Skip to content

V2: auto-resume active sessions after server restart #35646

Description

@opencode-agent

Summary

V2 sessions that were actively executing should automatically continue after the shared server restarts, instead of requiring the user to manually prompt them again or leaving stale in-progress state in the TUI.

Desired Behavior

On server startup:

  1. Identify sessions whose execution was active when the previous process stopped.
  2. Reconcile the interrupted step and any in-flight tool parts to durable terminal state.
  3. Resume the agent loop from persisted session state.
  4. Notify connected clients so the TUI converges without a reload.

The recovery path must not blindly re-execute an in-flight side-effecting tool. A tool whose completion cannot be proven should be recorded as interrupted; the resumed model turn can then inspect state and decide how to continue.

Acceptance Criteria

  • An active V2 session automatically resumes after a normal daemon restart, upgrade restart, or unexpected process exit.
  • Persisted running/pending tool parts are settled before continuation; no stale spinners remain.
  • Recovery does not automatically replay an ambiguous side-effecting tool call.
  • Exactly one process owns the resumed execution, including when multiple clients reconnect concurrently.
  • Connected and later-opening clients converge on the resumed canonical session state.
  • Recovery is idempotent across repeated crashes/restarts.
  • Tests cover restart during model streaming, restart during a read-only tool, restart during a side-effecting tool, and repeated restart while recovering.

Related Work

This issue adds the continuation policy after durable interruption reconciliation; it does not replace those issues.

Source

Metadata

Metadata

Assignees

Labels

2.0coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Fields

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