Repository navigation
Description
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
hung12ct commentedon Jun 25, 2025
I think this feature is really necessary. Currently, I'm wondering if there's any workaround to stop a runner?
limboinf commentedon Jun 25, 2025
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.
growmuye commentedon Jun 26, 2025
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
sdivakarrajesh commentedon Jul 12, 2025
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 terminationkylebarone commentedon Jul 26, 2025
Is there any update on this?
firefox1918 commentedon Aug 6, 2025
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.
growmuye commentedon Aug 8, 2025
@firefox1918 hi,我自己做了一个stop,具体见#2068 第一个comment,或许对你有用
klateefa commentedon Dec 9, 2025
@limboinf Thanks for your request! We are looking into it,This feature is currently under review
Thank you for understanding.
davidmonterocrespo24 commentedon Mar 14, 2026
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)
GWeale commentedon Sep 3, 2026
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.