fix subagent max iteration limit

This commit is contained in:
hanyuanling
2026-04-30 13:45:40 +08:00
committed by Xubin Ren
parent f8fd9f0011
commit 3c20d16117
5 changed files with 165 additions and 5 deletions
+7
View File
@@ -258,6 +258,7 @@ class AgentLoop:
exec_config=self.exec_config,
restrict_to_workspace=restrict_to_workspace,
disabled_skills=disabled_skills,
max_iterations=self.max_iterations,
)
self._unified_session = unified_session
self._max_messages = max_messages if max_messages > 0 else 120
@@ -307,6 +308,10 @@ class AgentLoop:
self.commands = CommandRouter()
register_builtin_commands(self.commands)
def _sync_subagent_runtime_limits(self) -> None:
"""Keep subagent runtime limits aligned with mutable loop settings."""
self.subagents.max_iterations = self.max_iterations
def _apply_provider_snapshot(self, snapshot: ProviderSnapshot) -> None:
"""Swap model/provider for future turns without disturbing an active one."""
provider = snapshot.provider
@@ -531,6 +536,8 @@ class AgentLoop:
Returns (final_content, tools_used, messages, stop_reason, had_injections).
"""
self._sync_subagent_runtime_limits()
loop_hook = _LoopHook(
self,
on_progress=on_progress,