fix(delegation): isolate subagent iteration budgets by default (fixes #2873)#2875
Closed
Mibayy wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix(delegation): isolate subagent iteration budgets by default (fixes #2873)#2875Mibayy wants to merge 1 commit intoNousResearch:mainfrom
Mibayy wants to merge 1 commit intoNousResearch:mainfrom
Conversation
Previously, all subagents inherited the parent's shared IterationBudget
object. This caused two compounding problems:
1. The parent's already-consumed turns reduced the budget available to
children before they even started.
2. In batch mode (3 parallel subagents), all children raced to consume
the same depleted pool, each getting roughly 1/N of what remained.
Example of the bug:
Parent uses 30 of 90 turns, then spawns 3 subagents with max_iterations=50.
Only 60 turns remain in the shared budget.
3 children race for 60 → each gets ~20 on average → all hit max_iterations
mid-task and exit with exit_reason: max_iterations.
Fix: introduce budget_mode config option (delegation.budget_mode).
isolated (default): each child gets a fresh IterationBudget(max_iterations)
starting at 0. max_iterations=50 means exactly 50 turns for that child,
regardless of parent consumption or sibling activity.
shared (legacy): preserves the old behaviour for users who explicitly
want a session-wide hard cap across parent + all children.
After this change:
Parent: 30/90 consumed (irrelevant to children in isolated mode)
Subagent 1: 0/50 fresh budget → can use all 50 turns
Subagent 2: 0/50 fresh budget → can use all 50 turns
Subagent 3: 0/50 fresh budget → can use all 50 turns
Fixes NousResearch#2873
Contributor
|
This was already fixed on main in commit 68ab37e (PR #3004), which sets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Subagents consistently exit with
exit_reason: max_iterationsbefore completing their task, even whenmax_iterationsis set explicitly. This is especially bad in batch mode with 3 parallel subagents.Root cause:
_build_child_agent()passes the parent'sIterationBudgetobject directly to each child. That budget is already partially consumed by the parent's own turns. In parallel batch mode, all 3 children share what's left and race to exhaust it.Fix
Introduce a
budget_modeconfig option underdelegation:inconfig.yaml.isolated(new default)Each child gets a fresh
IterationBudget(max_iterations)starting at 0.max_iterations=50means exactly 50 turns, independent of parent consumption or parallel siblings.shared(legacy)Preserves the old behaviour for users who explicitly want a session-wide cap across parent + all children combined. Not recommended but kept for backwards compatibility.
Changes
tools/delegate_tool.py— readbudget_modefrom config in_build_child_agent(); passiteration_budget=None(isolated) or the parent's budget object (shared). Added module-level docstring explaining both modes with concrete examples.website/docs/user-guide/features/delegation.md— new "Iteration Budget Modes" section with visual examples (bar charts), updated Configuration table.Config
Closes #2873