Skip to content

fix: preserve thinking choices across models and runtimes - #150106

Merged
steipete merged 3 commits into
mainfrom
codex/thinking-models-audit-20260916
Sep 16, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/thinking-models-audit-20260916

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Thinking settings could be rejected, silently changed, or serialized incorrectly when selecting another model/runtime, inheriting agent defaults, or using standalone completions. This aligns validation, controls, defaults, and requests with the capabilities of the selected route.

Why This Change Was Made

Thinking policy was duplicated across catalog projections, default resolution, provider wrappers, and transports. Shared request resolution now preserves logical Off, native none, omission, binary controls, mandatory reasoning, provider-native labels, and explicit capability exclusions. Per-agent and per-model precedence is shared by status, chat, commands, and spawned runs. Scoped runtime refresh replaces only the selected model row, preserving other providers’ prepared capabilities for later switches.

Standalone completions apply provider wire policy with the existing once-per-prepared-model wrapper lifetime; returned streams read each call’s thinking choice. Kimi resolves thinking before serialization so payload and replay agree, including empty signatures. Baseten resolves its opt-in default before serialization so disabled thinking cannot be paired with enabled effort. Managed Responses preserves proxy defaults on omission while accepting explicitly supported none; native OpenAI and Copilot retain their existing defaults. The direct SDK’s distinct omission contract is unchanged.

OpenRouter preserves mandatory reasoning when no scalar selector exists. Its derived capability cache refreshes from v3 to v4; config and sessions need no migration. If the first refresh fails, metadata remains temporarily unknown and the existing cold-cache behavior applies. The same request does not retry; a later refresh recovers and persists v4. This is a deliberate derived-cache tradeoff, covered by a 503 → later success → fresh-module durable readback regression.

Duplicate maps, wrappers, default-resolution paths, declarations, and test setup are removed. Production decreases by 488 lines including manifest metadata, or 523 code/type lines excluding metadata. Tests/support grow by 2,004 lines. No configuration, protocol, dependency, or SQLite schema-version changes.

Evidence

Pre-fix reproductions cover default precedence, exact-runtime capabilities, scalar/binary mapping, wrapper lifetime, stale OpenRouter cache reuse, provider omission/replay, and cross-provider catalog retention. Selected owner and sibling suites pass, including the 669-case post-rebase set, 1,396-case cleanup set, 199-case CI repair set, 350-case wrapper/provider set, and final 269-case correction set. Independent review is clean through P2. Canonical selected type, lint, architecture, dead-export, and ratchet checks pass; this is component proof, not a claim that one monolithic changed-check invocation passed.

Authenticated live proof covers OpenAI tools through direct and managed transports, Anthropic thinking signatures, Gemini text/realtime, Kimi K3 Off/Max and tool-result replay, Mistral, Baseten, and OpenRouter. Final reused-model checks include six Baseten GLM-5.2 calls (Off → Max → omitted on each transport), four OpenRouter missing-selector/mandatory cases, and four xAI Grok 4.3 calls (omitted → Off → native none → High), all with HTTP 200 and expected outputs/wire controls. Kimi’s native-Max replay check used an opaque tool-provided token to prove actual tool use and exact replay.

The complete build passed on fed27afbdaf366d8296d45ffae7fee931098029e in 9m35s. On that build, isolated agent exec returned the exact requested output through OpenCode Kimi K3 at Max and Kimi K3 at Off (HTTP 200). Invalid thinking and missing credentials returned explicit, actionable errors. Exact-head CI run 35127601508 and required openclaw/ci-gate passed. GitHub initially retained the previous PR head after accepting the branch push; closing/reopening this same PR recovered the projection before this final run.

A real isolated Gateway/browser verified per-agent defaults, explicit High surviving reload, and /think default restoring the inherited value. The inspected before/after images were shown in the originating chat and render in this PR.

Review follow-through and limitations

ClawSweeper revision 5 reviewed the final head with no actionable findings. Maintainer disposition of its remaining checklist: retain the documented, recovery-tested derived-cache refresh tradeoff; confirm existing config/session formats and wrapper contracts remain unchanged; and treat the data-model flag on src/commands/agent-command-attempt.test-mocks.ts as test scaffolding, with no production storage/schema change. The complete 196-file diff was reviewed.

The ClawSweeper wrapper-lifetime concern is resolved without changing the shipped hook contract. Stateful third-party wrappers survive repeated calls and ambient registry replacement. The cache recovery concern has the failure/recovery/persistence proof above. Final build/CLI results and screenshot delivery address its remaining Rank-up move.

Authenticated Azure, Anthropic Vertex, Amazon Bedrock, ChatGPT subscription, and local llama.cpp inference are not claimed; these routes have source/dependency or request-boundary coverage, and no configured llama.cpp endpoint was running. A separate live Telegram round trip is skipped: the Telegram adapter is unchanged, and common command/status behavior is covered by native-command tests and the real Gateway/UI flow. No live Telegram proof is claimed.

Merged as f024e6786025e99fd01360542e2c33d8be580e08. Catalog publish run 35131446516 passed; the hosted catalog reports that exact source commit, and all two Kimi and five Baseten rows match the landed manifests, including preserved codeMode metadata.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

Consolidate thinking defaults, runtime capability selection, and request intent.
Keep native none distinct from logical off, honor declared effort restrictions,
and share provider wire policy with standalone completions.

Preserve mandatory OpenRouter reasoning without an effort selector, refresh
incomplete cached capabilities, and retain default-on reasoning replay.
Remove duplicate policy and wrappers while keeping existing configuration.
@steipete
steipete merged commit f024e67 into main Sep 16, 2026
197 of 199 checks passed
@steipete
steipete deleted the codex/thinking-models-audit-20260916 branch September 16, 2026 17:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…50106)

* fix: preserve thinking choices across models and runtimes

Consolidate thinking defaults, runtime capability selection, and request intent.
Keep native none distinct from logical off, honor declared effort restrictions,
and share provider wire policy with standalone completions.

Preserve mandatory OpenRouter reasoning without an effort selector, refresh
incomplete cached capabilities, and retain default-on reasoning replay.
Remove duplicate policy and wrappers while keeping existing configuration.

* fix: preserve prepared thinking state and defaults

Keep standalone wrappers alive across calls and resolve provider thinking before serialization. Preserve trusted runtime alias context, align transport fixtures with verified provider contracts, and consolidate duplicate test setup.

* fix: preserve omitted reasoning and scoped model capabilities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: amazon-bedrock extensions: anthropic-vertex extensions: baseten Extension: baseten extensions: codex extensions: deepseek extensions: google extensions: kimi-coding extensions: llama-cpp extensions: lmstudio extensions: microsoft-foundry extensions: mistral extensions: ollama extensions: openai extensions: opencode-go extensions: openrouter extensions: qwen extensions: vllm extensions: xai extensions: xiaomi extensions: zai gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: file-transfer proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant