Skip to content

[Bug]: opencode provider fails at startSession — opencode.mcp.add returns 500 UnknownError #10485

Description

@Sunsilkk

[Bug]: opencode provider fails at startSession — opencode.mcp.add returns 500 UnknownError

Before submitting

Area

apps/server (opencode provider adapter)

Steps to reproduce

  1. T3 service running on Linux (Orange Pi 5, systemd user service), provider = local OpenCode 1.18.29.
  2. ~/.config/opencode/opencode.jsonc has 5 Cloudflare remote MCPs enabled (4 of them in needs_auth, only cloudflare-docs connected).
  3. Open any thread with the OpenCode provider and send a prompt.
  4. Turn fails immediately with the error below.

Expected behavior

Session starts; T3 registers its MCP endpoint on the OpenCode server.

Actual behavior

ProviderAdapterProcessError: Provider adapter process error (opencode) for thread 53e10d8c-c496-448b-8f7d-8b7872317be4: Unexpected server error. Check server logs for details.
...
[cause]: Error: {"body":{"name":"UnknownError","data":{"message":"Unexpected server error. Check server logs for details.","ref":"err_90bd82fd"}},"status":500}

Trace chain (server.trace.ndjson, trace 979074f06a4e769ff881a415b253c991, 2026-09-07T09:00:59Z):
McpSessionRegistry.issue Success → opencode.global.health Success →
verifyOpenCodeServerVersion Success → opencode.mcp.add Failure (500, ref err_90bd82fd) →
startSession Failure → ensureSessionForThread Failure.

Notably the OpenCode server log (~/.local/share/opencode/log/opencode.log) contains
no ERROR line at 09:00:59Z for this request — the 500 is silent server-side
(the only err_90bd82fd matches anywhere are T3's own trace lines).

Side effects of the never-started session:

  • ProviderService.stopSession: Cannot route thread ... because no persisted provider binding exists.
  • ThreadSettlementReactor: settlement skipped for the thread.

Version / Environment

  • t3 v0.0.38 (service), also present on 0.0.39 changelog check: no mcp.add fix listed
  • opencode 1.18.29 (/home/sunsilk/.opencode/bin/opencode, satisfies >=1.14.19)
  • Linux ARM64 (Orange Pi 5 Max), Node v26.5.0, systemd user service
  • Model in other sessions: opencode / muse-spark-1.3-contributor-free
    (free-tier rate_limit_exceeded also observed same day in unrelated sessions)

Logs

Attached / available on request:

  • trace-thread-53e10d8c.jsonl — all T3 trace spans mentioning the thread (73 lines)
  • trace-turn-failure.jsonl — the 9-span failure chain for the turn
  • opencode-log-0900-UTC.txt — OpenCode server log slice around the failure
  • opencode.jsonc — MCP config (5 Cloudflare remote MCPs)
  • Full stacks redacted to the two at frames above; complete traces in the files.

Root cause (confirmed 2026-09-07, opencode 1.18.29 source + local DB)

Project.migrateProjectId (packages/opencode/src/project/project.ts) runs
UPDATE workspace SET project_id=..., but the local
~/.local/share/opencode/opencode.db still has the ancient
workspace(id, provider, binding, created_at, last_used_at) shape — no
project_id column — even though migration 20260808023530_workspace_domain
is recorded as applied. Every Project.fromDirectory(/home/sunsilk/infra)
therefore throws SQLiteError: no such column: project_id
(opencode.log refs err_1cc751ba, err_48f24f83, err_db9fd44c,
err_cfd939de), and T3's opencode.mcp.add surfaces it as 500
UnknownError (err_90bd82fd, then err_e76414f8 on t3 0.0.39).
Likely trigger: git remote add origin in ~/infra changed the computed
project ID, activating the previous → new migration path.
Verified fixed locally by ALTER TABLE workspace ADD COLUMN project_id TEXT
(backup: opencode.db.bak in this folder) + POST /session for
/home/sunsilk/infra returning a live session. Upstream issue belongs to
sst/opencode (migration recorded-but-not-applied / missing-column guard),
with a T3-side hardening ask below.

Suspected cause / questions

  1. Does T3's mcp.add payload conflict... → answered: no, it's the workspace schema mismatch (above).
  2. Should a failing T3 MCP registration fail the whole startSession, or degrade (session without T3 tools) with a warning?
  3. Should a failing T3 MCP registration fail the whole startSession, or degrade (session without T3 tools) with a warning?
  4. OpenCode returns UnknownError 500 with a ref but logs nothing — may need an upstream sst/opencode report with the ref.

Workaround tried

Restarting the T3 service; error persists per-thread on new turns.

Activity

  1. thedamod commented on Sep 11, 2026

    @thedamod

    Confirmed duplicate on a separate installation.

    Environment: T3 Code 0.0.41-nightly.20260911.1520; OpenCode 1.18.30; Linux x64 on WSL2; local T3 web server.

    Evidence: the T3 trace shows opencode.global.health and version verification succeeding, then opencode.mcp.add failing with HTTP 500 / UnknownError (reference err_ff65d701). The OpenCode log identifies the underlying failure as SQLiteError: no such column: project_id while initializing the workspace.

    Recovery performed: made a consistent backup of the OpenCode database and added the missing nullable workspace.project_id column. The schema now contains project_id. This matches the root cause and successful workaround documented in this issue.

    Generated by GPT-5 Codex via T3 Code triage.

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