fix(catalog): do not carry a retained compact limit onto a corrected window - #2526
Conversation
…window #1905 taught catalog sync never to raise a compaction threshold retained from Codex. The rule is right, but the retained number was trusted even when sync corrected the row's context window in the same pass. An upstream entry arriving as 128k/115_200 whose window is then widened to 272k kept the stale 115_200 — 42% of the real window — so every long turn compacted early. CI caught it on macos and test 1/4 at 121c1fb. A retained threshold only describes the window it arrived with. Capture the incoming window before any override or cap rewrites the row, and trust the retained value only when the window is unchanged; lower-is-policy still holds there, which is what #1905 was protecting.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesContext window override
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏳ DRAFT
What to do
Automatic draft conversion failed (token cannot change draft status). Please convert this pull request to a draft manually. The required |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea9debffe9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const retainedDescribesCurrentContext = incomingContextWindow === undefined | ||
| || incomingContextWindow === effectiveContext; |
There was a problem hiding this comment.
Reject retained limits when the source window is absent
When a persisted or upstream native row has auto_compact_token_limit but a missing or nonnumeric context_window, this condition treats the retained threshold as describing the newly derived window. For example, a partial gpt-5.5 row retaining 115200 gets its window corrected to 272k but still compacts at 42%, reproducing the early-compaction failure this change addresses. Treat an absent incoming window as a mismatch and retain the threshold only when a defined incoming window equals effectiveContext.
Useful? React with 👍 / 👎.
Summary
Post-merge fix for a regression #1905 introduced. CI caught it on
devat121c1fbe2—Codex catalog sync hardening > account rows reconcile idempotentlyfailed on bothmacosandtest 1/4, and it reproduces locally, so it is not a flake.#1905 added the rule that catalog sync must never raise a compaction threshold retained from Codex. That rule is right, but the retained number was trusted unconditionally — including when sync corrects the row's context window in the same pass.
The fixture is exactly that case: an upstream entry arrives with
context_window: 128_000andauto_compact_token_limit: 115_200, and the native override widens the window to272_000. The retained 115200 then pinned a 272k model to 42% of its real window, silently compacting every long turn early. Expected 244800, got 115200.A retained threshold only describes the window it arrived with. This captures the incoming window before any override or cap rewrites the row, and trusts the retained value only when the window is unchanged. Lower-is-policy still holds in that case, which is what #1905 was protecting.
Verification
The failing test passes without being modified — the fixture already encoded the correct expectation.
Checklist
d659c542f~1, fails after)bun x tsc --noEmitcleanSummary by CodeRabbit