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 63030cba
authored
Jun 02, 2026
by
sunqi02
Committed by
胡悦
Jul 01, 2026
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat(agent_hub): inject soul_guide into main and sub-agent prompts
1 parent
4bfc0b92
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
11 deletions
workspace/agent-admin/backend/app/service/agent_hub.py
workspace/agent-admin/backend/docs/superpowers/sunqi/plans/2026-06-02-sub-agent-thinking-control-plan.md
workspace/agent-admin/backend/app/model/soul/agent.md → workspace/agent-admin/backend/soul/agent.md
workspace/agent-admin/backend/test_request.json
workspace/agent-admin/backend/tests/test_agent_hub.py
workspace/agent-admin/backend/app/service/agent_hub.py
View file @
63030cb
...
...
@@ -147,6 +147,14 @@ class AgentHub:
)
self
.
formatter
=
OpenAIChatFormatter
()
# 加载回复风格指南(soul/agent.md)
soul_path
=
Path
(
__file__
)
.
parent
.
parent
.
parent
/
"soul"
/
"agent.md"
if
soul_path
.
exists
():
self
.
soul_guide
=
soul_path
.
read_text
(
encoding
=
"utf-8"
)
else
:
self
.
soul_guide
=
""
logger
.
warning
(
f
"soul/agent.md 未找到: {soul_path}"
)
# sub_agent 专用 model:低 temperature,更确定性
self
.
sub_model
=
OpenAIChatModel
(
model_name
=
self
.
main_model_config
.
model_name
,
...
...
@@ -306,7 +314,7 @@ class AgentHub:
if
sub_lines
:
prompt
+=
"
\n\n
## 可调用的子Agent
\n
"
+
"
\n
"
.
join
(
sub_lines
)
return
prompt
+
REVIEW_GUIDE
+
THINKING_GUIDE
return
prompt
+
self
.
soul_guide
+
REVIEW_GUIDE
+
THINKING_GUIDE
def
_build_sub_agent_prompt
(
self
,
agent_code
:
str
,
context
:
Dict
[
str
,
Any
])
->
str
:
"""Build prompt for a sub-agent when handling a routed query."""
...
...
@@ -314,7 +322,7 @@ class AgentHub:
if
not
agent
:
raise
AgentHubError
(
f
"Agent {agent_code} 配置未找到"
)
return
agent
.
prompt
+
THINKING_GUIDE
# sub 加思考风格
约束
return
agent
.
prompt
+
self
.
soul_guide
+
THINKING_GUIDE
# sub 加回复风格+思考
约束
def
_dict_to_msg
(
self
,
m
:
dict
)
->
Msg
:
"""SessionStore dict → AgentScope Msg。只处理 user/assistant 文本消息。"""
...
...
workspace/agent-admin/backend/docs/superpowers/sunqi/plans/2026-06-02-sub-agent-thinking-control-plan.md
0 → 100644
View file @
63030cb
This diff is collapsed.
Click to expand it.
workspace/agent-admin/backend/
app/model/
soul/agent.md
→
workspace/agent-admin/backend/soul/agent.md
View file @
63030cb
...
...
@@ -18,3 +18,7 @@
-
多条并列用数字序号:1. 2. 3.
-
链接能描述就描述,贴出来尽量短
-
一条能说完不拆五条,五条能说清也别硬塞一条
## 行动风格
-
行动时只输出工具调用,不要附加解释
-
行动阶段用较低 temperature 减少"废话"
workspace/agent-admin/backend/test_request.json
View file @
63030cb
...
...
@@ -25,15 +25,6 @@
"msg_type"
:
"file"
,
"msg_content"
:
"https://glsk-agentic-test.oss-cn-shenzhen.aliyuncs.com/meeting-minutes%2Faudio%2F1219%E4%BA%8C%E6%89%8B%E8%BD%A6%E4%BE%8B%E4%BC%9A%EF%BC%88%E8%B5%B5%E6%80%BB%EF%BC%89.mp3"
,
"payload"
:
{}
},
{
"msg_id"
:
"m5"
,
"msg_time"
:
"2026-05-26T10:00:00Z"
,
"sender_id"
:
""
,
"sender_name"
:
"孙奇"
,
"msg_type"
:
"text"
,
"msg_content"
:
"请帮我把这段会议录音转成文字,并总结会议纪要。"
,
"payload"
:
{}
}
]
}
workspace/agent-admin/backend/tests/test_agent_hub.py
View file @
63030cb
...
...
@@ -806,3 +806,23 @@ def test_sub_agent_prompt_includes_thinking_guide_only():
assert
"20"
in
prompt
# sub 不应有 REVIEW_GUIDE
assert
"收到子Agent返回后"
not
in
prompt
# ── Tests for soul_guide injection ──
def
test_main_prompt_includes_soul_guide
():
"""_build_main_prompt 输出应包含 soul/agent.md 的回复风格内容。"""
hub
=
_make_test_hub
()
context
=
{
"user_query"
:
"test"
,
"messages"
:
[],
"room_id"
:
"r1"
,
"user_id"
:
"u1"
}
prompt
=
hub
.
_build_main_prompt
(
context
)
assert
"说人话"
in
prompt
assert
"微信适配"
in
prompt
def
test_sub_agent_prompt_includes_soul_guide
():
"""_build_sub_agent_prompt 输出应包含 soul/agent.md 的回复风格内容。"""
hub
=
_make_test_hub
()
prompt
=
hub
.
_build_sub_agent_prompt
(
MEETING_KEY
,
{})
assert
"说人话"
in
prompt
assert
"微信适配"
in
prompt
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