Commit 6952ea7
fix(doctor): preserve explicit non-default agentRuntime pin during legacy model-ref migration
`maybeRepairCodexRoutes` migrates `openai-codex/*` model refs to their
canonical `openai/*` form, then calls `ensureCodexRuntimePolicy` on each
hit so the rewritten ref keeps Codex auth routing. When the user already
had an explicit non-default pin on the legacy form (for example
`models["openai-codex/gpt-5.4"].agentRuntime = { id: "pi" }` as a
deliberate opt-out from the broken native Codex runtime), the previous
sequence silently overwrote it:
1. The `AGENT_MODEL_CONFIG_KEYS` loop rewrote `model.primary`, then
`preserveCodexRuntimePolicyForNewHits` synthesized
`models["openai/gpt-5.4"].agentRuntime = { id: "codex" }` because
that canonical entry did not yet exist.
2. `rewriteModelsMap` then renamed `openai-codex/gpt-5.4` →
`openai/gpt-5.4`. Its spread merge
`{ ...legacyRecord, ...canonicalRecord }` placed the synthesized
`{ id: "codex" }` last, silently dropping the user's `{ id: "pi" }`
pin.
End state: the explicit PI runtime opt-out was gone, gateway fell back
to the native Codex runtime, and per-request token usage grew 3-4x
because the upstream Codex runtime issue still applies.
Fix: in `ensureCodexRuntimePolicy`, skip synthesizing the default
`{ id: "codex" }` pin when the user already has an explicit non-default
pin on a legacy `openai-codex/*` form of the same canonical model ref.
`rewriteModelsMap` then carries the legacy pin forward unmodified via
its existing `canonicalEntry ?? legacyEntry` falsy branch.
This narrow fix matches the existing behavior covered by
`preserves explicit model-scoped runtime pins when repairing legacy
model map keys` (only the models map, no `model.primary` slot to trigger
synthesis) and `overwrites non-concrete model-scoped runtime pins when
preserving Codex route intent` (auto/default pins still get codex
applied). The combined-config path from #84038 was the previously
uncovered regression.
Fixes #84038.
Co-Authored-By: Nex <nex@dbitstec.com>1 parent 4133c58 commit 6952ea7
1 file changed
Lines changed: 24 additions & 0 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1997 | 1997 | | |
1998 | 1998 | | |
1999 | 1999 | | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
2000 | 2021 | | |
2001 | 2022 | | |
2002 | 2023 | | |
| |||
2025 | 2046 | | |
2026 | 2047 | | |
2027 | 2048 | | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
2028 | 2052 | | |
2029 | 2053 | | |
2030 | 2054 | | |
| |||
0 commit comments