Skip to content

fix: apply max_agent_step config to subagents#5608

Merged
Soulter merged 3 commits intomasterfrom
copilot/fix-subagent-tool-call-limit
Mar 2, 2026
Merged

fix: apply max_agent_step config to subagents#5608
Soulter merged 3 commits intomasterfrom
copilot/fix-subagent-tool-call-limit

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

Sub-agents ignored the user-configured "工具调用轮数上限" (provider_settings.max_agent_step) and always capped tool calls at 30 steps, while the main agent correctly respected the configured value.

Change

  • astrbot/core/astr_agent_tool_exec.py: Replace hardcoded max_steps=30 in the subagent handoff call with a config lookup, consistent with how stream is already read in the same call:
# Before
max_steps=30,

# After
max_steps=ctx.get_config().get("provider_settings", {}).get("max_agent_step", 30),
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]希望工具调用轮数上限对subagent生效</issue_title>
<issue_description>### Description / 描述

希望工具调用轮数上限对subagent生效

  1. 前往桌面应用->配置文件->普通配置->AI配置页面
  2. 设置工具调用轮数上限100000
  3. 用Telegram对话
  4. 向主agent要求分配长自动化任务给subagent

预期:
能顺利执行
实际:
subagent调用工具超过30次后回复调用工具达到上限
[2026-03-01 18:09:54.963] [Core] [WARN] [v4.18.3] [runners.tool_loop_agent_runner:560]: Agent reached max steps (30), forcing a final response.

PS:让主agent进行长自动化任务不会出现,看起来只对主Agent生效

Use Case / 使用场景

需要subagent进行长自动化任务的时候

Willing to Submit PR? / 是否愿意提交PR?

  • Yes, I am willing to submit a PR. / 是的,我愿意提交 PR。

Code of Conduct

  • I have read and agree to abide by the project's Code of Conduct. /
    </issue_description>

<agent_instructions>subagent 的 max step 配置应用配置文件中的。</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tool call limit for subagent functionality fix: apply max_agent_step config to subagents Mar 1, 2026
@Soulter Soulter marked this pull request as ready for review March 2, 2026 05:58
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. area:core The bug / feature is about astrbot's core, backend labels Mar 2, 2026
@dosubot
Copy link
Copy Markdown

dosubot bot commented Mar 2, 2026

Documentation Updates

1 document(s) were updated by changes in this PR:

pr4697的改动
View Changes
@@ -173,13 +173,13 @@
 
 ##### 工具调用轮数上限配置(PR #5608)
 
-[PR #5608](https://github.com/AstrBotDevs/AstrBot/pull/5608) 修复了子代理未正确继承用户配置的工具调用轮数上限的问题([Issue #5595](https://github.com/AstrBotDevs/AstrBot/issues/5595))。修复前,子代理始终使用硬编码的 30 步上限,忽略了用户在"工具调用轮数上限"(`provider_settings.max_agent_step`)中的配置,而主代理能够正确遵循该配置。
-
-修复后,子代理与主代理行为保持一致:
+[PR #5608](https://github.com/AstrBotDevs/AstrBot/pull/5608) 修复了子代理未正确继承用户配置的工具调用轮数上限的问题([Issue #5595](https://github.com/AstrBotDevs/AstrBot/issues/5595))。在此修复之前,子代理始终使用硬编码的 30 步上限,忽略了用户在"工具调用轮数上限"(`provider_settings.max_agent_step`)中的配置,而主代理能够正确遵循该配置。
+
+该修复现已实施,子代理与主代理行为保持一致:
 
 - 子代理执行时,`max_steps` 参数从系统配置 `provider_settings.max_agent_step` 读取(默认值为 30)
 - 用户可通过桌面应用 → 配置文件 → 普通配置 → AI 配置页面,统一设置主代理和子代理的工具调用轮数上限
-- 确保子代理在执行长自动化任务时不会因硬编码上限而提前终止
+- 子代理在执行长自动化任务时不再因硬编码上限而提前终止,而是遵循用户配置的上限值
 
 ##### 参考图片自动传递(PR #5579)
 

How did I do? Any feedback?  Join Discord

@Soulter Soulter merged commit 460acf4 into master Mar 2, 2026
5 checks passed
@Soulter Soulter deleted the copilot/fix-subagent-tool-call-limit branch March 2, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]希望工具调用轮数上限对subagent生效

2 participants