pingdotgg / pingdotgg/t3code

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

Open
#10,485 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
23k
Forks
5.9k
Avg merge
11h 14m
Merged PRs (30d)
357

Description

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

Before submitting

  • I searched existing issues and did not find a duplicate (ProviderAdapterProcessError + opencode hits are #3571 model-id, #2668 codex, #2163 windows PATH, #3094 remote URL — none is mcp.add 500).

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/server at the OpenCode provider adapter and trace startSession through opencode.mcp.add; compare this with the reported OpenCode Project.migrateProjectId path and missing workspace.project_id schema. The issue is done only when the upstream migration problem and the T3-side choice about failing versus degrading MCP registration are resolved and session-start behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
sqlite, typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.