Skip to content

MCP server connection lost after context compaction — tools unavailable until new session #23556

@ramsyman

Description

@ramsyman

Description

After context compaction occurs, MCP server tools become completely unavailable for the rest of the session. The only workaround is to start a new session.

This was also reported in NeuralNomadsAI/CodeNomad#344, where the CodeNomad maintainer confirmed this is an OpenCode-level issue.

Steps to Reproduce

  1. Start a session with MCP servers configured
  2. Use MCP tools extensively (large tool outputs, many calls)
  3. Wait for or trigger context compaction (~95% context window)
  4. Attempt to call any MCP tool after compaction

Expected Behavior

MCP server connections are re-established after compaction. Tools remain available throughout the session.

Actual Behavior

All MCP tool calls fail after compaction. The tools are simply gone — no error, no reconnect attempt. A full new session is required to restore MCP functionality.

Impact

Any workflow relying on MCP tools (e.g. database tools, agent registries, custom servers) is silently broken after compaction. This is especially problematic for long-running sessions where compaction is expected.

Environment

  • OpenCode TUI (darwin)
  • MCP servers configured via config
  • Model: claude-sonnet-4-6

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions