Skip to content

Desktop migrates shared DB; older CLI on PATH fails opencode run with no such column: replacement_seq (Unexpected server error) #38471

Description

@JustinGastby

Description

OpenCode Desktop and OpenCode CLI share ~/.local/share/opencode/opencode.db. When Desktop (or a newer runtime) applies migration 20260622142730_simplify_session_context_epoch (from PR #33378), it drops session_context_epoch.replacement_seq / revision / agent.

An older CLI still on PATH (here: npm opencode-ai@1.17.3) still calls SessionContextEpoch.requestReplacement during SessionPrompt.createUserMessage. Headless callers such as Multica invoke:

opencode run --format json --dangerously-skip-permissions --dir <workdir> --model <provider/model> "..."

and immediately get:

{"type":"error","error":{"name":"UnknownError","data":{"message":"Unexpected server error. Check server logs for details.","ref":"err_..."}}}

With --print-logs:

SQLiteError: no such column: replacement_seq
  at SessionContextEpoch.requestReplacement
  at SessionPrompt.createUserMessage
  at SessionPrompt.prompt

(then the next missing column after manually adding replacement_seq was session_context_epoch.revision)

Observed split behavior on the same machine

  • OpenCode Desktop UI: can send messages successfully (runtime matches migrated schema)
  • Multica / CLI opencode run: fails with Unexpected server error (old binary + new schema)

DB evidence

  • migration table includes 20260622142730_simplify_session_context_epoch
  • PRAGMA table_info(session_context_epoch) had only: session_id, baseline, snapshot, baseline_seq (no replacement_seq / revision)

This is the same class of failure as “old code meets new schema” described in #33773 / #33898, but the trigger here is Desktop + independently installed older CLI on PATH, not an intentional downgrade. Tools that shell out to opencode (Multica, etc.) hit this easily because Desktop auto-updates the shared DB while npm/nvm CLI stays pinned.

Plugins

oh-my-openagent in ~/.config/opencode/opencode.jsonc (failure also reproduces the same SQLite error path; schema mismatch is the blocker before model I/O)

OpenCode version

  • Desktop: @opencode-aidesktop (sessions logged as version=local / newer schema owner)
  • CLI on PATH used by Multica: 1.17.3 (opencode-ai@1.17.3 via nvm/npm)

Steps to reproduce

  1. Install/use OpenCode Desktop long enough for migration 20260622142730_simplify_session_context_epoch to run on ~/.local/share/opencode/opencode.db
  2. Keep an older CLI on PATH (e.g. npm opencode-ai@1.17.3) that still contains requestReplacement
  3. Confirm Desktop chat can send messages
  4. Run:
    opencode run --print-logs --format json --dangerously-skip-permissions --dir <any-existing-dir> --model <configured-model> "hi"
  5. Observe Unexpected server error / SQLiteError: no such column: replacement_seq

Screenshot and/or share link

N/A — log excerpt above.

Operating System

Windows 10 (win32 10.0.19045)

Terminal

PowerShell / Multica desktop daemon (multica daemon spawning CLI)

Expected

Either:

  1. Clear compatibility error: “database schema is newer than this OpenCode runtime; upgrade CLI to match Desktop”, or
  2. Desktop/CLI refuse to diverge on the shared DB without warning, or
  3. Destructive migrations remain compatible with the supported previous CLI window (expand-contract; see ci(core): reject downgrade-incompatible database migrations #33898)

Workaround

Align CLI version with the runtime that migrated the DB (opencode upgrade to match Desktop), or temporarily re-add dropped columns for the older CLI (fragile).

Related

Metadata

Metadata

Assignees

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