-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.
Is your feature request related to a problem? Please describe.
Currently, SequentialAgent executes all sub-agents in sequence without the ability to terminate early when a certain condition is encountered. This can lead to unnecessary execution of subsequent agents when the first agent hits a blocking condition.
LoopAgent already has this capability using the escalate action and exit_loop tool, but SequentialAgent lacks this functionality.
Describe the solution you'd like
Implement an early exit mechanism for SequentialAgent that:
- Creates a new exit_sequence tool - similar to the existing exit_loop tool
- Updates SequentialAgent._run_async_impl - to check for event.actions.escalate and terminate the sequence early
- Provides consistent API - follows the same pattern as LoopAgent for developer familiarity
Describe alternatives you've considered
The alternative would be separating out any sub agents that could have a function leading to not requiring the rest of the sequence to run, but it would be much easier and cleaner to have the option to stop further executions and exit gracefully.
Additional context
- Create exit_sequence_tool.py following same pattern as exit_loop_tool.py
- Update SequentialAgent._run_async_impl with escalation detection
- Export new tool in tools/init.py
- Add comprehensive test coverage for async mode scenarios
- Ensure backward compatibility with existing SequentialAgent usage
- Update live mode (deferred due to complexity)
Scope Limitation
This initial implementation focuses on the async mode (_run_async_impl) only. The live mode (_run_live_impl) presents additional complexity due to:
- Continuous streaming semantics
- Function call detection in event streams
- Interaction with existing task_completed() mechanism