Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ai
/
ai-workflow
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit cb6fb426
authored
Jun 08, 2026
by
sunqi02
Committed by
胡悦
Jul 06, 2026
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Revert "feat(agent_hub): 新增子Agent职责摘要功能,优化职责描述生成逻辑"
This reverts commit
932bfbd1
.
1 parent
1cc5b0fb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 additions
and
35 deletions
workspace/agent-admin/backend/app/main.py
workspace/agent-admin/backend/app/service/agent_hub.py
workspace/agent-admin/backend/app/main.py
View file @
cb6fb42
...
@@ -99,8 +99,6 @@ async def lifespan(app: FastAPI):
...
@@ -99,8 +99,6 @@ async def lifespan(app: FastAPI):
preloaded_agents
=
agents
,
preloaded_agents
=
agents
,
)
)
await
agent_hub_instance
.
summarize_agent_duties
()
# ── MessageGate 实例化 ──
# ── MessageGate 实例化 ──
from
app.service.message_gate
import
MessageGate
from
app.service.message_gate
import
MessageGate
from
app.hooks.post_reply
import
PostReplyHook
from
app.hooks.post_reply
import
PostReplyHook
...
...
workspace/agent-admin/backend/app/service/agent_hub.py
View file @
cb6fb42
...
@@ -247,9 +247,6 @@ class AgentHub:
...
@@ -247,9 +247,6 @@ class AgentHub:
group_name
=
"basic"
,
group_name
=
"basic"
,
)
)
# 子 Agent 职责摘要缓存(由 summarize_agent_duties() 填充)
self
.
agent_duty_summaries
:
Dict
[
str
,
str
]
=
{}
# 构建每个 agent 的专属 toolkit(按 skills 字段过滤)
# 构建每个 agent 的专属 toolkit(按 skills 字段过滤)
self
.
agent_toolkits
:
Dict
[
str
,
Toolkit
]
=
{}
self
.
agent_toolkits
:
Dict
[
str
,
Toolkit
]
=
{}
for
agent_code
,
agent_config
in
self
.
agents
.
items
():
for
agent_code
,
agent_config
in
self
.
agents
.
items
():
...
@@ -309,34 +306,6 @@ class AgentHub:
...
@@ -309,34 +306,6 @@ class AgentHub:
return
key
return
key
raise
AgentHubError
(
"未找到主 Agent(is_steward=True)"
)
raise
AgentHubError
(
"未找到主 Agent(is_steward=True)"
)
async
def
summarize_agent_duties
(
self
):
"""启动时用模型将每个子 Agent 的完整 prompt 总结为一句职责描述。"""
for
code
,
agent
in
self
.
agents
.
items
():
if
agent
.
is_steward
:
continue
if
not
agent
.
prompt
:
self
.
agent_duty_summaries
[
code
]
=
agent
.
name
continue
try
:
system_msg
=
Msg
(
"system"
,
"你是一个系统配置助手。请将以下Agent的完整系统提示词总结为一句职责范围描述(≤30字),只输出描述本身,不要加引号或解释。"
,
"system"
,
)
user_msg
=
Msg
(
"user"
,
agent
.
prompt
,
"user"
)
formatted
=
await
self
.
formatter
.
format
([
system_msg
,
user_msg
])
response
=
await
self
.
thinking_summary_model
(
formatted
)
text_parts
=
[]
for
block
in
response
.
content
:
if
isinstance
(
block
,
dict
)
and
block
.
get
(
"type"
)
==
"text"
:
text_parts
.
append
(
block
.
get
(
"text"
,
""
))
summary
=
""
.
join
(
text_parts
)
.
strip
()
self
.
agent_duty_summaries
[
code
]
=
summary
or
agent
.
name
logger
.
info
(
"子Agent职责摘要完成: code=
%
s name=
%
s summary=
%
s"
,
code
,
agent
.
name
,
summary
)
except
Exception
:
logger
.
warning
(
"子Agent职责摘要失败,回退用name: code=
%
s"
,
code
,
exc_info
=
True
)
self
.
agent_duty_summaries
[
code
]
=
agent
.
name
def
_build_main_prompt
(
def
_build_main_prompt
(
self
,
self
,
allowed_agent_codes
:
Optional
[
list
]
=
None
,
allowed_agent_codes
:
Optional
[
list
]
=
None
,
...
@@ -355,8 +324,7 @@ class AgentHub:
...
@@ -355,8 +324,7 @@ class AgentHub:
continue
continue
if
allowed_agent_codes
is
not
None
and
code
not
in
allowed_agent_codes
:
if
allowed_agent_codes
is
not
None
and
code
not
in
allowed_agent_codes
:
continue
continue
duty
=
self
.
agent_duty_summaries
.
get
(
code
)
or
f
"{agent.name}相关任务"
sub_lines
.
append
(
f
"- {agent.name}(调用码: {code}): {agent.name}相关任务"
)
sub_lines
.
append
(
f
"- {agent.name}(调用码: {code}): {duty}"
)
if
sub_lines
:
if
sub_lines
:
prompt
+=
"
\n\n
## 可调用的子Agent
\n
"
+
"
\n
"
.
join
(
sub_lines
)
prompt
+=
"
\n\n
## 可调用的子Agent
\n
"
+
"
\n
"
.
join
(
sub_lines
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment