Skip to content

fix(catalog): routed models never inherit the native template's context window (#992) - #1028

Open
lidge-jun wants to merge 1 commit into
devfrom
codex/lane-06-routed-context-window
Open

fix(catalog): routed models never inherit the native template's context window (#992)#1028
lidge-jun wants to merge 1 commit into
devfrom
codex/lane-06-routed-context-window

Conversation

@lidge-jun

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

Copy link
Copy Markdown
Owner

Bug-stack campaign lane (devlog/_plan/260805_bug_stack_campaign/100). Fixes #992.

A routed model is not the native template: when /models omits context metadata, the entry now falls to the existing conservative 128000/128000/115200 triple instead of advertising the template's window. Known live/configured/Jawcode metadata still restores exact values; a provider context cap never invents capacity (pinned by tests).

Summary by CodeRabbit

  • Bug Fixes
    • Routed catalog entries now use conservative context and auto-compaction defaults when explicit context settings are not provided.
    • Provider context limits no longer incorrectly increase the available capacity of routed entries.
    • Explicit routed context settings continue to be preserved and applied correctly.

…xt window (#992)

A routed model is not the native template. When /models omits context
metadata, the entry now falls to the existing conservative 128k/128k/
115.2k triple; known live/configured/Jawcode metadata still restores
exact values, and a provider context cap never invents capacity. Two
tests that pinned inheritance as a feature are updated to the #992
contract.
@github-actions github-actions Bot added the bug Something isn't working label Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Routed catalog entries no longer inherit context metadata from native templates. The sync path clears inherited values before normalization. Tests verify conservative defaults, provider-cap handling, and preservation of explicit routed metadata.

Changes

Routed catalog context handling

Layer / File(s) Summary
Clear inherited metadata and validate routed defaults
src/codex/catalog/sync.ts, tests/codex-catalog.test.ts
Routed entries discard inherited context and auto-compaction limits before normalization. Tests require 128K defaults, confirm oversized provider caps do not add capacity, and preserve explicit routed context metadata with 90% auto-compaction.

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

Possibly related PRs

Suggested reviewers: ingwannu, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the fix: routed models no longer inherit context-window metadata from native templates.
Linked Issues check ✅ Passed The changes in src/codex/catalog/sync.ts and tests/codex-catalog.test.ts address issue #992 by removing inherited metadata and validating conservative defaults and cap behavior.
Out of Scope Changes check ✅ Passed The changes are limited to routed catalog context metadata handling and related regression tests, which matches issue #992 and the stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/lane-06-routed-context-window

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/codex-catalog.test.ts`:
- Around line 2318-2333: Extend both routed-capacity tests around
buildCatalogEntries to assert the complete context contract: context_window,
max_context_window, and auto_compact_token_limit. For the oversized contextCap
case, verify all three values remain capped at the expected routed capacity; for
explicit contextWindow metadata, verify max_context_window matches 256,000 and
auto_compact_token_limit remains floor(256,000 × 0.9), alongside the existing
context_window assertions.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e432b224-91a0-4b80-80c2-0390848724cf

📥 Commits

Reviewing files that changed from the base of the PR and between 2a72aa4 and c3393ba.

📒 Files selected for processing (2)
  • src/codex/catalog/sync.ts
  • tests/codex-catalog.test.ts

Comment on lines +2318 to +2333
test("a provider context cap never invents routed capacity (#992)", () => {
const entries = buildCatalogEntries({ context_window: 372_000 }, [], [
{ provider: "relay", id: "relay-model", contextCap: 950_000 },
]);
const routed = entries.find(e => e.slug === "relay/relay-model");
expect(routed?.context_window).toBe(128_000);
});

test("known routed metadata still restores the exact context window (#992)", () => {
const entries = buildCatalogEntries({ context_window: 372_000 }, [], [
{ provider: "relay", id: "relay-model", contextWindow: 256_000 },
]);
const routed = entries.find(e => e.slug === "relay/relay-model");
expect(routed?.context_window).toBe(256_000);
expect(routed?.auto_compact_token_limit).toBe(Math.floor(256_000 * 0.9));
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Assert the complete routed context contract.

Lines 2318-2324 assert only context_window for an oversized contextCap. A regression can advertise capacity through max_context_window or auto_compact_token_limit and still pass this test.

Lines 2326-2333 also omit max_context_window for explicit contextWindow metadata. Assert the full expected triples in both tests.

Proposed test additions
     expect(routed?.context_window).toBe(128_000);
+    expect(routed?.max_context_window).toBe(128_000);
+    expect(routed?.auto_compact_token_limit).toBe(115_200);
@@
     expect(routed?.context_window).toBe(256_000);
+    expect(routed?.max_context_window).toBe(256_000);
     expect(routed?.auto_compact_token_limit).toBe(Math.floor(256_000 * 0.9));

As per path instructions, “A behavior change in src/ should come with a focused regression test near the existing tests for that subsystem.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test("a provider context cap never invents routed capacity (#992)", () => {
const entries = buildCatalogEntries({ context_window: 372_000 }, [], [
{ provider: "relay", id: "relay-model", contextCap: 950_000 },
]);
const routed = entries.find(e => e.slug === "relay/relay-model");
expect(routed?.context_window).toBe(128_000);
});
test("known routed metadata still restores the exact context window (#992)", () => {
const entries = buildCatalogEntries({ context_window: 372_000 }, [], [
{ provider: "relay", id: "relay-model", contextWindow: 256_000 },
]);
const routed = entries.find(e => e.slug === "relay/relay-model");
expect(routed?.context_window).toBe(256_000);
expect(routed?.auto_compact_token_limit).toBe(Math.floor(256_000 * 0.9));
});
test("a provider context cap never invents routed capacity (`#992`)", () => {
const entries = buildCatalogEntries({ context_window: 372_000 }, [], [
{ provider: "relay", id: "relay-model", contextCap: 950_000 },
]);
const routed = entries.find(e => e.slug === "relay/relay-model");
expect(routed?.context_window).toBe(128_000);
expect(routed?.max_context_window).toBe(128_000);
expect(routed?.auto_compact_token_limit).toBe(115_200);
});
test("known routed metadata still restores the exact context window (`#992`)", () => {
const entries = buildCatalogEntries({ context_window: 372_000 }, [], [
{ provider: "relay", id: "relay-model", contextWindow: 256_000 },
]);
const routed = entries.find(e => e.slug === "relay/relay-model");
expect(routed?.context_window).toBe(256_000);
expect(routed?.max_context_window).toBe(256_000);
expect(routed?.auto_compact_token_limit).toBe(Math.floor(256_000 * 0.9));
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/codex-catalog.test.ts` around lines 2318 - 2333, Extend both
routed-capacity tests around buildCatalogEntries to assert the complete context
contract: context_window, max_context_window, and auto_compact_token_limit. For
the oversized contextCap case, verify all three values remain capped at the
expected routed capacity; for explicit contextWindow metadata, verify
max_context_window matches 256,000 and auto_compact_token_limit remains
floor(256,000 × 0.9), alongside the existing context_window assertions.

Source: Path instructions

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Routed models inherit native template context_window when /models omits context metadata

1 participant