Repository navigation
fix(update): migrate retired Codex routes without losing the subscription billing path - #145305
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 12, 2026, 2:09 AM ET / 06:09 UTC (Revision 13). ClawSweeper reviewWhat this changesThe PR preserves subscription billing during automatic OpenAI account selection and model migrations, honors explicit authentication choices, and completes deferred model retirement after updates. Merge readiness⛔ Blocked before merge - 3 items remain The previous configured-auth blocker is fixed, and no remaining blocking defect was found. Current main and v2026.9.4 still retain the affected routing behavior; the related update PR does not supersede this work. Priority: P1 Review scores
Verification
How this fits togetherOpenAI provider policy supplies available billing routes, and shared authentication preparation selects eligible accounts for chat, heartbeat, subagent, and auxiliary requests. Doctor repairs configured model references and records migration outcomes during updates. flowchart TD
A[Model and account settings] --> B[OpenAI route policy]
C[Eligible credentials] --> D[Shared account selection]
B --> D
D --> E[Compatible agent runtime]
A --> F[Doctor model migration]
F --> G[Saved config and update notices]
G --> A
Before merge
Agent review detailsSecurityNone. PR surfaceSource +759, Tests +1406, Docs +51, Other 0. Total +2216 across 63 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Maintain one shared authentication-precedence contract, preserve explicit account choices, and keep migration notices tied to durable Doctor writes. Do we have a high-confidence way to reproduce the issue? Yes, from source: official Completions configuration with both account types exposes the baseline API-only selection, and the PR records a failing subscription-preservation probe. This review did not execute the reproduction. Is this the best way to solve the issue? Yes. Provider-owned route preference consumed by shared authentication selection is a maintainable repair, and the latest correction preserves explicit provider authentication in both preparation and availability. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d5e652099074. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
2b2076d to
b3700c9
Compare
Preserve default route intent for aliases, bare IDs, and stored-profile bindings. Keep implicit Completions runtime selection independent of billing preference, and retain a plain literal API key behind eligible profiles. Refs #145154 Thanks to @dbraendle for reporting the mixed-credential billing regression.
Resolve provider auth and profile bindings before route filtering. Keep inherited billing intent subordinate to explicit credential order. Refs #145154.
|
Merged via squash.
|
…tion billing path (openclaw#145305) Retired `openai-codex/*` routes migrate to `openai/*` without switching an unpinned heartbeat or subagent from the ChatGPT subscription to the metered API key. Explicit provider auth, provider-bound profiles, and authored auth order keep precedence; the deferred model-retirement Doctor pass completes on the candidate's own receipt. The two optional Plugin SDK fields are additive, with no version bump or new configuration option, stored shape, schema, retention, or recovery change. Validated by failing-first authentication regressions, published-driver deferred-retirement proof, and green exact-head CI. Live inference, Gateway restart, and the optional empty-account updater variant remain unproven. Fixes openclaw#145154 Thanks to @dbraendle for reporting the billing regression.
Complete post-plugin Doctor when updater-owned database writes change a captured generation. Carry settled Doctor postimages through the existing database-write receipt and migration lineage, and observe the updater-owned state database before finalization. Close the retained update-run writer before observing its postimage so the next Doctor can acquire native SQLite exclusion. Preserve refusal for changes to untouched captured databases and the accepted native-close tradeoff for databases the updater writes. Covers plugin changes, deferred model retirement, and deferred plugin migrations. Related: #174599 and #145305. Validated by the real native update with config/auth migrations and completed deferred retirement, cross-process owner regression, and exact-head CI including all three PostgreSQL shards.
…85789) Complete post-plugin Doctor when updater-owned database writes change a captured generation. Carry settled Doctor postimages through the existing database-write receipt and migration lineage, and observe the updater-owned state database before finalization. Close the retained update-run writer before observing its postimage so the next Doctor can acquire native SQLite exclusion. Preserve refusal for changes to untouched captured databases and the accepted native-close tradeoff for databases the updater writes. Covers plugin changes, deferred model retirement, and deferred plugin migrations. Related: openclaw#174599 and openclaw#145305. Validated by the real native update with config/auth migrations and completed deferred retirement, cross-process owner regression, and exact-head CI including all three PostgreSQL shards.
Fixes #145154
Additional instructions
This branch is in openclaw/openclaw; maintainers with repository write access can edit it directly.
What Problem This Solves
Fixes an issue where users upgrading with both ChatGPT OAuth and an OpenAI API key could have heartbeat and subagent traffic silently move onto metered API billing. A custom official Completions adapter already existed in working 7.x subscription configurations; treating that adapter alone as an API billing pin changed shipped behavior. Deferred retirement could also leave a model that had retired on the subscription route, causing credential preparation to fall back to the API key.
Why This Change Was Made
The OpenAI plugin keeps subscription routing eligible for supported models and supplies an authentication preference. Shared selection applies it only to automatic selection with both credential kinds eligible. Explicit consumer pins, provider auth, provider-bound profiles, and authored auth order retain priority. Unpinned auxiliary consumers inherit the primary model's prepared intent as a preference. Runtime compatibility, implicit runtime selection, and explicit Codex runtime pins retain their existing semantics.
Two optional fields extend the existing beta-only Plugin SDK contract:
ProviderResolveModelRoutesContext.routeIntentcarries secret-free prepared consumer intent and its explicit/inherited source;ProviderModelRouteResolution.preferredAuthRequirementcarries the provider-owned preference. Runtime preparation, availability, simple completion, and auxiliary selection consume those facts consistently. These additive changes need no beta-only compatibility shim or removal obligation. They introduce no user option, raw credentials, or hook. Simple completion uses the shared prepared account sequence and preserves same-route refresh fallback.Doctor compares resolved billing routes around model-reference migration and names the consumer, model, profiles, and both billing routes after a successful config write. The existing Doctor result forwards those warnings into the diagnostic log and update ledger. Completed migrations do not repeat the warning. Model retirement preserves an agent's local runtime pin over inherited successor settings.
Package-swap Doctor now records deferred model retirement in the existing update ledger. The candidate completes that work after plugin convergence even when the published parent's
freshDoctorRequiredflag is false because no plugin changed. Candidate resume finishes the missing pass before publishing its result to the old parent; changed plugins keep the parent's existing guaranteed Doctor pass. Doctor marks the receipt complete only after the repaired config is durable. Deferral and completion are separate warning events, so the existing boundedupdate statussummary shows completion after the package warnings. Rehearsal cannot borrow the real Doctor's ledger correlation.Data-model compatibility: readers use existing model selectors/profile suffixes, aliases/runtime policies, auth profile declarations/order, provider auth/key settings, and canonical auth-store profiles. The SDK fields and Doctor completion flag are in-process facts. Writes remain model-reference/allowlist repairs plus existing diagnostic/update-run rows. The retained
finalize:doctor:model-retirementrow uses existingskipped/completedstates; a normal warning row reports its outcome. Database schemas, credential encoding, ledger encoding, retention rules, recovery rules, and protocol versions are unchanged. Older readers already accept these step names/statuses; older plugins may omit the optional SDK fields.Related to #145043 by @fuller-stack-dev, which addresses broader plugin migration ordering and preservation of legacy inputs. This PR owns authentication-route preference and explicit-auth precedence, plus completion of the specifically recorded model-retirement deferral. Their integration overlap is Doctor/update ordering; neither has been shown to supersede the other. No code was ported from #145043.
User Impact
An API key kept for another capability no longer silently takes priority over eligible subscription credentials. Explicit API choices still work, and single-kind authentication retains its selection behavior. Heartbeat profile pins reach admission without changing the normal chat session's selected account. Inheritance handles aliases, bare IDs, profile suffixes, and accounts declared only in the auth store. Subscription billing can use the ChatGPT route through an eligible OpenClaw runtime; choosing subscription credentials does not implicitly install Codex.
Thanks to @dbraendle for reporting the billing impact and configuration shape.
Evidence
2026.7.1-2routing/auth ownersopenai/gpt-5.4-miniselectsopenai:default/ metered Completionsopenai/gpt-5.4-miniselectsopenai:chatgpt-default/ subscription ChatGPT routeopenai/gpt-5.6-luna; required OAuth availability succeedsThe original subscription probe failed before the repair with
AssertionError: migration must preserve subscription billing, actualapi-key, expectedsubscription. It passes on the current source. The three precedence regressions failed on7ef41bf08ee8928ec87812e7af147a91d26b221b: provider auth produced an incompatible-route error; provider-bound API availability was false; API-first auth order selected OAuth. All pass after the corrections.The published-driver cell at
31f683109c6then found the deferred-retirement gap: the update succeeded and recorded billing warnings, but the retainedgpt-5.4-minifailed required OAuth preparation as retired; automatic preparation selected the API profile. A manual second Doctor repaired it, which was correctly not counted as a passing update cell.Failing-first tests for the new repair were captured before implementation on merged baseline
cc5715f781a:After implementation, 128 focused Doctor/update/canary/lease tests and 331 routing/migration tests passed through
node scripts/run-vitest.mjs. After the final review correction, all 76 affected CLI/Doctor tests passed again. A later main merge introduced a required producer assessment; keeping produced and completed plugin results separate fixed the resulting CI type error without a cast or weakened producer contract. The merged head passed 131 focused owner tests, the final six Doctor tests, and the scoped changed-file gate including production/test types, lint, dead exports, and import-cycle guards. Coverage includes the published parent's missing run ID, rehearsal isolation, required OAuth availability after retirement, no-op completion, and refused writes retaining the pending receipt. The human-status regression also failed before the final event-ordering fix (completion was hidden behind the three package warnings), then passed with all 46 focused report/Doctor/completion tests and the scoped changed-file gate. The source subscription-preference probe still exits 0 withopenai:chatgpt-defaultandopenai-chatgpt-responses.node scripts/check-changed.mjspassed format, ratchets, Doctor contracts, all production/test typechecks, all dead-export scans, and core lint. Extension lint stopped at the existing ancestor-install isolation guard (node_modules/punycode); the guard and ancestor installation were not changed. The Linux cell runs clean core and extension lint plus the canonical full package build.pnpm plugin-sdk:surface:checkpassed after merging main, with no cap changes in this PR: public entrypoints 153/153, public exports 4454/4454, callable exports 2632/2632, wildcard reexports 50/50, deprecated exports 1132/1138.Current head:
1d2ba49355e088d9f78beac91bf40af6a8d16657, including mainb9eda7cd386568c677c9fcaf0fb27b33cb5c79f3. The initial deferred-retirement commit was production +105/-3, tests +213/-1, documentation +2/-0. Final PR diff against this merged main: production +988/-229, tests +1601/-195, docs +52/-1, and one exact shrink-only guard-data edit (+1/-1).Published-2026.9.4 → candidate Linux cell passed at the deferred-retirement proof head
5167a545581c74d16253e1f20005504ee0473fe1: Testbox run 34675674426, isolated state, Node 24.19.0. The published npm-installed CLI ranupdate --tag file:<candidate.tgz> --yes --json --no-restart; the canonical candidate build and both Linux lint checks passed. The old parent reportedplugins.changed=false. Both complete synthetic account values and explicit config auth choices were preserved. Candidate Doctor retired heartbeat/subagents toopenai/gpt-5.6-luna; automatic heartbeat, subagents, and required-OAuth preparation selectedopenai:chatgpt-default/openai-chatgpt-responses, while the explicit API control selectedopenai:default/openai-completions.The completed update contains
finalize:doctor:model-retirementandwarning:finalize:doctor:model-retirement, both completed. Humanupdate statusshowsDeferred model retirement repair completed after plugin convergence.The published driver also retained both consumer-specific billing warnings aswarning:openclaw doctorandwarning:openclaw doctor:2. A repeatdoctor --fix --non-interactiveexited 0, emitted zero fresh billing events/panels, and preserved the entire update receipt plus agents/auth config. Historical warnings remain visible in Update history. Task evidence:.local/l103-cell/attempt-7/summary.jsonand its artifacts directory; the owned lease was stopped after collection.Exact-head CI for
1d2ba49355e088d9f78beac91bf40af6a8d16657: passed, run 34677085403. No rerun was needed; the previously reported lint-cap and worker-launch lanes passed. The final environment-precedence delta passednode scripts/check-changed.mjs -- src/agents/model-auth-availability.ts src/agents/runtime-plan/prepare-auth.ts src/agents/runtime-plan/prepare-auth.route-intent.test.ts src/agents/runtime-plan/prepare-auth.test.ts docs/plugins/sdk-provider-plugins/runtime-hooks.md, including typechecks, lint, ratchets, dead exports, and import/storage guards.Review follow-ups
ClawSweeper review
Reviewed head:
1d2ba49355e088d9f78beac91bf40af6a8d16657. The exact-head review reports no actionable code or security findings. The earlier explicitauth,apiKey, provider-bound profile, authoredauth.order, and environment-fallback precedence findings are fixed and covered by the shared cross-path regression table.The maintainer accepts the documented automatic subscription preference; integrations requiring metered API billing retain explicit authentication controls. The two optional Plugin SDK fields are additive and require no version bump. There is no new configuration option or stored config shape, database schema, retention, recovery, or protocol change.
The published-driver qualification is retained for the unchanged deferred-retirement path at
5167a545581c74d16253e1f20005504ee0473fe1; the final auth-only correction has separate failing-first owner coverage and exact-head green CI. Live inference, Gateway restart, and the optional empty-account updater variant are skipped as disclosed proof limits, not claimed as passing. The linked Testbox workflow envelope is cancelled; qualification rests on the preserved cell observations described above, not its workflow conclusion. The data-model follow-up is satisfied by the compatibility statement and published-driver observations above. No new code fixup or re-review request is needed for this disposition.Configured auth with environment fallback: both auth owners now retain an explicit provider
authmode whenOPENAI_API_KEYsupplies fallback material. The new regression failed on5167a545: preparation and availability both choseopenai:chatgpt-default/ subscription despiteauth: "api-key"; both now chooseopenai:default/ API-key. The shared six-row table runs explicit provider auth, provider-bound profile,auth.order, inherited intent, unconfigured environment fallback, and configured auth plus environment fallback through both owners with identical expected outcomes. Two prior OAuth tests were tightened to preserve explicit OAuth or reject incompatible explicit profile order; both also failed before the fix. The four owner suites pass 165 tests, the subscription-default probe still passes, and a fresh P1 autoreview is scoped-clean for this delta.SDK precedence risk: the
routeIntent/preferredAuthRequirementdocumentation now states the ordering across preparation and availability. Required bindings and configured auth remain authoritative; authored auth order ranks eligible profiles; inherited intent/provider preference only breaks remaining ties. Environment credentials do not clear configured auth. The SDK surface check passes with the unchanged counts above.Published-updater qualification: the successful Linux cell, run 34675674426, qualifies the deferred-retirement implementation at
5167a545581c74d16253e1f20005504ee0473fe1. Its exact orchestration wasnode .local/l103-cell/invoke.mjs --run --attempt attempt-7 --id tbx_01m2a1dfrcczpm4dctrv2dtpfk --head 5167a545581c74d16253e1f20005504ee0473fe1; the published 2026.9.4 CLI ranupdate --tag file:<candidate.tgz> --yes --json --no-restart. Withplugins.changed=false, both accounts survived,finalize:doctor:model-retirementcompleted, humanupdate statusdisplayed completion, and heartbeat/subagents selected the subscription profile with the API key present. Repeat Doctor preserved the completed receipt and emitted no fresh billing warning. The new delta changes auth precedence only; this cell has not been rerun for it. The optional no-existing-accounts updater variant remains unrun because the exact compiled artifact and lease are no longer available; the two-profile table is not empty-account proof.Data-model compatibility: see the Data-model compatibility paragraph above and the two optional SDK fields. This follow-up changes only in-process selection conditions, tests, and precedence documentation. It adds no stored shape or schema and no compatibility burden for older readers.
Known limits: the reporter's redacted backups have not arrived, so their precise configuration and release chronology remain unverified. The released routing helper was executed and its auth owner inspected; the whole 7.x updater was not run. Doctor enumerates primary, heartbeat, subagent, and explicitly authored model consumers; other inherited auxiliary capability defaults are not separately enumerated. Proof uses synthetic credentials and does not claim successful live provider inference or Gateway restart.