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 2ca9309c
authored
Jun 18, 2026
by
sunqi02
Committed by
胡悦
Jul 06, 2026
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: optimize tool interaction saving to avoid duplicate historical messages
1 parent
49ada179
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
workspace/agent-admin/backend/app/service/agent_hub.py
workspace/agent-admin/backend/app/service/agent_hub.py
View file @
2ca9309
...
...
@@ -515,6 +515,7 @@ class AgentHub:
history_msgs
=
[
Msg
.
from_dict
(
m
)
for
m
in
recent
]
if
history_msgs
:
await
agent_memory
.
add
(
history_msgs
)
history_msg_count
=
len
(
history_msgs
)
# 用于后续只保存本次 ReAct 新增的工具消息
# Create per-request ReActAgent with per-agent toolkit
agent
=
ReActAgent
(
...
...
@@ -554,10 +555,11 @@ class AgentHub:
response_text
=
response_msg
.
get_text_content
()
or
""
# 纯文本,用于返回值和日志
target_agent_name
=
target_agent
# 1. 保存工具交互(
先于 assistant,保证 remove_last 只命中最终回复
)
# 1. 保存工具交互(
只保存本次 ReAct 新增的,避免历史工具消息重复追加
)
try
:
msg_list
=
await
agent
.
memory
.
get_memory
()
self
.
_save_tool_interactions
(
memory
,
msg_list
)
new_msgs
=
msg_list
[
history_msg_count
:]
self
.
_save_tool_interactions
(
memory
,
new_msgs
)
except
Exception
:
logger
.
warning
(
"[AgentHub] session=
%
s 保存工具消息异常(不影响主流程)"
,
...
...
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