Skip to content

fix: resolve default values of tool init parameters not taking effect#6267

Open
DurantChan1 wants to merge 1 commit into
1Panel-dev:v2from
DurantChan1:durantchan1/fix_tool_default
Open

fix: resolve default values of tool init parameters not taking effect#6267
DurantChan1 wants to merge 1 commit into
1Panel-dev:v2from
DurantChan1:durantchan1/fix_tool_default

Conversation

@DurantChan1

Copy link
Copy Markdown

What this PR does / why we need it?

修复工具(Tool)初始化参数中配置的默认值(default_value)在部分场景下不生效的问题。

根因: 当工具的 init_field_list 中某个字段定义了 default_value,但用户已保存的 init_params 中不包含该字段时,代码直接使用 init_params 而跳过了默认值合并,导致该字段为空。

Summary of your change

在所有构建 tool_init_params 的地方,统一将 init_field_list 中的 default_value 作为基线,再与已保存的 init_params 合并(默认值 → 已保存参数),确保未配置的参数能正确回退到默认值
修改列表

  • base_chat_step.py:387:对话 pipeline 中自定义 tool 的 MCP 配置
  • base_chat_node.py:284:Flow 中 AI Chat 节点自定义 tool 的 MCP 配置
  • base_chat_node.py:335:Flow 中 AI Chat 节点 skill tool 参数配置
  • base_tool_node.py:99-105:工具节点执行时合并 init_params 与运行时入参
  • tools/serializers/tool.py:586-590:工具调试(Debug)模式下执行

Please indicate you've done the following:

本地验证:确认修改后工具调用时未配置参数字段能正确取到 init_field_list 中定义的 default_value
向后兼容:已有 init_params 的存量工具不受影响(用户参数优先级最高)
覆盖 4 条主要路径:对话、Flow 节点、工具节点执行、调试模式

  • [x ] Made sure tests are passing and test coverage is added if needed.
  • [x ] Made sure commit message follow the rule of Conventional Commits specification.
  • [x ] Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

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.

2 participants