Skip to content

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

Description

@bbartels

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

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions