Skip to content

opencode harness: t3-code MCP server intermittently absent from Code Mode execute catalog mid-session #15736

Description

@Sunsilkk

Summary

The t3-code MCP server (t3-code-b4757dec-c97d-45b3-9c6c-194da6d88025, ~72 tools including delegate_task / task_status / orchestrator_capabilities) intermittently disappears from the Code Mode execute tool catalog mid-session when running in T3 Code through the OpenCode harness (opencode-go/muse-spark-1.3-contributor). Calls then fail with Unknown tool, breaking in-flight orchestration with no config change in between.

Environment

  • opencode version: v2.0.22
  • OS: Linux orangepi5-max 6.1.115-vendor-rk35xx aarch64 GNU/Linux
  • Terminal: xterm-256color (TERM_PROGRAM/COLORTERM unset)
  • Shell: /usr/bin/fish
  • Install/channel: latest
  • Active plugins: superpowers@git+https://github.com/obra/superpowers.git
  • Global ~/.config/opencode/opencode.jsonc has "mcp": {}, no local .opencode/ overrides; the t3-code server is injected by the harness.

Reproduction

  1. Run a thread in T3 Code through the OpenCode harness that uses execute + search(...) to discover T3 tools (e.g. delegate_task, task_status, orchestrator_capabilities).
  2. Successfully call tools["t3-code-b4757dec-c97d-45b3-9c6c-194da6d88025"].orchestrator_capabilities() and delegate_task (provider codex, model gpt-6.1-sol) several times across turns.
  3. On a later turn, the "Code Mode tool catalog has changed" system notice arrives and the catalog only lists browser, cloudflare*, opencode — no t3-code-* server.
  4. search({query: "delegate_task"}) returns only unrelated Cloudflare/browser tools; search({query: "orchestrator_capabilities"}) returns 0 items.
  5. A direct call fails: Unknown tool 't3-code-b4757dec-c97d-45b3-9c6c-194da6d88025.task_status'. Did you mean tools.opencode.list_mcp_resources?
  6. Later (after user-side intervention / another catalog notice), the server reappears with 72 tools and calls succeed again — then disappears again.

Expected Behavior

Once attached, the t3-code MCP server should stay present in the execute catalog for the lifetime of the thread, or its removal should come with an explicit reason/actionable error instead of a silent catalog swap.

Actual Behavior

The server flaps in and out of the catalog across turns within a single thread. While absent, delegate_task/task_status are uncallable, so delegated Codex child tasks can neither be spawned nor have their terminal results read (notifications about terminal task state arrive but are unactionable). T3_ACP_MCP_NODE is unset in this environment, so the ACP fallback transport is unavailable.

Additional Context

  • Frequency: intermittent, observed multiple times within one session (2026-10-03/04). Same thread saw: present (72 tools) -> absent -> present after user fixed tooling -> absent again.
  • Possibly related: [Bug]: Codex turn sees partial MCP tool catalog during server startup #13437 (Codex turn sees partial MCP tool catalog during server startup) — but that issue is about first-turn startup grace on the Codex side, whereas this is the OpenCode/Code Mode execute catalog losing an already-working server mid-session.
  • No config, plugin, terminal, or workspace changes between the working and broken turns.
  • Workaround tried: re-establishing tooling user-side temporarily restores the server, but it drops out again. No durable workaround found.

Activity

  1. juliusmarminge commented on Oct 4, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    Triage

    Thanks for the careful report, @Sunsilkk! The notice text and the flapping timeline were really useful for tracing this.

    What I found

    • Not a duplicate of [Bug]: Codex turn sees partial MCP tool catalog during server startup #13437. That one is a Codex first-turn startup race, where optional MCP servers get dropped while they're still starting. Here, the t3-code-<thread> server was already connected and working, then left OpenCode's Code Mode catalog on a later turn.
    • Where the notice comes from. OpenCode emits "The Code Mode tool catalog has changed" itself whenever the visible inventory changes. An empty search result for orchestrator_capabilities means the namespace really was unregistered. browser and opencode are OpenCode's own namespaces, so the execute runtime itself stayed up.
    • Also expected: T3_ACP_MCP_NODE being unset. It only covers the ACP terminal fallback.
    • How T3 registers the server. apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.ts registers it once per directory in prepareTurn. I found two paths that can remove it mid-session.
      1. Event-stream reconnect. A reconnect resets every thread's remembered MCP registration (state.mcp = undefined) without removing the live server. The next turn calls mcp.add again, and OpenCode's replaceServer disposes the existing client before the new one has tools. That drops the namespace until the reconnect finishes. If the add takes longer than the 5 s INVENTORY_TIMEOUT, it logs Could not add T3 Code's MCP server to OpenCode and leaves the registration unset, so the next turn tears the server down again. Repeated cycles would match the present, absent, present flapping you saw.
      2. Transport close. OpenCode clears a server's tools when its transport closes. It only reconnects when a session-expired response comes back, such as the 404 a restarted T3 process returns for an old in-memory session id. After any other close, the namespace stays gone, and T3 won't re-add it because it still thinks the server is registered.
    • Less likely: credential expiry. The token is refreshed on every provider turn.

    Likely fix area

    • Option 1: avoid replacing a live server. After an event-stream reconnect, check what OpenCode actually has registered instead of resetting and calling mcp.add again.

    • Option 2: re-register when the server disappears. Detect that the t3-code-* server is missing, for example by checking the inventory each turn, and register it again rather than trusting the remembered state.

    • Option 3: handle a slow add more gracefully. When the 5 s add timeout hits, avoid tearing the server down again on the following turn.

    • Logs that would tell the paths apart:

      • From T3, around a drop: Lost the OpenCode event stream; reconnecting. or Could not add T3 Code's MCP server to OpenCode.
      • From OpenCode, for the t3-code-* server: mcp session expired, reconnecting or Connection closed.

      If you can share those lines (redacted), please do.

    A maintainer will decide on the fix direction.

  2. added
    bugSomething is broken or behaving incorrectly.
    via-triageFiled through npx t3 triage
    on Oct 4, 2026
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

    bugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions