-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Summary
I have implemented an early exit mechanism for SequentialAgent similar to what exists in LoopAgent to resolve #3000
Documentation PR - google/adk-docs#707
Here's what was accomplished:
Implementation Complete
- New tool function that sets escalate=True and skip_summarization=True
- Proper docstring explaining when to use the tool
- Follows the same pattern as exit_loop tool
- Modified _run_async_impl to check for event.actions.escalate after each event
- Added early termination logic with break and return statements
- Prevents subsequent agents from executing when escalation is triggered
- Added import for exit_sequence
- Added to all list for public API
- test_run_async_with_escalate_action: Tests early exit when first agent escalates
- test_run_async_escalate_action_in_middle: Tests escalation in middle of sequence
- test_run_async_no_escalate_action: Ensures normal operation when no escalation
- All tests passing
Key Features