Skip to content

[Bug] 连续工具调用提示只按工具名累计,参数变化时仍误判为重复调用 #7784

Description

@RhoninSeiei

发生了什么

Agent 连续多次调用同一个工具但参数不同、每次都在获取新信息时,系统仍按工具名累计连续调用次数,并触发重复调用提示。

在浏览器自动化任务中,模型可能需要多轮调用 astrbot_execute_browser_batch,每次参数都不同,例如点击、等待、截图、继续填写页面等。当前提示只看工具名,达到阈值后会出现 same tool 警告,容易误导模型停止有效操作。

如何重现

  1. 启用 Agent Sandbox 与浏览器工具。
  2. 在一次较长的网页任务中,让模型多次调用 astrbot_execute_browser_batch
  3. 每次调用使用不同参数,持续获取新的页面状态或截图。
  4. 当连续调用次数增加后,观察系统提示。

预期行为

连续工具调用提示应区分“同一工具同一参数反复调用”和“同一工具不同参数持续推进任务”。

对于同一工具但参数不同的调用,不应按单一工具名持续累计为重复调用。更合适的判断方式是使用工具名加参数指纹作为计数依据。

实际行为

即使参数不同,仍按工具名累计,触发类似提示:

[SYSTEM NOTICE] Important: you have executed the same tool `astrbot_execute_browser_batch` 26 times consecutively. Repetition is now very high. Continue only if each call is clearly producing new information. Otherwise, change strategy, adjust arguments, or explain the limitation to the user.

相关调用示例:

[Core] [INFO] [runners.tool_loop_agent_runner:975]: Agent 使用工具: ['astrbot_execute_browser_batch']
[Core] [INFO] [runners.tool_loop_agent_runner:1025]: 使用工具:astrbot_execute_browser_batch,参数:{'commands': ['click @e8', 'wait 1500', 'snapshot -i -C', 'screenshot ciallomeow_result.png'], 'timeout': 90, 'stop_on_error': True, 'description': '打开问卷结果页并截图', 'tags': 'ciallomeow,questionnaire,result', 'learn': False, 'include_trace': False}
[Core] [INFO] [runners.tool_loop_agent_runner:1222]: Tool `astrbot_execute_browser_batch` Result: {"success": true, ...}

运行环境

AstrBot: v4.23.5
Sandbox: Shipyard Neo
Tool: astrbot_execute_browser_batch

补充说明

本地验证显示,将连续调用计数从“工具名”调整为“工具名 + 参数 JSON 指纹”后,不同参数的同名工具调用不会被误计为同一种重复调用;相同工具和相同参数的重复调用仍然可以被识别。

参与贡献

  • 愿意提交 PR 修复该问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreThe bug / feature is about astrbot's core, backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions