Skip to content

[Bug]: OpenCode (ACP) provider creates new session instead of resuming after app/system restart #2838

@zucram

Description

@zucram

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Connect to OpenCode as a provider (via ACP)
  2. Have an active conversation with context
  3. Either: restart the computer / quit and reopen T3 Code, or simply leave the thread idle for some time (~30+ minutes)
  4. Send a follow-up message in the same thread

Expected behavior

T3 Code should call resumeSession (ACP protocol) with the previous session ID, restoring conversation context. OpenCode's ACP agent supports resumeSession and will replay the last 20 messages to restore context.

Actual behavior

T3 Code calls newSession instead of resumeSession, creating a fresh session with no context. The AI responds with "I don't have context from a previous conversation." The old session still exists in OpenCode's database (visible in OpenCode's own UI as a separate session).

This happens both after app/system restart and after the session is reaped due to inactivity. In both cases, the next message creates a new ACP session rather than resuming the existing one.

Root cause analysis

T3 Code's session reaping (provider.session.reaped, reason: inactivity_threshold) kills the provider connection after idle time. When the user sends a new message, T3 Code reconnects but calls newSession instead of resumeSession with the previous ACP session ID.

Looking at T3 Code's session docs, resumeCursor is persisted and used for Codex provider sessions. However, for ACP providers (like OpenCode), the session resume path doesn't appear to persist or pass the ACP session ID on reconnect.

OpenCode's ACP agent advertises sessionCapabilities: { resume: {} } in its initialize response and implements resumeSession which loads the session from SQLite and replays messages. T3 Code just needs to:

  1. Persist the ACP session ID (e.g., ses_19567fd2affe3jFlm4rRaKT5AO)
  2. Call resumeSession({ sessionId, cwd }) instead of newSession when reconnecting to an ACP agent after transport disconnect, inactivity reap, or app restart

Impact

Blocks work completely — all conversation context is lost after any interruption.

Version or commit

Latest (v0.0.28)

Environment

macOS, OpenCode provider via ACP

Related issues

Workaround

After context is lost, open the original session directly in OpenCode's own UI (where the full context is preserved) instead of continuing through T3 Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions