anomalyco / anomalyco/opencode

Compaction request exceeds context window on high-output models (v2)

Open
#42,448 4 comments 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 14, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

A V2 session using a custom OpenAI-compatible model reached about 236k of its 299,964-token context window (79%). Automatic compaction did not run, and /compact failed because the provider reported that the prompt plus requested output exceeded the context limit.

The model advertises a 131,072-token output limit. SessionCompaction.required() caps its reserved output budget at 32,000, but the compaction LLM.request() does not set generation.maxTokens. OpenAI-compatible lowering therefore leaves max_tokens unset, allowing the provider to use 131,072 instead.

Expected: the compaction request should use the same bounded output budget used to calculate the automatic-compaction threshold.

Before /compact, the model also returned finish=stop with no text or tool calls several times, leaving the TUI with no visible response. This may be a separate empty-response issue.

Plugins

No response

OpenCode version

0.0.0-next-17403

Steps to reproduce
  1. Configure a custom OpenAI-compatible model with context limit 299964 and output limit 131072.
  2. Grow a V2 session to approximately 236k tokens, displayed as 79% context usage.
  3. Observe that automatic compaction does not run.
  4. Run /compact.
  5. Observe that the provider rejects the request because the prompt plus requested output exceeds the context window.
Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.