Skip to content

fix(catalog): do not carry a retained compact limit onto a corrected window - #2526

Merged
lidge-jun merged 1 commit into
devfrom
codex/fix-retained-compact-limit-stale-window
Aug 25, 2026
Merged

fix(catalog): do not carry a retained compact limit onto a corrected window#2526
lidge-jun merged 1 commit into
devfrom
codex/fix-retained-compact-limit-stale-window

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Summary

Post-merge fix for a regression #1905 introduced. CI caught it on dev at 121c1fbe2Codex catalog sync hardening > account rows reconcile idempotently failed on both macos and test 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_000 and auto_compact_token_limit: 115_200, and the native override widens the window to 272_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

bun test tests/codex-catalog-sync-hardening.test.ts tests/codex-catalog.test.ts \
         tests/auto-compact-budget.test.ts tests/native-model-toggle.test.ts \
         tests/codex-convergence-account-selectors.test.ts
273 pass, 0 fail

bun x tsc --noEmit   exit 0

The failing test passes without being modified — the fixture already encoded the correct expectation.

Checklist

Summary by CodeRabbit

  • Bug Fixes
    • Fixed automatic compaction limits when a model’s context window changes.
    • Prevented outdated thresholds from restricting the corrected context window.

…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.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 25, 2026 03:48
@lidge-jun
lidge-jun merged commit 64bc085 into dev Aug 25, 2026
6 of 8 checks passed
@lidge-jun
lidge-jun deleted the codex/fix-retained-compact-limit-stale-window branch August 25, 2026 03:48
@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • missing_regression_test — Behavior changed under src/ or gui/src/ without a test change. Add focused coverage or obtain test-exception-approved.

@github-actions github-actions Bot added the bug Something isn't working label Aug 25, 2026
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c9bbb29f-fead-4156-9c43-1aedddbd9050

📥 Commits

Reviewing files that changed from the base of the PR and between 121c1fb and ea9debf.

📒 Files selected for processing (1)
  • src/codex/catalog/parsing.ts

📝 Walkthrough

Walkthrough

applyNativeOpenAiContextOverride now preserves the incoming context window before applying overrides or provider caps. It discards retained auto-compact thresholds when that window differs from the effective context window.

Changes

Context window override

Layer / File(s) Summary
Validate retained auto-compact threshold
src/codex/catalog/parsing.ts
The parser records the incoming context_window before rewriting it. It trusts a retained auto-compact token limit only when the incoming window is absent or matches the effective window.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ingwannu, luvs01, chilung-cgu

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-retained-compact-limit-stale-window

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • hygiene: missing_regression_test.

What to do

  • Fix missing_regression_test — Behavior changed under src/ or gui/src/ without a test change. Add focused coverage or obtain test-exception-approved.

Automatic draft conversion failed (token cannot change draft status). Please convert this pull request to a draft manually. The required enforce-target check will keep failing until every issue above is resolved.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +362 to +363
const retainedDescribesCurrentContext = incomingContextWindow === undefined
|| incomingContextWindow === effectiveContext;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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

Labels

bug Something isn't working intake: hygiene-blocked Deterministic PR hygiene checks failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant