Skip to content

fix(tools): 修复工具系统的多个问题#31

Merged
69gg merged 6 commits intomainfrom
bugfix/bugs-3-tools
Feb 15, 2026
Merged

fix(tools): 修复工具系统的多个问题#31
69gg merged 6 commits intomainfrom
bugfix/bugs-3-tools

Conversation

@69gg
Copy link
Owner

@69gg 69gg commented Feb 15, 2026

修复内容

1. 修复工具名误加前缀问题

  • 问题skills/registry.py 在注册工具时使用了原始 config 而不是处理后的 item.config
  • 影响:导致工具名被重复添加前缀(如 memory.memory.add
  • 修复:使用 item.config 替代原始 config,确保工具名正确

2. 修复工具配置中的分隔符问题

  • 问题:toolsets 的 config.json 中工具名包含了类别前缀(如 memory.add
  • 影响:与注册逻辑冲突,导致工具名格式错误
  • 修复:移除 config.json 中的前缀,由注册系统自动添加
  • 涉及工具
    • memory: add, delete, list, update
    • notices: get, list, stats
    • messages: send_group_sign

3. 完善上下文注入

  • 新增:向工具 context 注入 memory_storageruntime_config
  • 位置ai_coordinator.pyscheduler.py
  • 目的:使工具能够访问记忆存储和运行时配置

4. 优化 naga agent 文件读取工具

  • 新增参数max_chars - 可选的最大字符数限制
  • 改进截断逻辑
    • 从硬编码的 10000 字符改为可配置限制
    • 提供更清晰的截断提示信息(显示总字符数和截断位置)
  • 建议用法:小文件不指定,大文件可设置为 50000-100000

5. 修复 end 工具的消息发送检查

  • 新增参数force - 强制结束对话,跳过未发送消息检查
  • 新增检查:如果有 summary 但本轮未发送消息,拒绝执行(除非 force=true)
  • 新增标记:在所有消息发送处设置 context["message_sent_this_turn"] = True
  • 涉及文件
    • tools/end/handler.py - 添加检查逻辑
    • toolsets/messages/send_message/handler.py - 添加标记
    • toolsets/messages/send_private_message/handler.py - 添加标记

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d251522cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 45 to 47
if summary and not force:
message_sent = context.get("message_sent_this_turn", False)
if not message_sent:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Account for non-text send tools before blocking end

This new guard blocks end whenever message_sent_this_turn is false, but in this commit only send_message/send_private_message set that flag. Other user-facing tools (for example render_markdown and render_latex) can already send content via sender/send_image_callback without updating this key, so a valid flow of "send image, then end with summary" is now rejected and can force extra model loops or force=true workarounds.

Useful? React with 👍 / 👎.

Comment on lines 42 to 45

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate force as bool before bypassing end guard

The bypass uses force = args.get("force", False) and then checks if summary and not force, so any truthy non-boolean value (e.g. a model-emitted string "false") disables the protection. Because parse_tool_arguments preserves value types, malformed but common tool-call payloads can skip the unsent-message check unintentionally.

Useful? React with 👍 / 👎.

在 OneBotClient send_group_message/send_private_message 成功后统一写入 RequestContext 的 message_sent_this_turn。

end 工具读取消息发送标记时增加 RequestContext 回退,避免依赖各工具单独打标。

force 参数仅接受 bool,非 bool 记录 warning 并按 false 处理。
@69gg 69gg merged commit a7eae8e into main Feb 15, 2026
1 check passed
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.

1 participant

Comments