Skip to content

fix: nested loop agents escalation issue #535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/google/adk/agents/loop_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ async def _run_async_impl(
while not self.max_iterations or times_looped < self.max_iterations:
for sub_agent in self.sub_agents:
async for event in sub_agent.run_async(ctx):
yield event
if event.actions.escalate:
# Reset the escalate status to make sure this escalation only exits one level of the loop agent, not the entire nested loop agents structure.
event.actions.escalate = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should instead check whether this is no more loop agent between this agent and the event author agent.


event.actions.escalate is the conversation history and we shouldn't alter it.

yield event
return
yield event
times_looped += 1
return

Expand Down