Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/codex/catalog/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ export function applyNativeOpenAiContextOverride(entry: RawEntry, limits?: Nativ
?? (isNativeOpenAiEntry(entry) ? entry.slug as string : undefined);
if (!nativeSlug) return;
const override = NATIVE_OPENAI_CONTEXT_OVERRIDES[nativeSlug];
// Captured before any override/cap rewrites the row: a retained compaction threshold only
// describes the window it arrived with.
const incomingContextWindow = typeof entry.context_window === "number" ? entry.context_window : undefined;
if (override) {
// Read the effective values through the accessors rather than re-deriving them from the
// static table: this function used to apply only the provider cap, so a per-model window
Expand Down Expand Up @@ -352,7 +355,14 @@ export function applyNativeOpenAiContextOverride(entry: RawEntry, limits?: Nativ
: undefined;
if (effectiveContext !== undefined) {
const derivedAutoCompactTokenLimit = nativeOpenAiAutoCompactTokenLimit(nativeSlug, limits);
const retainedAutoCompactTokenLimit = isNativeOpenAiEntry(entry)
// Only trust a retained threshold that still describes THIS window. When sync corrects the
// window, the old number is an artifact of the old one: a 115_200 limit retained from a
// 128k row would pin a corrected 272k model to 42% of its real window and compact every
// long turn early. Lower-is-policy still holds whenever the window is unchanged.
const retainedDescribesCurrentContext = incomingContextWindow === undefined
|| incomingContextWindow === effectiveContext;
Comment on lines +362 to +363

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

const retainedAutoCompactTokenLimit = retainedDescribesCurrentContext
&& isNativeOpenAiEntry(entry)
&& typeof entry.auto_compact_token_limit === "number"
&& Number.isSafeInteger(entry.auto_compact_token_limit)
&& entry.auto_compact_token_limit > 0
Expand Down
Loading