Skip to content

fix: honor reasoning capabilities on compatible model routes - #182987

Merged
steipete merged 8 commits into
mainfrom
fix/reasoning-effort
Oct 26, 2026
Merged

steipete merged 8 commits into
mainfrom
fix/reasoning-effort

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes configured thinking choices being replaced by catalog guesses and utility/title requests failing when an OpenAI-compatible endpoint rejects an undeclared none effort.

Closes #165119. Closes #177425. Thanks @tre1d and @eulrich101618 for the reports and reproductions.

User Impact

Operator reasoning lists, mappings, and explicit scalar support survive catalog preparation. Off sends a disable value only when the route declares it; unknown disable contracts omit scalar effort and leave the server default in effect. Saved thinking preferences remain intact under the existing runtime clamping policy. No new configuration field is introduced.

Custom Ollama /v1 users can declare none through existing compat metadata for models that support it. Declared binary formats retain their disable field. Explicit opt-outs and configured effort lists stay authoritative.

Why This Change Was Made

The shared request resolver owns scalar off/none mapping across Completions and Responses, replacing the transport-specific off hint. Catalog preparation preserves operator reasoning declarations while leaving unrelated capabilities catalog-owned. Partial maps stay partial; model-level off maps participate in Z.AI declaration detection, and declared binary disable remains available when scalar effort is disallowed. Native model-name disable defaults apply only on known native routes.

A boolean-only scalar opt-in also clears an inherited empty catalog ladder; otherwise the empty ladder still vetoes the operator's setting. Nonempty catalog ladders and explicit configured lists remain intact.

Merged main 4846765d3e20bb194bd17a0a9909e49c2ea69dc6 without rebasing. The only conflict was with #183604's test-fixture simplification. The resolution retains its shared helpers and passes the new compat declarations through them; no competing production owner was retained.

Production: +102/-58 (net +44, including one wrapper-inventory entry). Tests: +187/-29. Docs: +14/-7. The obsolete Completions off policy was removed; remaining growth preserves declared capabilities and distinct wire contracts. The assertion baseline shrinks by one.

Evidence

Current head: 113f6bfe71d459bc806c680e218f7884e76285f6.

  • 265 focused request, native-provider, catalog, and route-compat tests passed (29.79 s); both wrapper-extraction checks passed (11.51 s); 13 prompt-prefix stability tests passed (44.28 s).
  • Core and scoped test types, changed-file lint, formatting, and all seven ratchets passed. The runtime build passed (89.4 s active build; 171.04 s wall including artifact-lock wait), with the installed build identity matching this head.
  • Independent Codex review is scoped-clean with no actionable P0–P2 findings. Its boolean-only opt-in finding was reproduced first: one regression failed and the nonempty-ladder control passed (21.29 s); both now pass in the full catalog suite.
  • Final-head isolated macOS Gateway chat.send recheck on real Ollama qwen3:8b: saved off sent reasoning_effort: "none", produced 0 reasoning characters, and returned 4 in 5.264 s. Saved medium sent "medium", produced 448 reasoning characters, and returned 4 in 1.831 s. Both were HTTP 200, normal stop, no rerouting; the configured default was high and requests carried no thinking override.
  • Earlier baseline regressions failed at the request/catalog boundaries, and the original isolated CLI request reached the rejecting Responses fixture and returned HTTP 400. Previous-head 30807beb8d61b895e6dd0c48357bbe07dfdd61a0 also passed ten live Gateway cases: Ollama qwen3:8b/qwen3.5:4b, LM Studio Gemma, managed llama.cpp using the existing GGUF read-only, binary fixtures, and strict Responses/title fixtures. The model-level Z.AI attribution probe changed from HTTP 400/400 to 200/200 after its repair.

Exact-head CI passed, including openclaw/ci-gate. ClawSweeper reviewed this head with no findings and no before-merge items; proof confidence and patch quality are both 5/6.

Limits: local macOS proof only; no hosted OpenRouter/Muse inference. The full stable-upgrade proof below was run on the pre-merge head; this head reran the affected suites and the live Qwen control. Unknown custom routes still require a verified disable declaration. Ollama was 0.40.10, whose OpenAI adapter is byte-identical to 0.40.8. The mandatory-thinking Qwen3 4B model was not an off control.

Upgrade proof (pre-merge head)

Completed on macOS arm64, from the registry's latest ([email protected], release commit 157d8c2bc3ea2fa183afdc11088e69690bf8e64e) to the then-reviewed head 30807beb8d61b895e6dd0c48357bbe07dfdd61a0. Both packages use version 2026.10.7; installed build metadata verified the commit replacement.

Used an isolated npm prefix, HOME, state, config, workspace, and loopback Gateway port 20020. Three custom Completions routes used the existing real servers: Ollama /v1 with qwen3:8b, LM Studio with google/gemma-4-e4b, and a mapping-only Ollama route. The first two declared compat.supportedReasoningEfforts: ["none", "low", "medium", "high"]; the third declared only compat.reasoningEffortMap: {off:"none", medium:"medium"}. Stable requires an API-key-shaped field, so all routes used synthetic unused placeholders with no real credentials.

Created six sessions on stable with saved off/medium preferences, ran a normal chat.send turn in each, then stopped stable and backed up its databases/config. The configured thinking default was high. After upgrade, the same chat.send requests contained no thinking override, and no session creation or preference patch was performed; this proves restored preferences rather than a default or one-turn override.

Upgrade method: manual package replacement, as authorized for this proof. The repository packer produced the candidate from the prepared head build; its tarball integrity check passed. Installed that tarball over the same prefix, kept the same state, ran doctor --non-interactive --fix --yes (exit 0), and ran config validate --json (valid=true, warnings=[]), then started the candidate Gateway. No automatic openclaw update success is claimed. The runtime-only candidate had Control UI disabled; Doctor’s omitted-UI and empty-workspace advisories were recorded. This proves the persisted model/chat path, not web assets.

Redacted command sequence (all CLI commands used the same isolated environment/profile):

npm view openclaw dist-tags --json
npm install --global --prefix "$PREFIX" [email protected]
node scripts/package-openclaw-for-docker.mjs --skip-build --runtime-only \
  --allow-unreleased-changelog --output-dir "$ARTIFACTS" \
  --output-name openclaw-reasoning-upgrade.tgz
npm install --global --prefix "$PREFIX" "$ARTIFACTS/openclaw-reasoning-upgrade.tgz"
openclaw --profile reasoning-effort-upgrade doctor --non-interactive --fix --yes
openclaw --profile reasoning-effort-upgrade config validate --json
openclaw --profile reasoning-effort-upgrade gateway run

The npm installs used the scoped install-script allowlist for OpenClaw and its dependency scripts. The registry install's blocked scripts were completed with an isolated-prefix rebuild before stable startup.

Redacted verification output:

{
  "providerDefinitionsAndReasoningDeclarationsPreserved": "3/3",
  "originalSessionIdsModelsAndSavedPreferencesPreserved": "6/6",
  "originalTranscriptMessagesPreserved": "12/12",
  "configuredThinkingDefault": "high (unchanged)",
  "doctorExit": 0,
  "configValid": true,
  "allTwelveTurns": "HTTP 200; visible 4; normal stop; no rerouting",
  "postUpgradeOff": "3/3 zero reasoning characters",
  "postUpgradeMedium": "3/3 medium on wire; reasoning remains enabled"
}
Route / model Saved preference Wire effort, stable → head Reasoning chars, stable → head Head Gateway seconds
declared / qwen3:8b off none → none 0 → 0 7.283
declared / qwen3:8b medium medium → medium 505 → 655 2.877
studio / google/gemma-4-e4b off none → none 0 → 0 1.149
studio / google/gemma-4-e4b medium medium → medium 249 → 346 2.417
mapped / qwen3:8b off none → none 0 → 0 1.274
mapped / qwen3:8b medium medium → medium 429 → 490 2.511

Provider/model definitions, compat lists/maps, and all agent settings are semantically identical before and after Doctor. Doctor added its ordinary migration/wizard markers and missing defaults outside those settings; the whole config file is therefore not byte-identical. All six session IDs, model selections, and saved preferences matched before any new candidate turn, and all twelve original messages remained after the second turns. Timings are functional probes, not benchmarks. Package SHA-256: 6adc960f0e780f3a6861ba1be0be8b15e7211dab7ad3f078953dab24d8aaeeff.

No code changed or new head was pushed for this proof. The isolated Gateways were stopped after testing; shared model servers remain running.

Preserve operator effort declarations across catalog resolution and only send an explicit disable value when the selected route supports it. Keep binary controls independent of scalar effort support and retain runtime preference clamping.

Fixes #165119. Fixes #177425. Thanks to @tre1d and @eulrich101618 for the reports and reproductions.
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 24, 2026 22:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T04:21:38.218191Z 113f6bf New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6e0f9024d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (
model.reasoning &&
(!compat.thinkingOffControlUndeclared || thinkingEnabled !== undefined || !thinkingExplicit)
(!compat.thinkingOffControlUndeclared || thinkingEnabled === true || !thinkingExplicit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor model-level off mappings before suppressing Z.AI controls

When a Z.AI model declares thinkingLevelMap: { off: "none" } without an explicit compat.thinkingFormat, an explicit off request now loses its disable control. The Gateway's provider attribution marks the configured Z.AI endpoint as proxy-like, and resolveOpenAICompletionsCompat sets thinkingOffControlUndeclared because it checks only compat declarations, not thinkingLevelMap. Although the shared resolver correctly returns effort: "none" and thinkingEnabled: false, this new condition skips the block that emits thinking: { type: "disabled" }, leaving server-default thinking enabled. Include model-level off mappings in the declaration check so verified disable mappings remain effective.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves configured reasoning capabilities and omits undeclared scalar disable values on compatible model routes.

Example: opencode-go/muse-spark-1.3-contributor receives a utility request with thinking off and no declared disable mapping.

  • Before: The request sends none and receives HTTP 400.
  • After: The request omits scalar reasoning effort, leaving the endpoint default in control.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-level repair with meaningful request regressions, live Gateway evidence, and a reusable stable-upgrade run preserving existing settings and session data.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied macOS Gateway chat.send output exercises saved off/medium preferences through real Ollama on the exact head; earlier Gateway scenarios cover strict Responses/title and binary controls, with their head and hosted-provider limits explicitly identified.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Configured thinking levels disappear, and utility/title requests fail when compatible endpoints reject an undeclared none effort.
Reason: The reports establish concrete failures, and the maintainer-authored direction explicitly approves the narrow reasoning-precedence exception.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses two concrete reported failures, resolves the earlier findings, and has no new actionable findings; current-head CI remains pending.

Priority: P2
Reviewed head: 113f6bfe71d459bc806c680e218f7884e76285f6

Before merge

None.

Findings

None.

Agent review details

How this fits together

Model preparation combines configured and catalog capabilities; shared reasoning policy then converts thinking choices into Completions or Responses request fields.

flowchart TD
  A[Configured model declarations] --> C[Catalog compatibility owner]
  B[Provider catalog metadata] --> C
  C --> D[Prepared model route]
  D --> E[Shared reasoning resolver]
  E --> F[Completions adapter]
  E --> G[Responses adapter]
  F --> H[Provider endpoint]
  G --> H
Loading

Technical review

Best possible solution:

Retain the focused catalog and shared-request repairs, preserve declared binary contracts, and complete ordinary current-head CI.

Do we have a high-confidence way to reproduce the issue?

Current-main source exposes both reported paths, supported by reporter reproductions and the PR's recorded failing request/catalog controls; this review executed no target code.

Is this the best way to solve the issue?

The patch repairs the existing catalog and request owners, removes the transport-specific off policy, and preserves explicit opt-outs, accepted ladders, mappings, and binary controls without adding competing state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b17d07fc01e0.

Provenance checked

  • Catalog capability ownership changes intended behavior with a stated reason (5808b72: Prevent stale configured compat from overriding provider-owned capabilities on catalog-known routes.)
  • Shared reasoning mapping and clamping keeps the original intent (f024e67: Preserve logical off, omission, provider-native mappings, binary controls, and explicit capability exclusions across runtimes.)
  • Custom scalar off policy keeps the original intent (3dac10b: Enable reasoning efforts on custom compatible routes while omitting undeclared disable values.)
  • Inferred custom Z.AI disable suppression keeps the original intent (20299f8: Avoid rejected thinking-disabled requests on custom always-thinking GLM endpoints without a declared off contract.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +43, Tests +158, Docs +7, Other +1. Total +209 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 101 58 +43
Tests 6 187 29 +158
Docs 3 14 7 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 1 +1
Total 17 304 95 +209

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The affected workflows lose configured reasoning choices or useful session titles without evidence of a broad outage.
  • merge-risk: 🚨 compatibility: Existing configured reasoning declarations gain precedence on catalog-known routes, and unknown disable contracts omit scalar effort; the maintainer-authored direction explicitly accepts and documents these changes.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-24T23:05:31.272Z sha e6e0f90 :: blocked before merge. :: [P2] Honor model-level off mappings before suppressing Z.AI controls | [P2] Include the new dependency in the extracted PR wrapper inventory | [P2] Update managed off assertions for the new omission contract
  • reviewed 2026-10-24T23:24:41.000Z sha 7b6eb01 :: blocked before merge. :: [P2] Honor model-level off mappings before suppressing Z.AI controls
  • reviewed 2026-10-24T23:53:27.342Z sha 30807be :: blocked before merge. :: none
  • reviewed 2026-10-26T03:01:50.378Z sha 30807be :: needs changes before merge. :: none

Reviewed October 26, 2026, 12:27 AM ET / 04:27 UTC (Revision 5).

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The model-level off-map finding is fixed, including production Z.AI attribution with scalar support unset/false. Both regressions fail before the fix; all 156 request tests pass. The attribution HTTP fixture now returns visible answers, and all ten final-head Gateway cases pass. Latest-stable upgrade proof remains an explicit limitation in the PR body.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 26, 2026
Preserve main’s shared route-compat test fixtures while retaining the declared reasoning-effort regression cases. The production reasoning and catalog owners merge unchanged.
Clear only an inherited empty effort ladder when the operator explicitly enables scalar reasoning. Preserve non-empty accepted ladders and explicit configured restrictions.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Merged main without rebasing and preserved its shared test fixtures. The merge-resolution review also found and fixed a boolean-only scalar opt-in being vetoed by an inherited empty catalog ladder; a red regression and nonempty-ladder control now pass. All 265 request/catalog/compat tests, wrapper extraction, prefix stability, scoped checks, and the exact-head live Qwen off/medium recheck pass. Independent review is clean. Current-head evidence and the clearly labeled pre-merge upgrade proof are in the PR body.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@steipete
steipete merged commit 642b31d into main Oct 26, 2026
160 of 163 checks passed
@steipete
steipete deleted the fix/reasoning-effort branch October 26, 2026 06:37
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…w#182987)

* fix: honor reasoning capabilities on compatible model routes

Preserve operator effort declarations across catalog resolution and only send an explicit disable value when the selected route supports it. Keep binary controls independent of scalar effort support and retain runtime preference clamping.

Fixes openclaw#165119. Fixes openclaw#177425. Thanks to @tre1d and @eulrich101618 for the reports and reproductions.

* fix: preserve explicitly mapped reasoning controls

* test: align declared reasoning mapping expectations

* fix: retain declared binary thinking controls in managed requests

* fix: honor model reasoning maps on attributed ZAI routes

* test: type mapped reasoning transport cases without assertions

* fix: honor scalar reasoning opt-in over empty catalog metadata

Clear only an inherited empty effort ladder when the operator explicitly enables scalar reasoning. Preserve non-empty accepted ladders and explicit configured restrictions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant