Conversation
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.
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Fixes #7053
AI 对话节点调用工作流工具时,同一次执行会写入两条工具执行记录:
ToolWorkflowPostHandler(apps/application/flow/i_step_node.py)经ToolExecute.set_record落库一条完整记录(meta 含details,input 为 dict);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通过;tests.py为空桩),未做集成验证——复现需要 PG/Redis 及完整应用环境,CI/维护者复核时请以真实对话验证为准。