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 222becbc
authored
May 26, 2026
by
sunqi02
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat(agent_hub): 增加 IM 发送钩子的日志记录
1 parent
10dd61d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
workspace/agent-admin/backend/app/service/agent_hub.py
workspace/agent-admin/backend/app/service/agent_hub.py
View file @
222becb
...
...
@@ -26,6 +26,7 @@ async def _im_post_reasoning_hook(
*
,
im_service
,
account_mapping
,
room_id
,
user_id
,
bot_id_mapping
,
):
"""AgentScope native hook: 推理完成后通过 IM 发送 thinking 文本。"""
logger
.
info
(
f
"[Hook 触发] agent={self.name} 时机=post_reasoning"
)
bot_id
=
(
bot_id_mapping
.
get
(
self
.
name
)
or
account_mapping
.
get
(
self
.
name
))
if
not
bot_id
:
return
None
...
...
@@ -39,9 +40,10 @@ async def _im_post_reasoning_hook(
content
=
"
\n
"
.
join
(
content_parts
)
if
content_parts
else
None
if
not
content
:
return
None
logger
.
info
(
f
"[Hook 发送 IM] agent={self.name} bot_id={bot_id} content={content[:50]}..."
)
await
im_service
.
send_message
(
bot_id
=
bot_id
,
content
=
content
,
contact_id
=
room_id
,
at_list
=
user_id
,
contact_id
=
room_id
,
at_list
=
""
,
)
...
...
@@ -50,6 +52,7 @@ async def _im_pre_acting_hook(
*
,
im_service
,
account_mapping
,
room_id
,
user_id
,
bot_id_mapping
,
):
"""AgentScope native hook: 工具调用前通过 IM 发送即将执行的工具信息。"""
logger
.
info
(
f
"[Hook 触发] agent={self.name} 时机=pre_acting"
)
bot_id
=
(
bot_id_mapping
.
get
(
self
.
name
)
or
account_mapping
.
get
(
self
.
name
))
if
not
bot_id
:
return
None
...
...
@@ -57,9 +60,10 @@ async def _im_pre_acting_hook(
if
not
tool_call
:
return
None
content
=
str
(
tool_call
)
logger
.
info
(
f
"[Hook 发送 IM] agent={self.name} bot_id={bot_id} tool_call={tool_call}"
)
await
im_service
.
send_message
(
bot_id
=
bot_id
,
content
=
content
,
contact_id
=
room_id
,
at_list
=
user_id
,
contact_id
=
room_id
,
at_list
=
""
,
)
...
...
@@ -181,6 +185,7 @@ class AgentHub:
bot_id_mapping
:
Optional
[
Dict
[
str
,
str
]],
):
"""为 Agent 实例注册 IM 发送 hook。"""
logger
.
info
(
f
"[Hook 注册] agent={agent.name} 时机=post_reasoning"
)
route_ctx
=
dict
(
im_service
=
self
.
im_service
,
account_mapping
=
self
.
agent_to_account
,
...
...
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