Skip to content

API: Add abort/cancel turn endpoint #136

Description

@NathanFlurry

Description

The Sandbox Agent API needs an abort/cancel turn endpoint so that clients can stop an in-progress turn without terminating the entire session.

Currently, the only way to stop a running agent is POST /v1/sessions/{sessionId}/terminate, which destroys the session entirely. There's no way to cancel just the current turn and continue the conversation.

Proposed API

Add POST /v1/sessions/{sessionId}/abort that:

  1. Cancels the in-progress turn (stops the LLM request / agent subprocess work)
  2. Keeps the session alive so new messages can be sent
  3. Emits a session.ended event with reason: "terminated" for the current turn, or a new event type like turn.aborted

Agent support

  • OpenCode already has a native session.abort() API that does exactly this
  • Claude Code supports Escape to cancel via stdin
  • Codex — needs investigation
  • Amp — needs investigation

The daemon would need to translate the universal abort into the appropriate agent-specific mechanism.

Related

  • Gigacode ESC cancel: needs to call this endpoint once it exists (see linked gigacode issue)

🤖 Generated with Claude Code

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions