Skip to content

Context compaction drops MCP tool registrations #40901

Closed as not planned
Closed as not planned

Description

@druheendas

Bug Report: MCP tools dropped after context compaction

Bug Description

MCP server tools (e.g., outline_list_collections, outline_list_documents) are available as native tools in fresh sessions but get dropped after context compaction occurs during a long conversation.

Steps to Reproduce

  1. Configure an MCP server (e.g., Outline wiki MCP) in opencode.json
  2. Start a new session and use an MCP tool — works ✅
  3. Have a long conversation that triggers context compaction (the "Your operational mode has changed from plan to build" message)
  4. Try to use the same MCP tool — fails ❌ with "Model tried to call unavailable tool"

Expected Behavior

MCP tool registrations should persist across context compactions. The MCP server connection persists (opencode mcp list still shows it as connected), but the tool bindings are lost.

Actual Behavior

After context compaction:

  • opencode mcp list shows the MCP server is still connected
  • opencode debug agent build shows 0 MCP tools registered
  • Fresh sessions correctly register MCP tools

Evidence

Fresh session test:

opencode run "List all collections from Outline wiki"
> outline_list_collections → ✅ Works

Same session after compaction:

opencode debug agent build
> tools: [...no outline tools...]

Environment

  • OpenCode version: 1.18.10
  • OS: macOS (Darwin 25.5.0 arm64)
  • MCP server: Outline wiki (remote via mcp-remote proxy)

Impact

MCP tools become unusable mid-conversation, forcing users to either:

  1. Start a new session
  2. Use curl to call the MCP server directly (bypassing opencode integration)

Additional Context

The MCP server remains connected throughout the session (opencode mcp list shows it as connected), but the tool registrations are lost during context compaction. This suggests the issue is in how opencode manages tool state during context compression, not in the MCP server connection itself.

Verified with:

  • opencode mcp list → shows server connected
  • opencode debug agent build → shows 0 MCP tools registered
  • Fresh session → MCP tools work correctly

Model Independence Testing

This bug is NOT model-specific. Tested across 7 different models with consistent results:

Model Fresh Session After Context Fill
opencode/mimo-v2.5-free ✅ Works ❌ Dropped
opencode/deepseek-v4-flash-free ✅ Works ❌ Dropped
opencode/laguna-s-2.1-free ✅ Works ⏱️ Timeout (web fetch)
opencode/longcat-2.0-free ✅ Works ❌ Dropped
opencode/nemotron-3-ultra-free ✅ Works ❌ Dropped
opencode/north-mini-code-free ⏱️ Timeout Not tested
opencode/big-pickle ✅ Works Not tested

Conclusion: The bug occurs regardless of which model is being used. This confirms it is a general opencode issue with MCP tool state management during context compaction, not a model-specific problem.

Activity

  1. opencode-agent commented on Aug 6, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. We reviewed this against v1.18.10 and the current dev branch, but the evidence here does not indicate that context compaction is dropping MCP tool registrations.

    The message Your operational mode has changed from plan to build is emitted when the session switches from the plan agent to the build agent; it is not a context-compaction message.

    Also, opencode debug agent build reports the agent’s statically registered tools and their resolved permissions. It does not enumerate the MCP tools dynamically attached to a normal model request, so MCP tools being absent from that command’s output is expected and does not show that their registrations were lost. Normal session steps resolve connected MCP tools separately when constructing the request.

    We’re closing this as not reproduced based on the current evidence. If the failure can be reproduced using an explicit compaction while remaining on the same agent, please open a new report with debug logs showing the MCP listTools result and the subsequent model request. That would let us distinguish an MCP server/proxy failure from tool filtering or request construction.

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