fix(doctor): preserve codex context metadata#90507
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. This PR is superseded by a broader, clean, proof-positive migration PR that covers the same context-metadata preservation plus the provider-level budget, scoped model-id, and stale session-state cases this branch does not cover. Canonical path: Close this dirty narrow branch and review or land the broader clean doctor/update migration in #90451 as the canonical fix. So I’m closing this here and keeping the remaining discussion on #90451. Review detailsBest possible solution: Close this dirty narrow branch and review or land the broader clean doctor/update migration in #90451 as the canonical fix. Do we have a high-confidence way to reproduce the issue? Yes, source-level. Current main resolves OpenAI/Codex context config through canonical openai, and Codex source shows the 272000 default that legacy context overrides need to avoid. Is this the best way to solve the issue? No, this branch is not the best landing path. The narrower dirty branch is superseded by a clean canonical PR that handles model-scoped metadata, provider-level budgets, scoped ids, and stale session refs without adding runtime legacy readers. Security review: Security review cleared: The diff changes doctor migration code and tests only; it does not add dependency, workflow, credential, network, package, or code-execution surface. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against ebb9c6a013b5. |
|
Addressed the review finding in What changed:
Verification: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Add braces to a guard clause and use const for a never-reassigned binding in the runtime models migration, and switch the migration tests to optional chaining / explicit casts so they pass both tsgo (no possibly-undefined access) and oxlint (no unnecessary type assertions).
|
@clawsweeper re-review Pushed fixes for the failing gates: braced a guard clause + |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Fixes #90448 — the doctor migration that folds a legacy
openai-codexprovider into the canonicalopenaiprovider dropped the per-model context metadata (contextWindow/contextTokens/maxTokens). This carries that metadata forward.contextWindow/contextTokens/maxTokens(context-only; transport fields likebaseUrl/api/headersstay excluded) when copying legacyopenai-codexmodel rows intoopenai.constfor a never-reassigned binding in the migration, and switch the migration tests to optional chaining / explicit casts so they pass bothtsgo(no possibly-undefined access) andoxlint(no unnecessary type assertions).Real Behavior Proof
Behavior addressed: The
openai-codex → openaidoctor migration carried only id/name into canonicalopenaimodel rows, losing context metadata for existing users with legacyopenai-codexmodel entries (#90448). After this change the migration copies the full context metadata and removes the legacy provider.Real environment tested: OpenClaw source checkout on macOS (arm64), Node v26, pnpm 11.2.2, branch
fastino-90448-codex-context-fallback. Drove the real migration entry (LEGACY_CONFIG_MIGRATIONS_RUNTIME_MODELS→models.providers.openai-codex->models.providers.openai) against a legacy config object — not a mock.Exact steps or command run after this patch:
Evidence after fix: Copied output:
Observed result after fix: The legacy
gpt-5.5row is migrated intoopenaiwith itscontextWindow(200000),contextTokens(200000), andmaxTokens(8192) intact, and the legacyopenai-codexprovider is removed. Previously the context metadata was dropped on this path.What was not tested: A full
openclaw doctor --fixrun over a real on-disk user config was not executed; the migration logic itself is exercised here against the real migration entry on this branch, and the focused suites pass.Regression coverage