Skip to content

MCP tools disappear after context compaction in long sessions (tool manifest drops to 0, server stays connected) #46190

Closed as not planned

Description

@xxxn3m3s1sxxx

MCP tools disappear after context compaction in long opencode sessions

Summary

In long-running opencode sessions, after a context compaction occurs, all
MCP server tools vanish: client-side tool registration drops to zero, the
server stays connected, and only starting a new session restores the tools.

Not model-specific, not server-specific — reproducible with a local MCP
server (stdlib over stdio) and any model.

Environment

  • opencode v1.18.12 (local install)
  • OS: Windows (also reported/observed on other platforms in linked issues)
  • MCP servers: local python -m mempalace.mcp_server (stdio transport,
    started from opencode config)
  • Session: single long-running session with many tool calls → context
    compaction triggers → tools disappear

Reproduction steps

  1. Configure a local stdio MCP server in opencode.json (e.g.
    python -m mempalace.mcp_server).
  2. Start a new opencode session; confirm tools are available
    (opencode mcp list shows the server + tools).
  3. Use the session long enough to trigger context compaction
    (auto-compaction on large context).
  4. Observe after compaction:
    • opencode mcp list still shows the MCP server as connected
      (no reconnect/error state).
    • opencode debug agent build (or the equivalent tool manifest debug)
      shows 0 MCP tools in the agent's tool set.
    • Calling an MCP tool fails with "unknown tool" / tool-not-found.
  5. The only reliable recovery is starting a new session.

Expected behavior

  • Tool registrations from connected MCP servers survive context compaction:
    after compaction, the agent's tool manifest must be rebuilt from the still
    connected MCP server state (re-register tools), OR
  • the client detects the stale/empty registration, tears down and
    transparently reconnects the MCP server, re-listing its tools.

Either way: after compaction, opencode debug agent build must show the MCP
tools again without a manual session restart.

Notes

Activity

  1. github-actions commented on Aug 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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