GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Direct MCP tools (codemode: false) are nondeterministically missing from the session toolset; opencode run can hang forever after a session error · Issue #56240 · anomalyco/opencode

Direct MCP tools (codemode: false) are nondeterministically missing from the session toolset; opencode run can hang forever after a session error #56240

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
Direct MCP tools (codemode: false) are nondeterministically missing from the session toolset; opencode run can hang forever after a session error#56240
Copy link
Labels
pending closetriaging

Description

@willwolf-cohere
willwolf-cohere
opened on Oct 16, 2026
Issue body actions

Direct MCP tools (codemode: false) are nondeterministically missing from the session toolset; opencode run can hang forever after a session error

Versions

  • @opencode/[email protected] (also reproduced on @opencode/[email protected]) — Linux x64
  • Config decoded in the V2 shape (servers under mcp.servers), codemode: false, oauth: false, no timeout key (a server whose timeout is a V1-style integer is skipped as malformed — noted in passing)

Setup

A minimal streamable-HTTP MCP server (plain http.server, ~60 lines) serving one tool, jam_assessment, over tools/list / tools/call:

{
  "mcp": {
    "servers": {
      "jam": {
        "type": "remote",
        "url": "http://127.0.0.1:39778/mcp",
        "codemode": false,
        "oauth": false
      }
    }
  }
}

Then, repeatedly, with a fresh HOME/data dir each run:

opencode run --format json --model <provider/model> --auto --standalone \
  "Call the jam_assessment tool once with no arguments, then reply done."

Observed

  1. The server's tools are missing from the session's toolset on most runs. The CLI logs mcp connected server=jam tools=1 before the model's request, the model still reports "no jam_assessment tool available" (and with some configs literally answers: "My available tools are: file operations … shell …"), and a direct call is refused client-side with:

    {"error":{"type":"tool.execution","message":"No tool named \"jam_assessment\" is currently available. Please use a tool from the available tool list."}}
    

    The refusal shape flaps across identical configs and fully fresh state directories (same command, same config: run 1 calls the tool, run 2 refuses). Under machine load (several concurrent spawns) the refusal is near-deterministic — dozens of consecutive runs all refuse.

  2. Any tools map in the config makes it worse. With no tools key the tool sometimes registers; with tools: {"jam_assessment": true, …} present the refusal rate goes to ~100% under load. Naming the offered tool true is necessary but not sufficient — a 130-key map that names the tool true still refuses under load.

  3. When the session then dies (the scripted model returns an error for the follow-up request), opencode run does not exit. The log records Failed to drain Session, the stdout stream goes silent, and the process sits indefinitely — the caller sees no exit and burns the whole turn timeout (we run turns with a 2700 s budget; the whole budget is lost). Expected: the process exits non-zero promptly after the session fails.

  4. The CLI's own recovery attempts are visible in the log and the streamed events: after the refused call the CLI re-asks the model repeatedly (step_start events ~10–20 times), injects the error JSON as the tool result, asks again, and eventually surfaces Failed to drain Session. Nothing in that loop can succeed — the toolset snapshot the session was created with is final.

Expected

  • With codemode: false, the server's tools are on the session's native tool list deterministically — the session's toolset either waits for the server's tools/list to land or is derived from it after registration.
  • A session that fails to drain terminates its opencode run process with a non-zero exit promptly.

Why this matters in practice

An operator pinning codemode: false (per the docs) cannot rely on the server's tools being callable: the same spawn succeeds on a quiet machine and fails under load, and the failed turn costs the full timeout instead of a fast failure.

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 16, 2026 – with OpenCode Agent
    Contributor
    More actions

    Thanks for the detailed write-up and the minimal MCP server setup.

    I think this is a duplicate of #51812. On a fresh opencode run --standalone, the session's tool list is built before the MCP server's tools are registered, so a one-shot run can miss them entirely. The comments there also cover what you saw: a server can already show as connected (mcp connected … tools=1) and still be missing from the first turn. In the current code the session only waits for the initial discovery, and later tool updates are applied after a 100 ms debounce. That race fits the flapping between identical runs and the near-certain failure under load.

    The hang after Failed to drain Session is tracked separately in #49740. Drain failures are only logged and never sent to the client as an error, so opencode run gets no signal to exit.

    Possible duplicates and related issues, ordered by likelihood:

    • First prompt after start has no MCP tools: tool list does not wait for pending MCP connections #51812: first prompt has no MCP tools because the tool list doesn't wait for MCP registration; one-shot run --standalone never gets them
    • Session permanently frozen: drain() failures are logged but never surfaced to the client (no session.error event) #49740: Failed to drain Session is only logged, never surfaced, so the session (and run) never finishes
    • ACP: first prompt can miss MCP tools supplied to session/new (2.0.18 / 2.0.22) #53299: the same first-prompt MCP tool race over ACP
    • fix(core): refresh MCP tools before session snapshots #54942: open PR that refreshes MCP tools before the session takes its tool snapshot

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. For example, if the tools config map effect turns out to be a separate issue.

  2. opencode-agent
    added
    pending close
    triaging
    on Oct 16, 2026
  3. PolarTango commented on Oct 17, 2026

    @PolarTango
    PolarTango
    on Oct 17, 2026
    More actions

    Ping @obra @arittr — confirmed on v2.0.31 Linux x64. MCP servers connect successfully logs show tools=26 tools=1 etc, but opencode api get /api/mcp returns tools=0 for all servers. The tools never make it to the model session. This makes all MCP integration useless. Any workaround or ETA for fix?

  4. opencode-agent
    closed this as duplicateon Oct 17, 2026
  5. opencode-agent commented on Oct 17, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 17, 2026 – with OpenCode Agent
    Contributor
    More actions

    We haven't heard back in a day, so I'm closing this as a duplicate of #51812, as mentioned above. Thanks again for the detailed report.

    Follow these for updates:

    • First prompt after start has no MCP tools: tool list does not wait for pending MCP connections #51812: MCP tools (codemode: false) missing from the first turn of a fresh opencode run --standalone. PR fix(core): refresh MCP tools before session snapshots #54942 is related.
    • Session permanently frozen: drain() failures are logged but never surfaced to the client (no session.error event) #49740: opencode run hanging after Failed to drain Session.

    If part of this turns out to be a separate problem, such as the tools config map making refusals more likely, please reply here or open a new issue that links this one.

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

    pending closetriaging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.