Skip to content

fix(sse): align reactive compaction ceiling to input cap - #16627

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.52from
Junior-HJ:fix/compaction-input-cap
Oct 16, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.52from
Junior-HJ:fix/compaction-input-cap

Conversation

@Junior-HJ

@Junior-HJ Junior-HJ commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ base-red inherited: #15306

Summary

When a model defines a separate maxInputTokens that is smaller than its full contextLength (e.g. codex/gpt-5.6-sol-medium with 372k input cap vs 872k context window), prompts landing in the dead band [maxInputTokens, contextLength) previously bypassed proactive and last-resort compaction because compaction thresholds were computed strictly against contextLimit. The request would subsequently fail at enforceOutputTokenBudget with an HTTP 400 (estimated X input tokens, max input Y).

This aligns both proactive compression threshold and last-resort context compaction to effectiveCompactionCeiling = Math.min(contextLimit, effectiveInputCap), ensuring oversized histories are auto-compacted down to the concrete input limit instead of hard-rejecting.

Validation

  • npm run typecheck:core passed clean
  • check:file-size maintained within budget (-2 lines delta on chatCore.ts)
  • Unit test added in tests/unit/compaction-input-cap-alignment.test.ts verifying that a request exceeding max_input_tokens but within contextLength auto-compacts and succeeds instead of 400

@Junior-HJ
Junior-HJ force-pushed the fix/compaction-input-cap branch from 010dcb0 to 8b2bfbb Compare October 16, 2026 15:50
The input-cap hoist and the later output-budget block both declared
contextWindowChecksDisabled in the same function, so the file failed to parse.
The second call now uses effectiveInputCap.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit f3b68bd into cheaper-inference:release/v3.8.52 Oct 16, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants