Skip to content

feat(kanban): add POST /runs/{run_id}/terminate endpoint#31097

Closed
Interstellar-code wants to merge 1 commit into
NousResearch:mainfrom
Interstellar-code:feat/kanban-terminate-run
Closed

feat(kanban): add POST /runs/{run_id}/terminate endpoint#31097
Interstellar-code wants to merge 1 commit into
NousResearch:mainfrom
Interstellar-code:feat/kanban-terminate-run

Conversation

@Interstellar-code

Copy link
Copy Markdown
Contributor

Summary

  • Adds POST /runs/{run_id}/terminate to the Kanban dashboard plugin API
  • Closes the termination-control gap left by feat(kanban): worker visibility endpoints (workers/active, runs/{id}, inspect) (#23761) #28432, which shipped only the read-only sibling endpoints (/workers/active, /runs/{run_id}, /runs/{run_id}/inspect)
  • Pure HTTP wrapper around the existing kanban_db.reclaim_task() flow — no new termination semantics introduced, so the SIGTERM→SIGKILL escalation, run-outcome bookkeeping, and event-log append all match POST /tasks/{task_id}/reclaim

Behavior

Status Condition
200 {ok, run_id, task_id} Worker terminated, task reset to ready
404 Unknown run_id
409 Run already ended_at, or task no longer in a reclaimable state

Auth follows the existing dashboard session-token middleware — same exposure surface as the sibling /runs/* endpoints.

Test plan

  • tests/plugins/test_kanban_worker_runs.py — 5 new cases covering happy path, 404 unknown id, 409 already ended, 409 task not reclaimable, empty body accepted
  • Full suite green (16/16) for the test file
  • ruff check clean on both modified files

Closes #23762
Refs #28432

🤖 Generated with Claude Code

Closes the termination-control gap left by PR NousResearch#28432, which shipped the
read-only sibling endpoints (/workers/active, /runs/{run_id},
/runs/{run_id}/inspect) but no way to stop a misbehaving worker from
the dashboard without dropping to the CLI.

The new endpoint resolves run_id -> task_id and delegates to the
existing kanban_db.reclaim_task() flow, so the SIGTERM->SIGKILL
escalation, run-outcome bookkeeping, and event-log append all match
POST /tasks/{task_id}/reclaim exactly. No new termination semantics
introduced.

Responses:
  200 {ok, run_id, task_id} on success
  404 unknown run_id
  409 run already ended OR task no longer reclaimable

Refs: NousResearch#23762
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #34449 (commit 8d57281, rebase-merged). Your commit (0b07d86b4) was cherry-picked onto current main with your authorship preserved in git log — your name shows up correctly on the merged commit and you're credited in scripts/release.py AUTHOR_MAP.

The salvage PR was identical to your original (16/16 tests pass, no functional changes). Cherry-picking onto current main + adding the AUTHOR_MAP entry was the only delta. Closes #23762 as you intended.

Thanks for the clean implementation — minimal diff, comprehensive tests, semantic-contract match with the sibling POST /tasks/{id}/reclaim endpoint. This is the shape we want from contributor PRs.

@teknium1 teknium1 closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Public termination endpoint for kanban runs (POST /runs/{run_id}/terminate)

3 participants