Skip to content

fix: skip degraded tool record for workflow tools (#7053) - #7182

Open
tsumon wants to merge 1 commit into
1Panel-dev:v2from
tsumon:fix/skip-degraded-tool-record-7053
Open

tsumon wants to merge 1 commit into
1Panel-dev:v2from
tsumon:fix/skip-degraded-tool-record-7053

Conversation

@tsumon

@tsumon tsumon commented Sep 24, 2026

Copy link
Copy Markdown

问题

Fixes #7053

AI 对话节点调用工作流工具时,同一次执行会写入两条工具执行记录:

  1. 内部工作流执行完成时,ToolWorkflowPostHandler(apps/application/flow/i_step_node.py)经 ToolExecute.set_record 落库一条完整记录(meta 含 details,input 为 dict);
  2. 紧接着 agent 流在 apps/application/flow/tools.py 的 ToolMessage 分支无条件调用 save_tool_record,又落库一条降级记录(meta["input"] 是 JSON 字符串、无执行详情)。

两条记录 input/output/时间戳完全一致,即 issue 中描述的"重复保存,且重复那条数据有问题"。

修复

save_tool_record 中,对 ToolType.WORKFLOW 的工具直接跳过:内部工作流是在工具调用内同步执行的,完整记录一定先于 ToolMessage 处理落库,因此这条降级记录永远是多余的。函数库等其他类型工具没有后置处理器,仍依赖这条记录,行为不变。

注:之前 #7153 尝试过同方向修复,因 diff 重写了整个文件被关闭;这次 diff 仅 +5 行。

验证

  • python -m py_compile 通过;
  • 本仓库未配置 test runner(各 tests.py 为空桩),未做集成验证——复现需要 PG/Redis 及完整应用环境,CI/维护者复核时请以真实对话验证为准。

When a workflow tool is invoked from an AI chat node, the same execution
writes two tool execution records: a detailed one (with details) persisted
by ToolWorkflowPostHandler when the inner workflow completes, and a
degraded duplicate (meta.input as JSON string, no execution details) saved
unconditionally by save_tool_record while processing the ToolMessage.

The inner workflow runs synchronously inside the tool call, so the
detailed record is always persisted before the ToolMessage is processed.
Skip the degraded duplicate for workflow-type tools; other tool types
(e.g. custom tools converted to MCP servers) still rely on this record.
@tsumon

tsumon commented Sep 25, 2026

Copy link
Copy Markdown
Author

I traced the License Compliance failure: FOSSA reports the same 19 issues on this PR head (1d18934) and its exact parent/base commit (bfbbffb). This PR changes only apps/application/flow/tools.py and does not change dependencies or license metadata, so the failure predates this change. Could you confirm whether this baseline is tracked separately or if there is a specific package you want me to address?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 工作流工具的执行记录,重复保存了,且重复保存的那条数据还有问题

1 participant