Repository navigation
feat: Add Explicit Termination Mechanism for Multi-Agent Workflows (Similar to AutoGen "TERMINATE") #5211
Description
Is your feature request related to a problem? Please describe.
In multi-agent workflows using ADK, agents can sometimes fall into infinite or
long-running loops during collaborative tasks. This happens especially when
orchestration depends only on message passing, with no built-in signal to
indicate that the task is completed.
Other multi-agent frameworks — for example, Microsoft's AutoGen — include
explicit termination mechanisms (e.g., TextMentionTermination,
StopMessageTermination, or custom termination callbacks) that help teams of
agents know when to gracefully stop.
In ADK today, there is no simple built-in mechanism for agents to signal "task
completed," which can lead to runaway conversations, wasted tokens, and stalled
agent workflows.
Describe the solution you'd like
ADK should support a standardized termination mechanism that allows:
- Agents to explicitly signal termination, for example by producing a
special message type (likeStopMessagein AutoGen) that ends the
conversation. - Teams to define termination conditions, such as detecting a specific
keyword ("TERMINATE"), max message counts, function call results, token
usage, or any other customizable logic. - External termination control, so applications integrating ADK can stop a
run programmatically (e.g., a UI "Stop" button). - Composable termination conditions, allowing multiple rules combined with
AND/ORlogic (similar to AutoGen's
MaxMessageTermination | TextMentionTermination).
This would give ADK parity with AutoGen's termination system and prevent
infinite loops in multi-agent workflows.
Describe alternatives you've considered
- Custom stop messages in agent prompts — unreliable; agents may not follow
instructions consistently. - Max iterations as a safeguard — prevents infinite loops but doesn't allow
agents to end a task early when done. - External timeout logic — helps with long runs but doesn't let agents
indicate intentional completion.
None of these provide the simple, robust, and explicit termination controls that
AutoGen offers.
Additional context
AutoGen's termination system includes the following primitives, all of which
this proposal aims to replicate in ADK:
| Condition | Description |
|---|---|
TextMentionTermination |
Stop when a keyword appears in content |
MaxMessageTermination |
Stop after N events |
TokenUsageTermination |
Stop when token budget is exceeded |
TimeoutTermination |
Stop after a wall-clock duration |
FunctionCallTermination |
Stop when a specific function is called |
ExternalTermination |
Stop on external async signal |
StopMessageTermination |
Stop on a special stop message type |
Cross-repository alignment
This feature is being implemented in parallel across both ADK implementations to
keep them aligned:
- adk-js — Feature request: Feature Request: Add Explicit Termination Mechanism for Multi-Agent Workflows (Similar to AutoGen “TERMINATE”) adk-js#29
- adk-js — Implementation PR (under review): feat: add termination conditions for multi-agent workflows adk-js#193
- adk-python — Implementation PR: feat(agents): add termination conditions for multi-agent workflows #5213
The goal is for both adk-python and adk-js to ship the same termination
primitives with a consistent API surface, so developers can reason about
termination the same way regardless of which SDK they use.
Activity
feat(agents): add termination conditions for multi-agent workflows
feat(agents): add termination conditions for multi-agent workflows
llalitkumarrr commentedon Apr 13, 2026
Hello @davidmonterocrespo24 ,
Thank you for sharing your input. We are currently reviewing it and will take the necessary steps. We appreciate your patience.
feat(termination): add pluggable termination conditions for multi-age…
DeanChensj commentedon Oct 7, 2026
Thank you so much for taking the time to put together this thorough proposal for explicit multi-agent workflow termination!
We wanted to share that all three termination layers described here are now supported in
google-adk(v2.11.0+):Agents can call the built-in
exit_looptool (from google.adk.tools import exit_loop), which setstool_context.actions.escalate = True, or any custom tool/callback can setEventActions(end_invocation=True)/invocation_context.end_invocation = Trueto stop execution immediately.In ADK 2.0
Workflowgraphs (google/adk/workflow/), you can route any node directly to theENDnode (from google.adk.workflow import END) using conditional edge predicates on state or node output (edges=[(agent, END, lambda ctx: ...)]), alongsideLoopAgent(max_iterations=...)andRunConfig(max_llm_calls=...).Runner.run_async(..., abort_signal=abort_event)accepts anasyncio.Eventso callers can cleanly abort a running agent or multi-agent workflow externally at any time.I'm closing this issue as these capabilities are now built in. If you find any gaps or have additional use cases that aren't covered, please feel free to open a new issue or PR!