Skip to content

test(compaction): failing tests for missing headroom when limit.input is set#13034

Merged
rekram1-node merged 1 commit intoanomalyco:fix-compact-bugsfrom
lightsofapollo:test/compaction-overflow-headroom
Feb 10, 2026
Merged

test(compaction): failing tests for missing headroom when limit.input is set#13034
rekram1-node merged 1 commit intoanomalyco:fix-compact-bugsfrom
lightsofapollo:test/compaction-overflow-headroom

Conversation

@lightsofapollo
Copy link
Contributor

@lightsofapollo lightsofapollo commented Feb 10, 2026

Relates to #10634

adds 3 failing tests showing that isOverflow() doesn't reserve any headroom when limit.input is set, unlike the context - output fallback path.

basically if you have a model with limit.input = 200K and you've used 198K tokens, isOverflow says you're fine. next turn overflows.

without limit.input, same scenario correctly triggers compaction because it uses context - output (168K).

the diff between the two paths is exactly 32K — the output budget that's not being subtracted.

was hitting this with claude models in our tui project and traced it to line 37 in compaction.ts. saw #6875 and #12924 are both trying to fix this — these tests should pass once either lands.

related: #10634 #8089 #11086

…nput is set

isOverflow() uses `limit.input` directly without subtracting output
token headroom, unlike the `context - output` fallback path. This means
models with an explicit input limit (e.g. Claude with prompt caching)
don't trigger compaction until the full input budget is consumed,
leaving zero room for the next response.

Three tests added:
- Near-boundary case: 198K/200K used, should compact but doesn't
- Parity test: same tokens correctly trigger compaction without limit.input
- Asymmetry test: identical 200K models diverge by exactly 32K (the missing output headroom)

Related: anomalyco#10634, anomalyco#8089, anomalyco#11086, anomalyco#12621
See also: anomalyco#6875, anomalyco#12924
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Perfect! I found the related PRs. Here are the potential duplicates/related PRs:

Related PRs Found

  1. PR fix(core): ensure compaction is more reliable, add reserve token buffer to ensure that input window has enough room to compact #12924 - fix(core): ensure compaction is more reliable, add reserve token buffer to ensure that context window has enough room to compact

    • This is explicitly mentioned in the PR description as one of the fixes that should make these tests pass
  2. PR feat(compaction): Handle when models have input limit #6875 - feat(compaction): Handle when models have input limit

    • Also explicitly mentioned in the PR description as attempting to fix the same issue

These two PRs are directly addressing the root cause that PR #13034 is testing. The current PR adds failing tests that verify the bug exists, and PRs #6875 and #12924 are the actual fix implementations for the isOverflow() function's handling of limit.input and output budget headroom.

@rekram1-node rekram1-node changed the base branch from dev to fix-compact-bugs February 10, 2026 23:03
@rekram1-node rekram1-node merged commit b8ef47d into anomalyco:fix-compact-bugs Feb 10, 2026
8 of 10 checks passed
@rekram1-node
Copy link
Collaborator

ill just absorb into my branch since im working on this stuff

@lightsofapollo
Copy link
Contributor Author

@rekram1-node Ty!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants