feat(agents): let nested LoopAgents exit independently - #6842
Open
a2105z wants to merge 1 commit into
Open
Conversation
escalate=True still stops every enclosing loop so exit_loop stays backward compatible. EscalationContext(type='parent') is consumed by the nearest LoopAgent so an outer retry loop can continue. exit_current_loop is the parent-scoped tool. Fixes google#2808
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.
Summary
LoopAgents currently treat everyescalateas global: an innerexit_loop()also kills every ancestor loop. That is the Nested LoopAgents will escalate all LoopAgents #2808 report (expect 25 inner steps, get 5).escalate=Truewith no context stays root (today's behavior, includingexit_loop).EscalationContext(type='parent')is consumed by the nearestLoopAgent, which records itself onhandled_byso outer loops continue.exit_current_loopis the parent-scoped tool.target_agentaims the exit at a named loop. ParallelAgent ignores already-consumed parent escalations so siblings of an inner loop keep running.Test plan
57 loop/event/tool/parallel tests passed, plus the A2A peer-actions allow-list (escalation_context is not peer-settable).
Manual check: nested SequentialAgent → outer LoopAgent → inner LoopAgent with
exit_current_loopshould run inner×outer iterations;exit_loopstill unwinds every loop.Closes: #2808
@Jacksunwei @klateefa @hangfei @boyangsvl @wuliang229 @yeesian @xuanyang15 @steren @llalitkumarrr @GWeale @jhonratiu