Skip to content

fix(catalog): honor Manager context window for suffixless custom models (#1594) - #1722

Open
LeoLin990405 wants to merge 1 commit into
BigPizzaV3:mainfrom
LeoLin990405:fix/honor-configured-context-window-1594
Open

fix(catalog): honor Manager context window for suffixless custom models (#1594)#1722
LeoLin990405 wants to merge 1 commit into
BigPizzaV3:mainfrom
LeoLin990405:fix/honor-configured-context-window-1594

Conversation

@LeoLin990405

Copy link
Copy Markdown
Contributor

Root cause

apply_model_catalog_to_config returns before generating a catalog when a custom model has neither a [window] suffix nor bundled metadata — even if the user configured a context window in the Manager. The parse_optional_positive_u64(&profile.context_window, …) that reads the user's value sat after that early return, so it never ran. Codex then falls back to its bundled 272000 default (→ 272000 − 13840 reserved ≈ 258160, the "258K" users report) regardless of the 1M they set.

Repro (from #1594): custom provider on http://127.0.0.1:57321/v1, model deepseek-v4-flash (native 1M), Manager context window = 1,000,000 → Codex CLI shows 258K / 258K for every model.

Fix

Parse the configured window first, then generate the catalog whenever there is anything to customize — a [window] suffix, bundled metadata, or a user-supplied context window. When the user set no window, behavior is unchanged (a plain custom model still gets no generated catalog).

let fallback = parse_optional_positive_u64(&profile.context_window, "上下文大小")?;
if fallback.is_none()
    && !entries.iter().any(|entry| {
        entry.suffix_window.is_some()
            || crate::model_suffix::requires_bundled_metadata_catalog(&entry.slug)
    })
{
    return Ok(config_text.to_string());
}

Verification

New regression test generates_catalog_with_user_context_window_for_suffixless_custom_model (RED before the fix, GREEN after). cargo test -p codex-plus-core --lib202 passed, 0 failed.

Fixes #1594.

apply_model_catalog_to_config returned before generating a catalog when a
custom model had neither a `[window]` suffix nor bundled metadata — even if
the user configured a context window in the Manager. Codex then fell back to
its bundled 272000 default, so the CLI showed ~258K regardless of the 1M the
user set. Generate the catalog (and propagate the window) whenever the user
supplied a context window too. Adds a regression test.

Fixes BigPizzaV3#1594.
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.

[Bug] 上下文窗口被硬编码为258K,忽略配置的1M

1 participant