Skip to content

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

@davidmonterocrespo24

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    core[Component] This issue is related to the core interface and implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions