Skip to content

feat: Add Explicit Termination Mechanism for Multi-Agent Workflows (Similar to AutoGen "TERMINATE") #5211

Closed

Description

@davidmonterocrespo24

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 (like StopMessage in 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/OR logic (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:

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

  1. added 2 commits that reference this issue on Apr 8, 2026
    29ceadc
    3037c2c
  2. added
    core[Component] This issue is related to the core interface and implementation
    on Apr 9, 2026
  3. added theissue type on Apr 9, 2026
  4. self-assigned this
    on Apr 9, 2026
  5. llalitkumarrr commented on Apr 13, 2026

    @llalitkumarrr
    Collaborator

    Hello @davidmonterocrespo24 ,

    Thank you for sharing your input. We are currently reviewing it and will take the necessary steps. We appreciate your patience.

  6. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Apr 13, 2026
  7. DeanChensj commented on Oct 7, 2026

    @DeanChensj
    Collaborator

    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+):

    1. Agent-initiated termination:
      Agents can call the built-in exit_loop tool (from google.adk.tools import exit_loop), which sets tool_context.actions.escalate = True, or any custom tool/callback can set EventActions(end_invocation=True) / invocation_context.end_invocation = True to stop execution immediately.
    2. Workflow-level conditional termination & step budgets:
      In ADK 2.0 Workflow graphs (google/adk/workflow/), you can route any node directly to the END node (from google.adk.workflow import END) using conditional edge predicates on state or node output (edges=[(agent, END, lambda ctx: ...)]), alongside LoopAgent(max_iterations=...) and RunConfig(max_llm_calls=...).
    3. External Runner termination control:
      Runner.run_async(..., abort_signal=abort_event) accepts an asyncio.Event so 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

core[Component] This issue is related to the core interface and implementationneeds review[Status] The PR/issue is awaiting review from the maintainer

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions