Skip to content

Add cancellable SDK run controller - #850

Closed
victorxheng wants to merge 7285 commits into
mainfrom
fix/stop-running-cloud-jobs-2026070707
Closed

Add cancellable SDK run controller#850
victorxheng wants to merge 7285 commits into
mainfrom
fix/stop-running-cloud-jobs-2026070707

Conversation

@victorxheng

Copy link
Copy Markdown

User request

A Freebuff cloud user reported that long-running terminal commands or autonomous agent work can get stuck for 20+ minutes, and requested a user-controlled way to terminate the running work.

Implementation

  • Added CodebuffRunController and createRunController() in the SDK.
  • Added CodebuffClient.runCancellable(), which returns { id, controller, signal, result, cancel } for hosts to keep in an in-flight run registry and call from a Stop/Terminate UI or API action.
  • The cancel path composes with any caller-provided AbortSignal, then flows through the existing runtime cancellation path used by LLM streams, subagents, tool execution, and terminal commands.
  • Exported the new controller and CancellableRun type from the SDK entrypoint.
  • Added tests proving cancel() aborts an already-running agent signal and that external caller signals still abort the same run.

Confidence / verification

Ready to merge with high confidence for the SDK/runtime control surface. Verified locally:

  • bun test sdk/src/__tests__/client-cancellable-run.test.ts sdk/src/__tests__/run-cancellation.test.ts
  • cd sdk && bun run typecheck
  • cd sdk && bun run build

Note: this public snapshot does not include the tracked cloud web route/component code for the Stop button itself; this PR provides the production SDK primitive that the cloud host can wire to its stop endpoint/UI without bypassing existing runtime cancellation semantics.

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

Labels

bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants