-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: Add early exit mechanism to SequentialAgent using escalate action #2999
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @tommyhutcheson, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a critical early exit mechanism for the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Response from ADK Triaging Agent Hello @tommyhutcheson, thank you for your contribution! To help us track and review this new feature, could you please create and associate a GitHub issue with this PR? Additionally, since this change introduces a new user-facing tool ( This information will help reviewers to review your PR more efficiently. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces an early exit mechanism for SequentialAgent
, which is a great feature for controlling agent flow. The implementation is clean and the new exit_sequence
tool is well-defined. The tests are also comprehensive and cover the main scenarios.
I have a couple of suggestions for improvement:
- In
sequential_agent.py
, the early exit logic can be simplified for better readability. - In
test_sequential_agent.py
, one of the assertions is a bit confusing and could be removed to improve test clarity.
Additionally, I noticed that the early exit mechanism has been implemented for _run_async_impl
, but it seems to be missing from _run_live_impl
. For consistency and to fully implement the feature, you should consider adding similar logic to _run_live_impl
to handle the escalate
action and prevent subsequent agents from running in a live session as well.
Overall, this is a solid contribution. My comments are aimed at refining the implementation.
b7446cd
to
bee8029
Compare
…lAgent similar to what exists in LoopAgent. Here's what was accomplished
…n the agent terminates the sequence immediately preventing subsequent agents from running.
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
…gent-using-escalate-action
Hey @boyangsvl @hangfei @Jacksunwei I have updated the PR to include exit_sequence support to both the _run_async_impl and _run_live_impl by implementing the escalate check in async and live modes. docs updated here too google/adk-docs#707 |
…gent-using-escalate-action
…gent-using-escalate-action
Summary
Implements early exit mechanism for SequentialAgent using escalate action to resolve #3000
Documentation PR: google/adk-docs#707
Implementation
New Tool:
exit_sequence
tool that setsescalate=True
andskip_summarization=True
exit_loop
for consistencySequentialAgent Updates:
_run_async_impl
to enable early termination_run_live_impl
for feature parity across modesTest Coverage:
test_run_async_with_escalate_action
- Early exit when first agent escalatestest_run_async_escalate_action_in_middle
- Escalation in middle of sequencetest_run_async_no_escalate_action
- Normal operation without escalationtest_run_live_with_escalate_action
- Live mode escalate supportBehaviour
When a sub-agent calls
exit_sequence()
, the SequentialAgent terminates immediately, preventing both:This works consistently in both async and live streaming modes.
Key Features
exit_loop
patternTesting
All 9 tests passing:
Fixes #3000