Repository navigation
fix: preserve thinking preferences when switching models - #169435
Conversation
Keep requested session thinking levels across model and runtime selection. Clamp each run at the existing execution owner and report the effective level without replacing the saved preference. Related: #87925.
|
🦞👀 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 changesPreserves saved thinking preferences across model switches while clamping execution and showing the effective level. Example: Save high thinking on ollama/qwen3:8b, switch to ollama/llama3.2:latest, then switch back.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes preference loss still present on main. No actionable code defects remain; required CI is failed, with two test failures still unattributed. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway patches and chat model selectors update session preferences; admission and queued turns carry the request to execution, which resolves supported thinking and returns diagnostics to CLI and channel clients. flowchart LR
A[Model selection] --> B[Session preference]
B --> C[Admission and queue]
C --> D[Execution thinking policy]
D --> E[Provider request]
D --> F[Clamp diagnostics]
B --> G[Status presentation]
F --> G
Technical reviewBest possible solution: Retain one saved thinking preference and resolve supported execution levels through the existing thinking-policy owner. Do we have a high-confidence way to reproduce the issue? Current main visibly persists supported replacements, and the linked report demonstrates the switch-away-and-back failure; this read-only review ran no target code. Is this the best way to solve the issue? The patch fixes the persistence owners directly, carries requested intent through admission and queues, and reuses existing execution clamping rather than adding restoration state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 38f5412c097e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -28, Tests +160, Docs +14, Other +37. Total +183 across 44 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 HistoryReview history (5 earlier review cycles)
Reviewed October 12, 2026, 6:40 AM ET / 10:40 UTC (Revision 6). |
Carry requested thinking through admission and use context-window validation to exercise catalog preparation without relying on removed thinking remaps. Preserve authorization and lifecycle assertions.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Keep saved adaptive and xhigh preferences separate from effective clamps, and verify both requested levels return after switching back. Align the existing QA scenario with the behavior in #169435.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Integrate origin/main f13b3cd (533 commits after d220cac). Four production files conflicted: - attempt-auth-selection.ts: take main's async credential store (ensureAuthProfileStoreAsync, openclaw#169111) and keep this branch's import for the CLI auth-forwarding helper. - attempt-execution.ts: runAgentAttempt becomes async as on main (openclaw#169111, openclaw#169449) and keeps its RunAgentAttemptParams type; main's inline parameter type is otherwise unchanged since the previous merge. - sessions-patch.ts: keep the fallback policy patch step ahead of main's narrower explicit-thinkingLevel validation (openclaw#169435). - model-overrides.ts: keep the session fallback policy block and take main's bookkeeping simplification and comment removal (openclaw#169458). docs/.generated/config-baseline.{counts.json,sha256} were regenerated with pnpm config:docs:gen instead of merged by hand: core 2507 -> 2511, the four added entries are this branch's fallbackPriority paths.
…9435) Preserve the requested thinking level in session state across model changes. Clamp only the effective level at run time and report the clamp; switching back restores the requested level. Update selection, directive, session-patch, status and QA contracts without adding another state owner. Fixes openclaw#87925. Thanks @hoobnn for the report and @amittell for the switch-away-and-back reproduction. Proof: 664 focused tests (one existing skip), 93 focused QA follow-up tests, live isolated Gateway/native Ollama high/off/high wire behavior with high retained, and clean independent review. Landed under the maintainer-authorized inherited-failure exception for CI run 38231439814 attempt 3: generated manifest drift and the closed-request archive-authority assertion reproduce on the exact CI base. The large shard rerun passed including incognito. The small shard failed only the inherited assertion, before reaching the later CLI-reset group; earlier paired local evidence remains in the PR. Independent security-fast passed. CI remains failed, not green.
Fixes #87925. Thanks @hoobnn for the report and @amittell for the switch-away-and-back reproduction.
What Problem This Solves
Switching to a model with lower reasoning support permanently replaced the session’s saved thinking preference, so switching back did not restore it.
User Impact
Model and runtime switches now retain the requested thinking level. Each run uses a supported level and reports any clamp;
/statusshows requested and effective levels when they differ. Explicitly selecting an unsupported level still follows the existing validation rules.Why This Change Was Made
Session state owns the user’s preference; the existing execution policy owns the effective level. This removes durable remaps from Gateway patches and both model-directive paths, and preserves intent through admission and queued turns. The optional SDK
thinkingRemapresult type remains deprecated for source compatibility but is no longer emitted. No config or storage schema changes.Evidence
New regressions fail on unchanged main at
213ef3b213854ece209c5ddfdd433afc3f82bc14. The focused suites pass with 664 tests passed and one existing skip. Build, core and core-test typechecks, changed-file lint, required ratchets, config docs, plugin inventory, and remaining changed-file guards pass.Live proof used
pnpm openclaw --profile triage-b gateway call sessions.patchandagentthrough an isolated Gateway to native Ollama 0.40.2. A local forwarding proxy recorded request metadata without changing payloads:thinkqwen3:8bbefore switchinghighhigh"high"llama3.2:latesthighofffalseqwen3:8bafter switching backhighhigh"high"The Llama run printed
Thinking level clamped to off for ollama/llama3.2:latest (requested high; preference retained).It returned a successful response discussing an earlier tool marker instead of the exact requested marker; the same-session continuation then switched back successfully, and Qwen replied “Two plus two is four.” The saved preference remainedhighafter both runs.Inherited local check failure: the broad unused-export scan reports 70 findings; all 70 also occur on the exact untouched main base, which reports 78, with no candidate-only findings. These include existing Gateway exports and UI component exports. No exceptions were added to suppress them. The full build also reports the existing non-fatal chat boot request budget warning (36 versus 35).
Production LOC: +94 / -122 (net -28). Tests and test support: +280 / -120. Docs: +17 / -3. The assertion baseline shrinks by two removed casts. No model-facing prompt templates changed.
Independent Codex autoreview: scoped-clean, no actionable P0–P2 findings on
770a5fbaaaafe6432c81db484e0bb5b7201e6df9. ClawSweeper found no code findings or before-merge items on the initial head; the updated exact-head review is pending.No Telegram Test Server run was performed; the maintainer explicitly overrides that proof-only request, with live Gateway/native-model proof and focused shared-output tests provided.
The first CI run exposed old admission/catalog-wait fixture expectations, now corrected and passing locally under Node/Bun. Three other failure groups were reproduced on the actual CI main base
d290b6e0237d6217a62ba256fb6631f60af5537a:checks-ui-e2e (1/2): dashboard draft retention fails in the original 28-file selection (101 passed/1 failed, 154.72s).check-test-types-core-2: the same four MCP App UI component type errors (13.45s).checks-node-changed-compact-small-3: connection-identity persistence fails in the original eight-file shard (143 passed/1 failed, 235.42s); the isolated case passes, so the failure depends on shard context or load.On current head
770a5fbaaaafe6432c81db484e0bb5b7201e6df9, CI run 38187823686 has only the same connection-identity assertion failure (checks-node-changed-compact-small-22) and its dependentopenclaw/ci-gatefailure. The UI jobs now pass. The connection-identity test and helper are unchanged between the two CI bases; an additional replay on the newer base735a9617390dc59cfc806e031024c363da74837dpassed that case, consistent with the recorded shard/load sensitivity. These are inherited-failure evidence and a passing replay, not a claimed flake repair. ClawSweeper reviewed this exact head with no findings or Before merge items. Previously overwritten preferences cannot be reconstructed; affected users should set their desired level once.Focused test wall times
Each file ran with
node scripts/run-vitest.mjs <file> --maxWorkers=1. Times include runner/import/worker preparation on the shared host. Existing larger suites retain their integration coverage; the new cases do not boot per-test Gateways or add sleeps.src/gateway/server-methods/sessions-patch-model-selection.test.tssrc/model-picker/apply-session-model-selection.test.tssrc/auto-reply/reply/directive-handling.model.test.tssrc/gateway/session-utils-model.thinking-default.test.tssrc/auto-reply/reply/queue/state.test.tssrc/status/status-text.test.tssrc/commands/agent-via-gateway.test.tssrc/agents/agent-command.live-model-switch.test.tssrc/auto-reply/reply/agent-runner-execution-lifecycle.test.tssrc/agents/command/delivery.test.tssrc/auto-reply/reply/get-reply-run-admission.session-file.test.tssrc/gateway/sessions-patch.test.tssrc/auto-reply/reply/directive-handling.mixed-inline.test.tssrc/auto-reply/reply/get-reply-run.media-only.test.ts(node)src/gateway/server-methods/sessions-mutations.owner.test.ts(bun)src/gateway/server-methods/sessions-mutations.catalog-queue.test.ts(bun)Exact-head CI: the remaining failing mixed test job ran 383s; its eight-file Gateway group ran 117.49s (143 passed, one inherited connection-identity assertion failure). The UI E2E jobs passed in 180s and 287s.
QA contract follow-up
The thinking model-switch scenario now preserves
adaptiveandxhighin the savedentry.thinkingLevel, checks the separate effective clamps inresolved.thinkingLeveland/think, and switches back to verify each requested level becomes effective again. Its description now states the preference-preservation contract. A search ofthinkingLevelinqa/anddocs/found no other stale saved-level expectations.Catalog validation also exposed six existing UI
codeRefspointing at.tspaths whose components are.tsx. Those metadata paths are corrected; no UI behavior changed. This follow-up adds 0 production lines and changes QA assets by +57 / -18.Validation: scenario schema loaded and all 57 expressions across five steps compiled; 93 focused tests passed across the Gateway model-selection, directive-handling, QA flow-runner, and QA catalog suites. The initial four-file run took 305.88s, with 92 passing tests and the stale UI-reference failure; after fixing all six paths, the catalog suite passed all eight tests in 12.30s wall time (4.27s Vitest duration). The first catalog rerun exposed the remaining stale paths and took 15.92s; the complete reference inventory was then checked before the final rerun. Required max-lines, line-cap, assertion-safety, database-worker, database-dialect, timeout-race, mock-export, config-doc, and plugin-inventory checks passed, along with formatting and whitespace checks.
The private QA runtime build passed. The isolated
qa suite --provider-mode live-frontier --model openai/gpt-5.5 --scenario thinking-slash-model-remapattempt reached auth preflight but could not run without portable OpenAI/Codex credentials. No new credentials were acquired and no live provider or local-model proof is claimed for this QA-only follow-up; the earlier PR live proof remains documented above.Independent Codex autoreview on
55ab786698f1241bea00dc68835af444fe2811c3: scoped-clean, no actionable P0–P2 findings. ClawSweeper reviewed this exact head with no code findings and explicitly marked the earlier QA finding resolved; its remaining Before merge item requests CI asset-check comparison. Exact-head CI is failed.Exact-head CI attribution
CI run 38231439814 and
openclaw/ci-gatefailed on55ab786698f1241bea00dc68835af444fe2811c3. Its exact main base was4375c939e05cb6493eef30ff4ca65a7448ca62da; the tested merge was7cf6104bac568c53017890a5118b5234ccfb8ca9.Two failures are proven inherited. Two remain unreproduced and unclassified; passing replays are not claimed as repairs.
plugins:assets:buildregenerates the same three reported manifests (clawrouter,workboard,x) on the exact base.pnpm plugins:assets:checkon that base fails with those three paths (4.43s). Both owner commands leave the PR head clean, and its asset check passes. No generated files were hand-edited or added to this PR.src/gateway/local-request-context.session-tools.test.tssrc/gateway/server.sessions.create.incognito.test.tsUnknown agent id "work"in CI.src/auto-reply/reply/session.test.tsEach full-file comparison used
node scripts/run-vitest.mjs <file> --maxWorkers=1in detached exact-ref worktrees with separate temporary and module-cache directories. Group replays used the original CI file selections; Vitest's native sequencer chose their execution order. These local runs used macOS and Node 26.11.1; CI used Linux and Node 24. A Linux Testbox request queued rather than receiving an immediate lease, so it was stopped under the campaign's host limit. No Linux test execution is claimed. The remaining two failures need matching-environment evidence before they can be called inherited or PR-caused.This attribution follow-up changes 0 production lines and 0 test lines. No code or generated-output fix was warranted by the collected evidence, so the pushed head remains unchanged and no additional re-review was requested. No CI jobs were rerun. Independent Codex autoreview remains scoped-clean; ClawSweeper's exact-head review has no code findings and retains its CI-attribution Before merge item. The PR has not been landed.
Authorized landing disposition
The maintainer authorized one rerun of each affected test job, then the native inherited-failure admin exception if only the generated-asset drift and/or archive-authority assertion remained. CI run 38231439814, attempt 3 is complete on the unchanged head. The large test shard passed, including the vanished-session incognito case and its 144-test group. The small shard failed only the same closed-request archive-authority assertion reproduced on the exact CI base. Its sequential runner stopped there before the CLI-reset group; the earlier paired local/group evidence for CLI reset remains documented above, and no new CI pass is claimed for that case.
The remaining failed jobs are
build-artifactsandchecks-node-changed-compact-small-18, plus their dependentopenclaw/ci-gate. Independentsecurity-fastpassed. The native admin submission retains the exact base, tested merge, failed attempt, source identities, and paired evidence; this disposition does not relabel failed CI as green. No source, test, or generated asset changes were made during landing. Reporter and reproduction credit above remain unchanged.