Skip to content

Regression in 1.14.48: context compaction breaks sessions with large MCP tool sets #27631

Closed as duplicate

Description

@darkhipo

Description

Starting with v1.14.48, opencode's context compaction behavior regresses for sessions with large MCP tool definitions. Sessions that worked correctly on v1.14.47 become unusable — context usage jumps erratically (3% to 68% in a single turn), compaction fails or produces incorrect results, and the session enters a degraded state where every turn re-sends the full bloated context.

v1.14.47 and earlier handle this correctly: context stays steady at ~61% per turn with auto-compaction working as expected.

Reproduction

Environment:

  • Provider: Z.AI coding plan (GLM-5-Turbo, 200K context)
  • MCP tools: 206 tools x 2 transports (SSE + stdio) = 412 tool definitions (approx 123K tokens overhead per turn)
  • OS: macOS 26.4.1, Apple Silicon (M1 Air 8GB)
  • Install method: Homebrew

Steps to reproduce:

  1. Install opencode v1.14.48 (or v1.14.49 / v1.14.50 — all affected)
  2. Configure MCP servers with a large tool set (~100+ tools)
  3. Start a session with any model on a provider with a moderate context window (200K tokens or less)
  4. Send 2-3 messages and observe context usage

Expected behavior (v1.14.47):

  • First turn: ~123K tokens (61% of 200K) — steady
  • Subsequent turns: ~400 tokens (cache hit) or ~123K (cache miss) — predictable
  • Compaction triggers at the configured threshold and works correctly
  • Context percentage stays stable between turns

Actual behavior (v1.14.48+):

  • First turn: ~3% context usage
  • Second turn: jumps to 68-90%+ context usage
  • Context percentage fluctuates erratically between turns
  • Session degrades progressively, becoming slower and less reliable
  • Eventually becomes unusable without DB intervention

Workaround

Downgrade to v1.14.47:

# Download from GitHub releases
curl -L -o /tmp/opencode-1.14.47.zip \
  https://github.com/anomalyco/opencode/releases/download/v1.14.47/opencode-darwin-arm64.zip
unzip /tmp/opencode-1.14.47.zip -d /tmp/opencode-1.14.47/

# Backup current binary
cp /opt/homebrew/bin/opencode /opt/homebrew/bin/opencode.bak

# Replace
cp /tmp/opencode-1.14.47/opencode /opt/homebrew/bin/opencode

# Prevent brew from overwriting on next upgrade
brew pin opencode

After downgrading:

  • Context stays at steady ~61% per turn
  • Compaction works correctly
  • Session remains stable

Version Information

  • Broken: v1.14.48 (May 11), v1.14.49 (May 13), v1.14.50 (May 14)
  • Working: v1.14.47 (May 11)
  • Both v1.14.47 and v1.14.48 are dated May 11 — the regression was introduced in the same day's release

Additional Data

Token breakdown per turn (measured with reserved=8000, 200K context):

Metric v1.14.47 (working) v1.14.48+ (broken)
Per-turn overhead ~123K tokens (61%) ~123K tokens (61%)
Context stability Steady Erratic (3% to 68% jumps)
Compaction behavior Triggers correctly, reduces context Fails or produces incorrect results

The per-turn token cost is identical between versions. The regression is in how compaction manages the context window, not in the initial token calculation.

Related Issues

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