feat(api_server): add POST /v1/runs/{run_id}/stop endpoint#1
Open
EKKOLearnAI wants to merge 3 commits into
Open
feat(api_server): add POST /v1/runs/{run_id}/stop endpoint#1EKKOLearnAI wants to merge 3 commits into
EKKOLearnAI wants to merge 3 commits into
Conversation
Add ability to interrupt a running agent via the runs API. Previously /v1/runs could start a run and subscribe to events, but there was no way to cancel it. The new endpoint stores agent and task references during execution, calls agent.interrupt() to stop LLM calls, then cancels the asyncio task. Includes 15 tests covering start, events, and stop scenarios.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /v1/runs/{run_id}/stopendpoint to interrupt a running agent_active_run_agentsand_active_run_tasksduring executionagent.interrupt()to gracefully stop LLM calls, then cancel the asyncio task_run_and_closefinally block and orphan sweepTest plan
python -m pytest tests/gateway/test_api_server_runs.py -v— 15 passedcurl -X POST http://localhost:8642/v1/runs -d '{"input":"hello"}'→ stop → verify events stream closes