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 06407154
authored
Jun 02, 2026
by
sunqi02
Committed by
胡悦
Jul 06, 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
ed7ea5df
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
31 deletions
workspace/agent-admin/backend/app/model/soul/agent.md
workspace/agent-admin/backend/app/service/agent_hub.py
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/model/soul/agent.md
deleted
100644 → 0
View file @
ed7ea5d
# 回复风格
## 语气
-
说人话,不官方不客套
-
出错直接认,不绕弯子
-
用户简洁我也简洁,用户话多我跟节奏
-
不每句结尾都问"还有什么可以帮您"
## 结构
-
先结论,再细节
-
能直接做的就做,不问"要不要我帮你"
-
不确定的再问;敏感操作先确认
## 微信适配
-
不用 markdown 符号(#
*
- _
`
),微信不渲染,会显示成乱码
-
用空行分段,段落短,手机一行才 20 多字,该断就断
-
用 emoji 做视觉标记,比如 📌 标重点、✅ 标完成、⚠️ 标注意
-
多条并列用数字序号:1. 2. 3.
-
链接能描述就描述,贴出来尽量短
-
一条能说完不拆五条,五条能说清也别硬塞一条
workspace/agent-admin/backend/app/service/agent_hub.py
View file @
0640715
...
@@ -147,6 +147,14 @@ class AgentHub:
...
@@ -147,6 +147,14 @@ class AgentHub:
)
)
self
.
formatter
=
OpenAIChatFormatter
()
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,更确定性
# sub_agent 专用 model:低 temperature,更确定性
self
.
sub_model
=
OpenAIChatModel
(
self
.
sub_model
=
OpenAIChatModel
(
model_name
=
self
.
main_model_config
.
model_name
,
model_name
=
self
.
main_model_config
.
model_name
,
...
@@ -306,7 +314,7 @@ class AgentHub:
...
@@ -306,7 +314,7 @@ class AgentHub:
if
sub_lines
:
if
sub_lines
:
prompt
+=
"
\n\n
## 可调用的子Agent
\n
"
+
"
\n
"
.
join
(
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
:
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."""
"""Build prompt for a sub-agent when handling a routed query."""
...
@@ -314,7 +322,7 @@ class AgentHub:
...
@@ -314,7 +322,7 @@ class AgentHub:
if
not
agent
:
if
not
agent
:
raise
AgentHubError
(
f
"Agent {agent_code} 配置未找到"
)
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
:
def
_dict_to_msg
(
self
,
m
:
dict
)
->
Msg
:
"""SessionStore dict → AgentScope Msg。只处理 user/assistant 文本消息。"""
"""SessionStore dict → AgentScope Msg。只处理 user/assistant 文本消息。"""
...
...
workspace/agent-admin/backend/soul/agent.md
View file @
0640715
...
@@ -19,3 +19,6 @@
...
@@ -19,3 +19,6 @@
-
链接能描述就描述,贴出来尽量短
-
链接能描述就描述,贴出来尽量短
-
一条能说完不拆五条,五条能说清也别硬塞一条
-
一条能说完不拆五条,五条能说清也别硬塞一条
## 行动风格
-
行动时只输出工具调用,不要附加解释
-
行动阶段用较低 temperature 减少"废话"
workspace/agent-admin/backend/test_request.json
View file @
0640715
...
@@ -25,15 +25,6 @@
...
@@ -25,15 +25,6 @@
"msg_type"
:
"file"
,
"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"
,
"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"
:
{}
"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 @
0640715
...
@@ -806,3 +806,23 @@ def test_sub_agent_prompt_includes_thinking_guide_only():
...
@@ -806,3 +806,23 @@ def test_sub_agent_prompt_includes_thinking_guide_only():
assert
"20"
in
prompt
assert
"20"
in
prompt
# sub 不应有 REVIEW_GUIDE
# sub 不应有 REVIEW_GUIDE
assert
"收到子Agent返回后"
not
in
prompt
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