fix(delegate): inherit parent fallback_chain in _build_child_agent - #19601
Merged
Conversation
_build_child_agent constructed child AIAgents without passing fallback_model, leaving _fallback_chain=[] for every subagent. When a subagent hit a rate-limit or credential exhaustion the runtime fallback check (run_agent.py:7486 / 12267) found an empty chain and failed immediately — even though the parent agent was configured with fallback_providers and would have recovered. The cron scheduler already propagates fallback_model correctly (scheduler.py:1038). Fix closes the parity gap by reading the parent's _fallback_chain (the normalised list form accepted by AIAgent's fallback_model parameter) and threading it through. Empty chains coerce to None so AIAgent initialises _fallback_chain=[] as usual rather than iterating an empty list.
3 tasks
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.
Salvage of #19136 by @nftpoetrist onto current main.
Summary
_build_child_agentconstructed childAIAgents without passingfallback_model, leaving_fallback_chain=[]for every subagent. When a subagent hit a rate-limit or credential exhaustion, the runtime fallback chain was empty and the error surfaced immediately instead of rotating to another provider. Forwardparent_agent._fallback_chainwhen present.Changes
parent_fallbackinto child AIAgent constructorValidation
scripts/run_tests.sh tests/tools/test_delegate.py -k fallback -> 2 passed
Original PR: #19136 (only the delegate commit cherry-picked; the Slack-setup commit from the same branch was salvaged separately as #19583)