fix(subagents): raise general-purpose max_turns to 150 and default timeout to 30min (#3610)

* fix(subagents): raise general-purpose max_turns to 150 and default timeout to 30min

Deep-research subtasks failed out of the box with GraphRecursionError (Recursion limit of 100 reached): the built-in general-purpose subagent caps at max_turns=100. Raise it to 150 and bump the default subagent timeout from 900s (15min) to 1800s (30min) so the extra turns have time to run instead of shifting the failure to a timeout. The lead agent recursion_limit (100) is unchanged; the failures are subagent-only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(subagents): clarify lead recursion_limit is independent of subagent max_turns

Add comments at both lead recursion_limit=100 sites (gateway services + channel manager) explaining the lead's LangGraph super-step budget is separate from subagent depth, so the two 100s are not conflated. Comment-only, no behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(subagents): clarify built-in vs custom timeout scope; pin bash max_turns in test

Review follow-ups: (1) clarify SubagentConfig docstring + global timeout field/comment that the 1800 default applies to built-in subagents (custom agents keep their own timeout_seconds); (2) pin bash.max_turns==60 in the defaults regression test so the config.example.yaml doc cannot drift; (3) rename test_default_timeout_preserved_when_no_config -> test_explicit_global_timeout_propagates_to_general_purpose since it intentionally exercises an explicit non-default 900. No runtime behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
DanielWalnut
2026-06-16 19:55:04 +08:00
committed by GitHub
parent d2cc991d55
commit 05be7ea688
9 changed files with 50 additions and 16 deletions
+21 -4
View File
@@ -97,7 +97,7 @@ class TestSubagentOverrideConfig:
class TestSubagentsAppConfigDefaults:
def test_default_timeout(self):
config = SubagentsAppConfig()
assert config.timeout_seconds == 900
assert config.timeout_seconds == 1800
def test_default_max_turns_override_is_none(self):
config = SubagentsAppConfig()
@@ -281,7 +281,7 @@ class TestLoadSubagentsConfig:
def test_load_empty_dict_uses_defaults(self):
load_subagents_config_from_dict({})
cfg = get_subagents_app_config()
assert cfg.timeout_seconds == 900
assert cfg.timeout_seconds == 1800
assert cfg.max_turns is None
assert cfg.agents == {}
@@ -319,13 +319,30 @@ class TestRegistryGetSubagentConfig:
assert get_subagent_config("general-purpose") is not None
assert get_subagent_config("bash") is not None
def test_default_timeout_preserved_when_no_config(self):
def test_explicit_global_timeout_propagates_to_general_purpose(self):
"""An explicit global timeout (here the non-default 900) propagates to a
built-in agent, while max_turns still comes from the builtin def (150).
"""
from deerflow.subagents.registry import get_subagent_config
_reset_subagents_config(timeout_seconds=900)
config = get_subagent_config("general-purpose")
assert config.timeout_seconds == 900
assert config.max_turns == 100
assert config.max_turns == 150
def test_builtin_defaults_have_research_headroom(self):
"""Out-of-box defaults (no config.yaml subagents section) must give
general-purpose enough turns/time for deep research, which previously
failed with GraphRecursionError at the old max_turns=100 limit.
"""
from deerflow.subagents.registry import get_subagent_config
load_subagents_config_from_dict({}) # no subagents config -> model defaults
config = get_subagent_config("general-purpose")
assert config.max_turns == 150
assert config.timeout_seconds == 1800
# Pin bash too so the config.example.yaml "bash=60" doc cannot drift.
assert get_subagent_config("bash").max_turns == 60
def test_global_timeout_override_applied(self):
from deerflow.subagents.registry import get_subagent_config