Repository navigation
fix: keep configured model rows unchanged when you sign in to a provider again - #201742
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: needs maintainer review before merge. What this changesThis PR compares model rows directly when computing sign-in configuration changes, preserving unchanged null-valued settings. Example: Run openclaw models auth login --provider openai --method oauth with an existing model row containing thinkingLevelMap.off: null.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open for merge: this PR fixes a current configuration-preservation bug with a minimal owner-level change, and no actionable defects remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherProvider sign-in merges its result into a normalized configuration snapshot, computes a delta, and replays that delta against current authored settings after conflict checks. flowchart LR
A[Provider sign-in result] --> B[Normalize and merge auth changes]
C[Original configuration snapshot] --> B
B --> D[Compute configuration delta]
C --> D
D --> E[Check current settings for conflicts]
E --> F[Write authored configuration]
Technical reviewBest possible solution: Merge the direct row comparison and focused regression through the existing configuration delta owner. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically generates deletion deltas for unchanged null-valued model metadata; supplied built CLI/Gateway traces reproduce the failure on the pinned base and demonstrate preservation on this head. Is this the best way to solve the issue? Direct snapshot comparison fixes the producer without changing merge-patch deletion semantics, duplicating ownership, or bypassing concurrent-setting checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a8fb9e5670bf. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -4, Tests +14. Total +10 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 21, 2026, 8:45 AM ET / 13:45 UTC (Revision 3). |
|
Observed proof for #201558 on head dcad959 (base 072117b). Real built CLI + Gateway (dist), isolated state, loopback OAuth fixture (no real account), real |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Upgrade proof for #201558: released v2026.11.6 state, then this PR's head dcad959 on the same state. Real built CLI and Gateway (dist), isolated state, loopback OAuth and ChatGPT backend fixture (fixture JWT, no real account), managed Codex pointed at the fixture. No doctor command was run. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged in 83feebf. Thanks @MertBasar0 for the fix and @Caitoz for the precise report in #201558. Signing in to a provider again no longer rewrites configured model rows in |
…der again (openclaw#201742) Root cause: `src/config/merge-patch.ts:44` - in ID-keyed array mode, `createMergePatch` applied each complete target row as a merge patch before diffing it. Applying a patch deletes `null` values, so unchanged `thinkingLevelMap.off: null` came out as a deletion delta, and provider sign-in wrote that delta into `openclaw.json`. Fixes openclaw#201558 Thanks @Caitoz for the precise report and leaf diff, and @MertBasar0 for the fix. ## What Problem This Solves Signing in again with `openclaw models auth login --provider openai --method oauth` while the Gateway runs should only save the credential. Instead it rewrote configured OpenAI model rows. Rows without a `thinkingLevelMap` gained `thinkingLevelMap: {}`, which hides the bundled map. Rows with an explicit map lost `off: null`, so "off" showed up again for models that reject it. ## User Impact User impact: a provider re-login no longer touches `models.providers.*.models`. Authored `null` thinking-level entries and absent maps stay exactly as written. Real changes from a login, such as adding a default model entry, are still saved. ## Why This Change Was Made Sign-in computes its config change by diffing the Gateway's runtime view before and after the login. That view fills each row's catalog `thinkingLevelMap` (including `off: null`). For a credential-only login both sides are identical, so the change should be empty. The ID-keyed diff applied the target row as a patch first, which dropped every `null`, so each row reported `thinkingLevelMap: { off: null }`. Applying that to the authored config created `{}` on rows without a map and removed `off: null` from rows with one. The fix diffs the matched row directly (one line, net -4). Nothing else changes for the provider-auth caller, the only one that diffs with ID-keyed arrays. Inside a matched row, a key the target removed now shows up as a deletion, the same as at every other level. ## Evidence Real built CLI and Gateway with isolated state, a loopback OAuth fixture (no real account) and the issue's config shape. The test runs the real `models auth login --provider openai --method oauth` and pastes the redirect URL at the CLI prompt. Full observed output: openclaw#201742 (comment) - Base `92fb63c54e31`: the login succeeds. Then `openclaw.json` gains `"thinkingLevelMap": {}` on `gpt-6-astra` and `gpt-6.1-sol` and loses `"off": null` on both catalog-missing rows. The Gateway logs `config change detected; evaluating reload (models.providers.openai.models, meta)`. - This PR: the same login succeeds and `openclaw.json` stays byte-identical (models section diff empty). - Controls on this PR: a fresh login with no model rows leaves `openclaw.json` byte-identical. An offline login still writes its real `agents.defaults.models` addition while the model rows stay byte-identical (base corrupts the rows on this path too). - Upgrade from released v2026.11.6: the profile and config written by 11.6 load on this PR (config valid, profile listed). The online re-login keeps `openclaw.json` byte-identical (models and agents match what 11.6 left), and a turn with the saved credential succeeds on the fixture backend. Output: openclaw#201742 (comment) - Regression: `src/config/merge-patch.test.ts` fails on base (`thinkingLevelMap: { off: null }` emitted, removed key not emitted) and passes here. Merge danger: two-way door. It changes only how config deltas are computed, and a revert restores the old diff. Blast radius: provider sign-in config writes, the only caller of ID-keyed `createMergePatch`. Co-authored-by: Ayaan Zaidi <[email protected]>
…der again (#201742) Root cause: `src/config/merge-patch.ts:44` - in ID-keyed array mode, `createMergePatch` applied each complete target row as a merge patch before diffing it. Applying a patch deletes `null` values, so unchanged `thinkingLevelMap.off: null` came out as a deletion delta, and provider sign-in wrote that delta into `openclaw.json`. Fixes #201558 Thanks @Caitoz for the precise report and leaf diff, and @MertBasar0 for the fix. ## What Problem This Solves Signing in again with `openclaw models auth login --provider openai --method oauth` while the Gateway runs should only save the credential. Instead it rewrote configured OpenAI model rows. Rows without a `thinkingLevelMap` gained `thinkingLevelMap: {}`, which hides the bundled map. Rows with an explicit map lost `off: null`, so "off" showed up again for models that reject it. ## User Impact User impact: a provider re-login no longer touches `models.providers.*.models`. Authored `null` thinking-level entries and absent maps stay exactly as written. Real changes from a login, such as adding a default model entry, are still saved. ## Why This Change Was Made Sign-in computes its config change by diffing the Gateway's runtime view before and after the login. That view fills each row's catalog `thinkingLevelMap` (including `off: null`). For a credential-only login both sides are identical, so the change should be empty. The ID-keyed diff applied the target row as a patch first, which dropped every `null`, so each row reported `thinkingLevelMap: { off: null }`. Applying that to the authored config created `{}` on rows without a map and removed `off: null` from rows with one. The fix diffs the matched row directly (one line, net -4). Nothing else changes for the provider-auth caller, the only one that diffs with ID-keyed arrays. Inside a matched row, a key the target removed now shows up as a deletion, the same as at every other level. ## Evidence Real built CLI and Gateway with isolated state, a loopback OAuth fixture (no real account) and the issue's config shape. The test runs the real `models auth login --provider openai --method oauth` and pastes the redirect URL at the CLI prompt. Full observed output: #201742 (comment) - Base `072117b196ae`: the login succeeds. Then `openclaw.json` gains `"thinkingLevelMap": {}` on `gpt-6-astra` and `gpt-6.1-sol` and loses `"off": null` on both catalog-missing rows. The Gateway logs `config change detected; evaluating reload (models.providers.openai.models, meta)`. - This PR: the same login succeeds and `openclaw.json` stays byte-identical (models section diff empty). - Controls on this PR: a fresh login with no model rows leaves `openclaw.json` byte-identical. An offline login still writes its real `agents.defaults.models` addition while the model rows stay byte-identical (base corrupts the rows on this path too). - Upgrade from released v2026.11.6: the profile and config written by 11.6 load on this PR (config valid, profile listed). The online re-login keeps `openclaw.json` byte-identical (models and agents match what 11.6 left), and a turn with the saved credential succeeds on the fixture backend. Output: #201742 (comment) - Regression: `src/config/merge-patch.test.ts` fails on base (`thinkingLevelMap: { off: null }` emitted, removed key not emitted) and passes here. Merge danger: two-way door. It changes only how config deltas are computed, and a revert restores the old diff. Blast radius: provider sign-in config writes, the only caller of ID-keyed `createMergePatch`. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 83feebf) Companion disposition: createProviderAuthConfigPatch is the existing ID-keyed diff caller; applyMergePatch and prototype guards are unaffected and present-equivalent. No later same-path or PR follow-ups. Co-authored-by: RomneyDa <[email protected]>
…der again (#201742) Baseline adaptation: Apply the matched-row diff directly with the existing provider-auth config owner; no merge application change. (cherry picked from commit 83feebf) Co-authored-by: RomneyDa <[email protected]>
Root cause:
src/config/merge-patch.ts:44- in ID-keyed array mode,createMergePatchapplied each complete target row as a merge patch before diffing it. Applying a patch deletesnullvalues, so unchangedthinkingLevelMap.off: nullcame out as a deletion delta, and provider sign-in wrote that delta intoopenclaw.json.Fixes #201558
Thanks @Caitoz for the precise report and leaf diff, and @MertBasar0 for the fix.
What Problem This Solves
Signing in again with
openclaw models auth login --provider openai --method oauthwhile the Gateway runs should only save the credential. Instead it rewrote configured OpenAI model rows. Rows without athinkingLevelMapgainedthinkingLevelMap: {}, which hides the bundled map. Rows with an explicit map lostoff: null, so "off" showed up again for models that reject it.User Impact
User impact: a provider re-login no longer touches
models.providers.*.models. Authorednullthinking-level entries and absent maps stay exactly as written. Real changes from a login, such as adding a default model entry, are still saved.Why This Change Was Made
Sign-in computes its config change by diffing the Gateway's runtime view before and after the login. That view fills each row's catalog
thinkingLevelMap(includingoff: null). For a credential-only login both sides are identical, so the change should be empty. The ID-keyed diff applied the target row as a patch first, which dropped everynull, so each row reportedthinkingLevelMap: { off: null }. Applying that to the authored config created{}on rows without a map and removedoff: nullfrom rows with one. The fix diffs the matched row directly (one line, net -4). Nothing else changes for the provider-auth caller, the only one that diffs with ID-keyed arrays. Inside a matched row, a key the target removed now shows up as a deletion, the same as at every other level.Evidence
Real built CLI and Gateway with isolated state, a loopback OAuth fixture (no real account) and the issue's config shape. The test runs the real
models auth login --provider openai --method oauthand pastes the redirect URL at the CLI prompt. Full observed output: #201742 (comment)072117b196ae: the login succeeds. Thenopenclaw.jsongains"thinkingLevelMap": {}ongpt-6-astraandgpt-6.1-soland loses"off": nullon both catalog-missing rows. The Gateway logsconfig change detected; evaluating reload (models.providers.openai.models, meta).openclaw.jsonstays byte-identical (models section diff empty).openclaw.jsonbyte-identical. An offline login still writes its realagents.defaults.modelsaddition while the model rows stay byte-identical (base corrupts the rows on this path too).openclaw.jsonbyte-identical (models and agents match what 11.6 left), and a turn with the saved credential succeeds on the fixture backend. Output: fix: keep configured model rows unchanged when you sign in to a provider again #201742 (comment)src/config/merge-patch.test.tsfails on base (thinkingLevelMap: { off: null }emitted, removed key not emitted) and passes here.Merge danger: two-way door. It changes only how config deltas are computed, and a revert restores the old diff. Blast radius: provider sign-in config writes, the only caller of ID-keyed
createMergePatch.