Skip to content

[WRONG BRANCH] fix(reasoning): bootstrap metadata during catalog sync - #526

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/analyze-and-fix-reasoning-metadata-snapshot-issue
Draft

luvs01 wants to merge 1 commit into
mainfrom
codex/analyze-and-fix-reasoning-metadata-snapshot-issue

Conversation

@luvs01

@luvs01 luvs01 commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A recent change moved the models.dev metadata refresh behind a successful metadata lookup, which prevented a missing or corrupt snapshot from ever being populated and caused routed requests to forward unsupported reasoning efforts instead of clamping them.
  • The intent is to keep network work off the request path while ensuring an initial snapshot can bootstrap from a safe, explicit sync path rather than a per-request side effect.

Description

  • Add providerUsesReasoningMetadata() to src/providers/reasoning-metadata.ts to detect destinations that can use the models.dev snapshot.
  • Remove the request-path refresh side-effect from configuredReasoningEfforts() in src/reasoning-effort.ts so the lookup no longer conditions the refresh.
  • Add refreshReasoningMetadataForSync() and invoke it from src/codex/sync.ts before catalog gathering so supported routed destinations are bootstrapped during catalog sync.
  • Add a regression test tests/codex-integration/codex-sync-api.test.ts that asserts the reasoning metadata refresh runs prior to catalog refresh, and update structure docs to record the new ownership of the snapshot bootstrap.

Testing

  • Ran the focused integration tests with ./node_modules/bun/bin/bun.exe test tests/codex-integration/reasoning-metadata.test.ts tests/codex-integration/codex-sync-api.test.ts, and both suites passed (33 tests total passed).
  • Typecheck and structure checks were run with ./node_modules/bun/bin/bun.exe run typecheck and ./node_modules/bun/bin/bun.exe run structure:check, both of which completed successfully.
  • Ran git diff --check (no whitespace / check failures) and a repository-wide ./node_modules/bun/bin/bun.exe run test was attempted but produced unrelated failures in other suites (examples: tests/responses/ws-upstream.test.ts, tests/routing/combo-management-api.test.ts, tests/lab/lab-evidence-sanitization.test.ts), while the focused changed-subsystem tests remained green.

Codex Task

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 19ae4b49-1872-4bb2-8f55-1d6522aa7980


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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T01:05:17.325429Z 1090b85 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 1090b85bbf

ℹ️ 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 thread src/codex/sync.ts
applyProxyEnv(config); // `ocx ensure`/`ocx sync` fetch provider models outside the server process
// Bootstrap the optional ladder snapshot before gathering the catalog. Keeping this in the
// sync plane prevents an unrelated models.dev fetch from interleaving with a routed turn.
await refreshReasoningMetadataForSync(config, deps);

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 Refresh metadata before launching catalog prewarm

On ordinary ocx start, src/cli/index.ts launches scheduleCatalogPrewarm() before this await, and that prewarm is explicitly designed to share the same in-flight gatherRoutedModels call with refreshCodexModelCatalog. With Zen plus a slower second provider, Zen can apply configuredReasoningEfforts() before the metadata download completes while the second provider keeps the shared flight alive; after this await, the sync joins that already-partially-derived flight and writes a catalog without the newly bootstrapped ladder. Order the bootstrap before prewarm, or invalidate/restart any in-flight gather after refreshing.

Useful? React with 👍 / 👎.

Comment thread src/codex/sync.ts
Comment on lines +81 to +82
if (Object.values(config.providers).some(providerUsesReasoningMetadata)) {
await deps.refreshReasoningMetadata?.();

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 Exclude disabled providers from metadata bootstrap

When a configuration retains a disabled OpenCode Zen/Go provider but routes only through unrelated providers, this predicate still initiates the models.dev fetch even though catalog gathering explicitly excludes disabled providers. With a missing or stale snapshot and an unavailable models.dev endpoint, an otherwise unrelated startup or explicit sync can therefore wait for the 15-second refresh timeout before proceeding. Filter out provider.disabled === true before testing whether metadata is needed.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 14, 2026
@github-actions github-actions Bot changed the title fix(reasoning): bootstrap metadata during catalog sync [WRONG BRANCH] fix(reasoning): bootstrap metadata during catalog sync Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft September 14, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant