diff --git a/tools/delegate_tool.py b/tools/delegate_tool.py index 5e1875b5198..1be02f240e0 100644 --- a/tools/delegate_tool.py +++ b/tools/delegate_tool.py @@ -130,6 +130,12 @@ _SUBAGENT_TOOLSETS = sorted( _TOOLSET_LIST_STR = ", ".join(f"'{n}'" for n in _SUBAGENT_TOOLSETS) _DEFAULT_MAX_CONCURRENT_CHILDREN = 3 +# One-shot guard: the high-concurrency cost advisory is emitted at most once +# per process. _get_max_concurrent_children() runs on every get_definitions() +# schema rebuild (via _build_top_level_description / _build_tasks_param_description), +# so without this flag a config of max_concurrent_children>10 spams the log on +# every turn / agent spawn even when delegate_task is never called. +_HIGH_CONCURRENCY_WARNED = False MAX_DEPTH = 1 # flat by default: parent (0) -> child (1); grandchild rejected unless max_spawn_depth raised. # Configurable depth cap consulted by _get_max_spawn_depth; MAX_DEPTH # stays as the default fallback and is still the symbol tests import. @@ -374,11 +380,14 @@ def _get_max_concurrent_children() -> int: try: result = max(1, int(val)) if result > 10: - logger.warning( - "delegation.max_concurrent_children=%d: each child consumes API tokens " - "independently. High values multiply cost linearly.", - result, - ) + global _HIGH_CONCURRENCY_WARNED + if not _HIGH_CONCURRENCY_WARNED: + _HIGH_CONCURRENCY_WARNED = True + logger.warning( + "delegation.max_concurrent_children=%d: each child consumes API tokens " + "independently. High values multiply cost linearly.", + result, + ) return result except (TypeError, ValueError): logger.warning(