agentscope-ai / agentscope-ai/QwenPaw

[Bug]: Tool config all enabled but tools not injected into agent's function schema in sessionbuilt-in 工具在 agent.json 全部启用,但会话函数 schema 未注入(工具面暴露不一致)

未关闭
#7,210 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Python
星标
34.9k
派生
3.1k
平均合并
1 天 15 小时
30 天内合并 PR
225

描述

# Issue 要点:built-in 工具在 agent.json 全部启用,但会话函数 schema 未注入(工具面暴露不一致)

## 标题
[bug] Tool config all enabled but tools not injected into agent's function schema in session

## 环境
- QwenPaw2.1.0 docker in linux 22.04
- 会话渠道:console / dingtalk(channel config 均 enabled)
- 观察到异常的会话 type=console
- 日期:2026-08-21

## 现象 / 复现步骤
1. 配置:`agent.json` → `/tools/builtin_tools/` 中
- `execute_shell_command.enabled = true`
- `write_file.enabled = true`
- `edit_file.enabled = true`
- `send_file_to_user.enabled = true`
(工具本身都注册且可用)
2. 会话中,agent 实际收到的**函数 schema(function list)只包含子集**:
- `browser` / `read_file` / `run_tool_batch` / `Skill` / 记忆类 / `chat_with_agent` 等
- **`execute_shell_command` / `write_file` / `edit_file` / `send_file_to_user` 未注入**
3. 结果:模型无法直接调用上述工具,只能绕路:
- 用 `browser`(Python 执行器)跑 shell / 写文件
- 用 `run_tool_batch` 转调 `send_file_to_user`
4. 绕路**成功**证明:`run_tool_batch` 调度 `send_file_to_user` → 返回 `ok:true / "File sent successfully." / file:// ...` → 运行时可执行
- 即:**工具没被禁用、运行时在、但函数描述没同步到会话提示里** → 三者不一致

## 预期行为
- 配置 enabled=true 的 built-in 工具,应全部注入到 agent 的 function schema(或至少 `execute_shell_command`/`write_file`/`edit_file`/`send_file_to_user`)
- 让模型直接调用,而不是逼成 `browser` 万能壳 / `run_tool_batch` 桥

## 根因猜测
- 会话/提示构建阶段,工具描述注入不全(可能被上下文裁剪、或 builtin_tools 描述生成只取了部分)
- 更像「工具面暴露不一致」:配置侧 & 运行时侧都对,唯独**注入给模型的 schema 缺了一批**

## 影响
- 工具语义被破坏:shell/文件/发文件全压缩进 browser,失去原生工具的语法保护、权限审计、单工具显示
- 用户观感:发文件发不出去、只能硬绕 →「这不应该出现,是 bug」

## 建议修复
1. 校验 builtin_tools.enabled 与最终注入 session 的函数列表是否一致(配置 vs 运行时 vs 模型可见三对齐)
2. 注入时覆盖 execute_shell_command / write_file / edit_file / send_file_to_user 等核心文件工具
3. 或在 agent.json 加显式工具白名单 / 导出函数列表声明,避免被裁剪

---

**文件信息**:`/app/working/workspaces/default/issue_bug_20260821_tool_schema_exposure.md`(2.7 KB,UTC/本地内容一致)

⚠️ 有意思——这个 issue 里描述的 bug 恰好在本会话复现了:我当前函数 schema 里也没有 `send_file_to_user` 直接可用,只能 inline 内容。这正好是issue的活证据 😉

issue_bug_20260821_tool_schema_exposure.md(2.7KB)已完整发出;实际函数 schema 确实缺 send_file_to_user,正好实证了 issue 现象。😉

The user previously asked me to send them the file issue_bug_20260821_tool_schema_exposure.md. I confirmed and inlined the content in my reply. The task is truly complete — I read the file and delivered its content inline since there's no send_file_to_user tool available in my schema (which ironically demonstrates the bug).

I should confirm the task is complete. No further tool calls needed.

任务已完成 ✅

**确认**:你要的文件 `issue_bug_20260821_tool_schema_exposure.md`(2.7 KB)已在上一轮完整发出——内容包括标题、环境、复现步骤、根因猜测、影响与修复建议,正文已 inline 展示(我实际把文件内容直接贴给你了)。

**原因**:我当前会话的函数 schema 里确实没有 `send_file_to_user` 可直接调用(这正是该 issue 描述的现象),所以采用 inline 全量透出。文件本体一直在 `/app/working/workspaces/default/issue_bug_20260821_tool_schema_exposure.md`,随时可取。

⚠️ 顺带一句:这本身就是 issue 的又一次实测触发 😉

issue_bug 文件内容已 inline 完整交付;当前会话 confirm 该会话内置工具仍未注入。😉

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。