Skip to content

Feature Request: Add an Endpoint to Explicitly Stop/Terminate a Conversation #1621

Closed

Description

@limboinf

Feature Request: Add an Endpoint to Explicitly Stop/Terminate a Conversation

Background

In many real-world applications that integrate LLMs or agent frameworks, managing the lifecycle of a conversation is essential. It's not just about "starting" or "continuing"—sometimes we need to gracefully end a session. For example, a user may want to abort a long-running inference, free up backend resources, or quickly reset state in the case of an error. Currently, ADK does not appear to provide an explicit API to terminate a conversation.

Why Is This Important?

  • Resource Management: Conversations left open for extended periods can consume memory, file handles, or external service connections, leading to potential resource leaks.
  • User Experience: Users expect to be able to "end" a conversation with a single action, rather than waiting for a timeout or closing the frontend window.
  • Error Handling: In cases of infinite loops or stuck streaming responses, both developers and users need a way to interrupt processing immediately.
  • Business Logic Alignment: Many business flows naturally require an "abort" function, such as escalating to a human agent or canceling a task.

What Would Be Ideal?

I suggest exposing a RESTful endpoint in ADK, such as:

POST /conversations/{conversation_id}/stop

Calling this endpoint would immediately terminate all backend processing for the specified conversation (including streaming outputs and async tasks) and release related resources. The API should return a confirmation that the conversation has been stopped.

Design Suggestions

  • The endpoint should be idempotent: repeated calls to stop the same conversation should not cause errors.
  • If the conversation is already ended, return an appropriate message.
  • If the conversation does not exist, return a 404.
  • Optionally, support proactively notifying the frontend (e.g., via SSE) that the conversation has been terminated.

Related Discussion

I have not found existing issues or discussions on this feature in the tracker. If I've missed something, please let me know.


If this feature is on the roadmap, it would be great to hear about the expected timeline or design considerations. If community contributions are welcome, please advise on the contribution process.

Activity

  1. added
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Jun 24, 2025
  2. hung12ct commented on Jun 25, 2025

    @hung12ct
    Contributor

    I think this feature is really necessary. Currently, I'm wondering if there's any workaround to stop a runner?

  3. limboinf commented on Jun 25, 2025

    @limboinf
    Author

    Thanks for raising this. An explicit stop endpoint makes sense for both resource management and user control. It would also simplify error handling and recovery. Supporting idempotency and clear feedback for stopped or non-existent conversations is a good idea. Looking forward to seeing this feature implemented.

  4. growmuye commented on Jun 26, 2025

    @growmuye

    The same capability is needed, and research is currently underway on how to achieve it. The product requirement I received will soon require it.

    I created a discussion, but it seems like no one in the community... pays attention to this ability.
    #1616

  5. added theissue type on Jul 2, 2025
  6. sdivakarrajesh commented on Jul 12, 2025

    @sdivakarrajesh

    You can try setting the end_invocation flag in the _invocation_context(InvocationContext) to true in the ToolContext(in tool calls) or CallbackContext(in before or after model callback). It does stop, but i've seen a few more messages come up before actual termination

  7. kylebarone commented on Jul 26, 2025

    @kylebarone

    Is there any update on this?

  8. firefox1918 commented on Aug 6, 2025

    @firefox1918

    That's correct, the end_invocation property can terminate execution, but it's important to note that it terminates rather than pauses.
    You can check out the "Advanced: Direct InvocationContext Usage" section in https://google.github.io/adk-docs/context/#advanced-direct-invocationcontext-usage. It can be used in custom Agents and lifecycle callbacks between Agents and Tools, but its behavior doesn't meet expectations.
    I wrapped the termination logic in a custom Agent, but it throws an exception when executed. I haven't found a good solution yet.

  9. growmuye commented on Aug 8, 2025

    @growmuye

    That's correct, the end_invocation property can terminate execution, but it's important to note that it terminates rather than pauses. You can check out the "Advanced: Direct InvocationContext Usage" section in https://google.github.io/adk-docs/context/#advanced-direct-invocationcontext-usage. It can be used in custom Agents and lifecycle callbacks between Agents and Tools, but its behavior doesn't meet expectations. I wrapped the termination logic in a custom Agent, but it throws an exception when executed. I haven't found a good solution yet.

    @firefox1918 hi,我自己做了一个stop,具体见#2068 第一个comment,或许对你有用

  10. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Nov 19, 2025
  11. klateefa commented on Dec 9, 2025

    @klateefa

    @limboinf Thanks for your request! We are looking into it,This feature is currently under review
    Thank you for understanding.

  12. davidmonterocrespo24 commented on Mar 14, 2026

    @davidmonterocrespo24

    Hi @klateefa I made this pull request for the JavaScript version of ADK. What do you think about aligning it with the Python version?

    google/adk-js#193 (review)

  13. self-assigned this
    on Sep 3, 2026
  14. GWeale commented on Sep 3, 2026

    @GWeale
    Collaborator

    folding this into #2425. it's the same ask, and that's where the design conversation actually happened.

    yours is the older of the two, so this isn't about who filed first, just about keeping it in one place.

    one thing from your write-up that isn't covered over there: the idempotency behaviour. the 404 is already in #2425's description, but idempotency isn't. add it to that thread if you can.

    closing here.

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

Metadata

Metadata

Labels

needs review[Status] The PR/issue is awaiting review from the maintainerservices[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions