Skip to content

[FEATURE]:add session/delete method to ACP for programmatic session cleanup #54478

Open

Description

@zhangcongmr

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Description

OpenCode’s ACP protocol already supports session-related methods such as session/new, session/load, session/list, session/fork, session/prompt, and session/cancel. The CLI also supports deleting sessions, for example opencode session delete <id>.

However, ACP currently does not expose a session/delete method. This makes it impossible for IDE clients, editor plugins, or automation tools to delete a session purely through the ACP protocol. Clients that want to clean up sessions must fall back to CLI commands or other APIs, which breaks the consistency of ACP as a unified session management protocol.

Adding session/delete would complete the ACP session lifecycle and allow clients to create, load, list, fork, cancel, and delete sessions through the same interface.

Motivation

  • Make the ACP session lifecycle complete and symmetric.
  • Allow IDE/editor clients to delete sessions without shelling out to the CLI.
  • Improve automation scenarios such as tests, CI workflows, and multi-session orchestration.
  • Keep ACP consistent with existing OpenCode session capabilities.

Proposed API

Request:

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "session/delete",
  "params": {
    "sessionId": "ses_xxx"
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "deleted": true
  }
}

Optional extensions:

  • Support all: true to delete all sessions, similar to opencode session delete --all.
  • Return a clear error if the session does not exist, is locked, or cannot be deleted.
  • If the target session is actively running, either reject the request or automatically cancel it via session/cancel before deletion.

Acceptance Criteria

  • ACP exposes a session/delete method.
  • After deletion, the session no longer appears in session/list.
  • Deleting an active session produces a predictable and documented behavior.
  • Errors are returned for invalid or missing session IDs.
  • Documentation and error codes are updated alongside the implementation.

References

  • ACP already supports session/new, session/load, session/list, session/fork, session/prompt, and session/cancel.
  • The OpenCode CLI supports opencode session delete <id> and opencode session delete --all.
  • ACP currently lacks a matching delete method for programmatic session cleanup.

Activity

  1. opencode-agent commented on Oct 11, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed request!

    Good news: OpenCode v2 (@opencode/cli, 2.x) already supports session/delete over ACP. It has been in every release tag I checked, back to v2.0.7, and initialize advertises it under agentCapabilities.sessionCapabilities.delete. How it works now:

    • Request params: { "sessionId": "ses_..." }.
    • If the session has a turn running, that turn is cancelled first, then the session is deleted. After that it no longer shows up in session/list.
    • The response is an empty object {}, not { "deleted": true }.
    • An invalid or unknown sessionId is treated as a no-op and does not return an error.

    If you're on a 1.x version (opencode-ai), please upgrade to v2 to get this. v1 only receives critical fixes.

    The parts that v2 doesn't have yet are an all: true bulk delete, errors for invalid or missing IDs, and documentation of this behaviour. Maintainers will consider those. Related: #53359 recently changed how ACP handles cancel and delete.

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