Repository navigation
Open
Description
Description
The V2 docs never specify which model limit drives the automatic-compaction ceiling. In v2.0.22 the code computes the ceiling from limit.input || limit.context (packages/core/src/session/compaction.ts, calculateCeiling, reserve = max(window * 0.1, 16_000)). For split-window models (catalog input < context), auto-compaction therefore targets the input window, and a user config limit override of only context silently does not change the ceiling — the override must set both fields. This makes the workaround for #44821 undiscoverable from the docs.
Environment
- Docs pages checked (2026-10-03): /v2/docs/compaction, /v2/docs/config, /v2/docs/providers, /v2/docs/models
- Behavior verified against: opencode
v2.0.22source (packages/core/src/session/compaction.ts,packages/core/src/config/plugin/provider.ts) and a runningv2.0.22instance (/api/model) - OS: Windows x64 (docs issue; behavior verified locally on this platform)
Reproduction
- Read /v2/docs/compaction: "When a session approaches the model's context limit..." — no mention of
limit.inputvslimit.context. - Configure a split-window model override raising only
context, e.g.providers.openai.models."gpt-6.1-sol".limit = { "context": 1050000 }while the effective cataloginputis clamped to 272000 by the ChatGPT OAuth transform (see fix(openai): OAuth transform treats Codex product budget as endpoint context limit #44821). - Observe that auto-compaction still fires near the input-based ceiling (
272000 − max(27200, 16000) = 244800), not near the configured context — the context-only override is a silent no-op for compaction.
Expected Behavior
The docs should state:
- Which limit drives the automatic-compaction ceiling (
limit.inputfirst, falling back tolimit.contextin 2.0.22). - The reserve formula, including the undocumented 16,000-token floor (
RESERVE_MIN) below the documented "10% of the limit". - That model
limitconfig is merged per field ({ ...catalog.limit, ...config.limit }), so an override intended to move the compaction ceiling must set bothcontextandinput.
Actual Behavior
/v2/docs/compactionsays "approaches the model's context limit" — ambiguous, and contradicted by:/v2/docs/config, Compaction section: "Automatic compaction uses the selected model's usable input budget" — the only hint about input-vs-context anywhere, and it uses different wording than/compaction.bufferdefault is documented as "10% of the limit" (/compaction) but the effective reserve ismax(10%, 16_000); the/configexample shows"buffer": 20000without noting that it is not the default.
Additional Context
- Source refs (
v2.0.22):calculateCeilinginpackages/core/src/session/compaction.ts; per-field limit merge inpackages/core/src/config/plugin/provider.ts(if (config.limit !== undefined) model.limit = { ...model.limit, ...config.limit }). - Note for versioning: the
devbranch calculation changed to usecontextonly, so the docs should either describe the versioned behavior or the behavior should be unified — today a doc sentence that is correct for one version is wrong for the other. - Practical impact observed in the wild: users hitting fix(openai): OAuth transform treats Codex product budget as endpoint context limit #44821 (1M-context OpenAI models compacting at ~245k) could not discover from the docs that the workaround requires overriding both fields; a context-only override appears to "not work".
- Suggested placement: a short "Ceiling" subsection in
/v2/docs/compaction(which limit + formula + reserve floor + override guidance), plus one sentence in/v2/docs/modelsnear thelimitfield.
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Oct 3, 2026
Thanks for updating the issue. It now includes the required description and reproduction details.
opencodejr commentedon Oct 27, 2026
Thanks for the detailed write-up! To restate the request: the compaction docs should say that the automatic-compaction ceiling comes from
limit.input(falling back tolimit.context), explain the reserve, and note that modellimitoverrides are merged field by field. A config override has to setinputas well, or the ceiling doesn't move.I checked current
devand it still preferslimit.inputoverlimit.context. The default reserve there is 15% of the window, with a 16k minimum for windows of 32k or more. So the input-vs-context behaviour you describe applies to current versions as well as 2.0.22, and the docs page still only says "context limit".There is already an open docs PR for this, #56509, and maintainers will look at it.
Related: