Repository navigation
fix(openrouter): configured models send high reasoning effort when xhigh is selected - #160651
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 28, 2026, 6:39 PM ET / 22:39 UTC (Revision 7). ClawSweeper reviewWhat this changesConfigured models on OpenRouter’s standard route use catalog reasoning capabilities for model resolution and thinking choices, with route context added to the provider hook and regression coverage. Merge readiness⛔ Blocked before merge - 4 items remain The reported OpenRouter mismatch is still present on current main, and the PR’s isolated Gateway capture shows the intended outbound effort on the pinned head. A previously identified catalog-refresh edge case remains in the patch. The discussion proposes accepting that parity tradeoff, but the supplied GitHub context does not verify the commenter’s authority to accept it for maintainers. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw combines configured model rows with OpenRouter catalog capabilities before an agent turn. The selected thinking level then becomes an effort value in the outbound OpenRouter request. flowchart LR
A[Model configuration] --> C[Model resolution]
B[OpenRouter catalog] --> C
C --> D[Thinking choices]
D --> E[Selected effort]
E --> F[OpenRouter request]
Decision needed
Why: The tradeoff is specific and plausibly bounded, but the supplied acceptance comment is not independently verified as an authorized maintainer decision. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +80, Tests +353, Docs 0. Total +433 across 9 files. View PR surface stats
Review metrics
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: Keep the focused effort fix and have a verified provider owner either accept the bounded parity window with the linked follow-up or require prepared-row invalidation that preserves explicit operator declarations. Do we have a high-confidence way to reproduce the issue? Yes. The linked issue gives a concrete configured-model Gateway path, and the PR reports baseline and pinned-head outbound request captures through that path; this reviewer did not execute it. Is this the best way to solve the issue? Yes for the central mismatch: the provider owns catalog effort capabilities and the PR preserves configured sizing and explicit route choices. The prepared-row refresh tradeoff still needs verified maintainer disposition. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6188881e0525. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
Configured OpenRouter rows on the catalog route carried reasoning: true without effort metadata, so turn thinking selection clamped xhigh to high before the runtime model was resolved. Pass the selected route to thinking profile hooks and let OpenRouter fill missing effort capabilities from its model catalog on the canonical route only.
…er-reasoning-160474
Thinking profiles run on synchronous Gateway session reads. Consume only capabilities that runtime model resolution already loaded instead of initializing the SQLite-backed catalog cache or starting a fetch.
Thinking profiles kept a plugin-local copy of capabilities from the first runtime resolution, so catalog refreshes never reached session reads. Read the owner's in-memory catalog cache instead; it still avoids SQLite and fetches on synchronous paths. Drop the release-owned changelog entry.
|
Reply to the Revision 5 P2 ("Refresh catalog-derived facts in prepared thinking profiles", This limitation already exists on
The follow-up is #160758, "Prepared OpenRouter rows keep catalog-derived thinking efforts after a catalog refresh". It covers two options: mark catalog-derived metadata separately from declared metadata on prepared rows, or refresh prepared OpenRouter rows when the capability cache changes. Both need changes outside this fix's scope. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer decision for exact head This PR fixes the reported bug: a configured OpenRouter model that supports That limitation already exists on main for non-configured rows (evidence in #160758). Repairing it needs either declared vs. catalog-derived provenance on prepared rows, or invalidation of prepared rows when the capability cache changes. Both are design changes beyond this bug fix. The window is narrow: it requires an upstream catalog change that removes an effort from a model someone has already prepared. Configured declarations keep winning, and there's no new SQLite read or fetch on the session path. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer landing override for exact head Review. The ClawSweeper review has no defect findings in this diff. It recommends "Accept parity and track refresh", and it's blocked only on verifying maintainer acceptance of the pre-existing stale-effort-after-catalog-refresh window. I accept that tradeoff; the repair is tracked in #160758. CI. Fresh run 36487126447 finished with no cancelled jobs, and every type check and the package-boundary job passed. The two failures are main-owned:
Proof. A real Gateway on this head sent |
…igh is selected (openclaw#160651) * fix(openrouter): retain reasoning effort in prepared models * fix(openrouter): keep catalog efforts in configured thinking selection Configured OpenRouter rows on the catalog route carried reasoning: true without effort metadata, so turn thinking selection clamped xhigh to high before the runtime model was resolved. Pass the selected route to thinking profile hooks and let OpenRouter fill missing effort capabilities from its model catalog on the canonical route only. * fix(openrouter): keep thinking profiles off the capability store Thinking profiles run on synchronous Gateway session reads. Consume only capabilities that runtime model resolution already loaded instead of initializing the SQLite-backed catalog cache or starting a fetch. * fix(openrouter): read refreshed catalog efforts for thinking profiles Thinking profiles kept a plugin-local copy of capabilities from the first runtime resolution, so catalog refreshes never reached session reads. Read the owner's in-memory catalog cache instead; it still avoids SQLite and fetches on synchronous paths. Drop the release-owned changelog entry. --------- Co-authored-by: Ayaan Zaidi <[email protected]>
…rocess (#166705) ## What Problem This Solves Fixes: OpenRouter models offer only `off, ultra` on a fresh process, so `openclaw agent --local` (and a Gateway's first turn) rejects valid levels such as `--thinking low` and silently turns a configured `thinkingDefault: max` into `off`. ## User Impact User impact: configured OpenRouter models get their real thinking levels on the first turn of every process. `openai/gpt-5` offers minimal–high (no off, since reasoning is mandatory), `anthropic/claude-sonnet-4.5` offers off/on, `deepseek/deepseek-r1` is always on, and a configured `max` on gpt-5 sends `high` instead of `minimal`. ## Why This Change Was Made The OpenRouter thinking policy and dynamic model row read model capabilities from process memory only. That is deliberate (#160651, #166528): those reads run on synchronous session paths and must not touch SQLite or the network. On a cold process nothing has loaded yet when the prepared model runtime completes configured OpenRouter refs, so the row says `reasoning: false` and the level is chosen from that. Capabilities only load later, in `prepareDynamicModel`, after the level is fixed. The static catalog build already runs asynchronously before that completion, and only for providers whose configured refs need it. Core now passes that selected scope (`providerIds`, an existing catalog-context field) into static catalog hooks, and OpenRouter's static hook awaits its capability loader when OpenRouter is selected: a worker read of the persisted catalog, or one fetch when nothing is persisted yet. Unscoped static runs (doctor validation, the catalog worker, the bundled static fallback) pass no scope and stay network-free. The synchronous reads are unchanged. The provider SDK catalog docs describe the scoped static run. ## Evidence Live, real OpenRouter key, fresh isolated state per run, `openclaw agent --local`, request bodies captured at the HTTP client: | Model / input | main (630e969) | this PR | | --- | --- | --- | | gpt-5 `--thinking low` | rejected: `Use one of: off, ultra` | `reasoning: {effort: "low"}` | | gpt-5 `--thinking low` after a successful turn (SQLite populated) | rejected: `off, ultra` | `effort: "low"` | | gpt-5 default | `effort: "minimal"` (off clamped) | `effort: "medium"` | | gpt-5 `thinkingDefault: max` | `effort: "minimal"` | `effort: "high"` | | gpt-5 `--thinking off` | accepted | rejected: `Use one of: minimal, low, medium, high, ultra` | | claude-sonnet-4.5 `--thinking low` | rejected: `off, ultra` | `reasoning: {enabled: true}` | | claude-sonnet-4.5 default | `enabled: false` | `enabled: true` | | claude-sonnet-4.5 `--thinking off` | `enabled: false` | `enabled: false` | | deepseek-r1 `--thinking low` | rejected: `off, ultra` | `enabled: true` | | deepseek-r1 `--thinking off` | accepted (`enabled: true` sent) | rejected: `Use one of: always on, ultra` | The claude-sonnet-4.5 default change (`enabled: false` → `enabled: true`) is the cold path now matching warm behavior on main. OpenRouter reports this model as `{mandatory: false}` with no default, and OpenClaw applies its existing default for reasoning-capable models. A main Gateway (f186273, isolated, claude-sonnet-4.5 configured, no `--thinking`) sends `enabled: false` on turn 1, then `enabled: true` on turns 2 and 3. Gateway (isolated state and port, gpt-5 configured): first turn with `--thinking low` was rejected with `off, ultra` on main and sends `effort: "low"` with this PR; later turns were already correct on main. Tests: new `extensions/openrouter/static-catalog.test.ts` fails on main (row stays `reasoning: false`) and passes here; it also checks that unscoped static runs make no request. Existing OpenRouter, capability-cache, provider-discovery and implicit-catalog suites pass. Test cost (`pnpm test <file> --maxWorkers=1`, local): `extensions/openrouter/static-catalog.test.ts` 23s wall (Vitest 15.9s, test body 19ms); `src/agents/models-config.providers.implicit.discovery-scope.test.ts` 24s wall (Vitest 17.5s, 20 tests). Both are mostly transform time. Hosted CI run 37671257993 on 1f582fe passed all 79 jobs in 10m52s; the run does not report time per file. No overlap with Pash/Sarah changes. **Merge danger:** two-way door. No stored data, config or schema changes; reverting restores the previous cold behavior. Blast radius: OpenRouter users (first turn may now wait for one catalog read or fetch before selection, which the turn already did later), plus any static catalog hook that starts reading the new optional `providerIds` (none besides OpenRouter today). Co-authored-by: Ayaan Zaidi <[email protected]>
…rocess (openclaw#166705) ## What Problem This Solves Fixes: OpenRouter models offer only `off, ultra` on a fresh process, so `openclaw agent --local` (and a Gateway's first turn) rejects valid levels such as `--thinking low` and silently turns a configured `thinkingDefault: max` into `off`. ## User Impact User impact: configured OpenRouter models get their real thinking levels on the first turn of every process. `openai/gpt-5` offers minimal–high (no off, since reasoning is mandatory), `anthropic/claude-sonnet-4.5` offers off/on, `deepseek/deepseek-r1` is always on, and a configured `max` on gpt-5 sends `high` instead of `minimal`. ## Why This Change Was Made The OpenRouter thinking policy and dynamic model row read model capabilities from process memory only. That is deliberate (openclaw#160651, openclaw#166528): those reads run on synchronous session paths and must not touch SQLite or the network. On a cold process nothing has loaded yet when the prepared model runtime completes configured OpenRouter refs, so the row says `reasoning: false` and the level is chosen from that. Capabilities only load later, in `prepareDynamicModel`, after the level is fixed. The static catalog build already runs asynchronously before that completion, and only for providers whose configured refs need it. Core now passes that selected scope (`providerIds`, an existing catalog-context field) into static catalog hooks, and OpenRouter's static hook awaits its capability loader when OpenRouter is selected: a worker read of the persisted catalog, or one fetch when nothing is persisted yet. Unscoped static runs (doctor validation, the catalog worker, the bundled static fallback) pass no scope and stay network-free. The synchronous reads are unchanged. The provider SDK catalog docs describe the scoped static run. ## Evidence Live, real OpenRouter key, fresh isolated state per run, `openclaw agent --local`, request bodies captured at the HTTP client: | Model / input | main (c018fa5) | this PR | | --- | --- | --- | | gpt-5 `--thinking low` | rejected: `Use one of: off, ultra` | `reasoning: {effort: "low"}` | | gpt-5 `--thinking low` after a successful turn (SQLite populated) | rejected: `off, ultra` | `effort: "low"` | | gpt-5 default | `effort: "minimal"` (off clamped) | `effort: "medium"` | | gpt-5 `thinkingDefault: max` | `effort: "minimal"` | `effort: "high"` | | gpt-5 `--thinking off` | accepted | rejected: `Use one of: minimal, low, medium, high, ultra` | | claude-sonnet-4.5 `--thinking low` | rejected: `off, ultra` | `reasoning: {enabled: true}` | | claude-sonnet-4.5 default | `enabled: false` | `enabled: true` | | claude-sonnet-4.5 `--thinking off` | `enabled: false` | `enabled: false` | | deepseek-r1 `--thinking low` | rejected: `off, ultra` | `enabled: true` | | deepseek-r1 `--thinking off` | accepted (`enabled: true` sent) | rejected: `Use one of: always on, ultra` | The claude-sonnet-4.5 default change (`enabled: false` → `enabled: true`) is the cold path now matching warm behavior on main. OpenRouter reports this model as `{mandatory: false}` with no default, and OpenClaw applies its existing default for reasoning-capable models. A main Gateway (ac78700, isolated, claude-sonnet-4.5 configured, no `--thinking`) sends `enabled: false` on turn 1, then `enabled: true` on turns 2 and 3. Gateway (isolated state and port, gpt-5 configured): first turn with `--thinking low` was rejected with `off, ultra` on main and sends `effort: "low"` with this PR; later turns were already correct on main. Tests: new `extensions/openrouter/static-catalog.test.ts` fails on main (row stays `reasoning: false`) and passes here; it also checks that unscoped static runs make no request. Existing OpenRouter, capability-cache, provider-discovery and implicit-catalog suites pass. Test cost (`pnpm test <file> --maxWorkers=1`, local): `extensions/openrouter/static-catalog.test.ts` 23s wall (Vitest 15.9s, test body 19ms); `src/agents/models-config.providers.implicit.discovery-scope.test.ts` 24s wall (Vitest 17.5s, 20 tests). Both are mostly transform time. Hosted CI run 37671257993 on 1f582fe passed all 79 jobs in 10m52s; the run does not report time per file. No overlap with Pash/Sarah changes. **Merge danger:** two-way door. No stored data, config or schema changes; reverting restores the previous cold behavior. Blast radius: OpenRouter users (first turn may now wait for one catalog read or fetch before selection, which the turn already did later), plus any static catalog hook that starts reading the new optional `providerIds` (none besides OpenRouter today). Co-authored-by: Ayaan Zaidi <[email protected]>
Fixes #160474
What Problem This Solves
Fixes: a configured OpenRouter model on the standard OpenRouter URL reports
xhighthinking but sendsreasoning.effort: "high"when its config row sets sizing such ascontextTokenswithout effort metadata.User Impact
Configured OpenRouter models on the standard route now send the thinking level they report. Models whose OpenRouter catalog entry lacks
xhighstill clamp tohigh, and requests with thinking off send the same payload as before. For models where OpenRouter requires reasoning, the reported level with thinking off is nowlowinstead ofoff. This matches the request OpenClaw already sends and is not new behavior: the OpenRouter thinking policy (extensions/openrouter/thinking-policy.ts) dropsoffwhen the catalog marks reasoning as mandatory (thinkingLevelMap.off: null), non-configured OpenRouter models already reportlow, anddocs/providers/openrouter.mdsays models that require reasoning omit the off choice. Configured rows now match both.Why This Change Was Made
The configured row carries
reasoning: truewithout effort metadata. Two places treated it as the model's complete capability record:xhightohighbefore the run started. Fixing only the runtime model still senthigh.The OpenRouter plugin owns effort capabilities for its catalog route and now applies one route rule to both consumers.
preferRuntimeResolvedModelopts configured rows into the existing runtime metadata pass, and configured sizing and explicitreasoning: falsestill win.resolveThinkingProfilefills missing effort metadata from the OpenRouter capability cache already loaded in process memory (getLoadedOpenRouterModelCapabilities, exported only on the existing private-localprovider-stream-familysubpath). It follows catalog refreshes without a restart, and it does not read the SQLite-backed capability store or start a catalog fetch on Gateway session reads. With a cold cache, the configured row keeps today's profile. Rows that already declare efforts or a thinking map keep their own values. Custom base URLs, non-openai-completionsAPIs and legacy URLs keep their configured capabilities. The thinking profile hook now receives the selected route'sbaseUrl, next to the existingapi, so a provider can make this distinction. This is a compatible, optional plugin SDK addition to theresolveThinkingProfilehook context that the fix needs; existing plugins are unaffected. The field is documented indocs/plugins/sdk-provider-plugins/runtime-hooks.md.Evidence
I ran a real isolated Gateway (
gateway runwith task-owned profile, state, config and port) using the issue's config shape and the standardhttps://openrouter.ai/api/v1base URL. OpenRouter traffic went through a local HTTPS proxy using a task-local CA (HTTPS_PROXY,NODE_EXTRA_CA_CERTS). The proxy servedGET /api/v1/modelsfrom a fixture copied from OpenRouter's public model list for the two models used. This is the same endpoint the plugin reads its catalog from. The proxy recordedPOST /api/v1/chat/completionsbodies and refused every other destination. Each run sent oneopenclaw agent --agent <id> --message pingturn per agent with no thinking override. The baseline was the parent commit, with the production change reverted in the same worktree.main/anthropic/claude-opus-5.5(catalog: max, xhigh, high, medium, low)thinkingDefault: "xhigh"reasoning.effort: "high"reasoning.effort: "xhigh"opus46/anthropic/claude-opus-4.6(catalog: max, high, medium, low)thinkingDefault: "xhigh""high""high"thinkoff/anthropic/claude-opus-5.5thinkingDefault: "off""low""low"Redacted request excerpts from the fixed run:
{"model": "anthropic/claude-opus-5.5", "reasoning": {"effort": "xhigh"}, "max_completion_tokens": 128000} {"model": "anthropic/claude-opus-5.5", "reasoning": {"effort": "low"}, "max_completion_tokens": 128000} {"model": "anthropic/claude-opus-4.6", "reasoning": {"effort": "high"}, "max_completion_tokens": 128000}In the same Gateway setup, the earlier head of this PR (runtime hook only) still sent
"high". Its resolved runtime model carriedxhigh, but thinking selection had already lowered the level.The fixed-run results above were captured again on the final head
69b1eb83from a fresh state directory, so the first turn after Gateway start already sendsxhigh. The plugin regression covers the thinking profile on standard, custom and declared-effort routes, with a cold capability cache, and across a catalog refresh without a restart. A core test checks that the loaded-cache read neither reads SQLite nor fetches when cold, and that it sees refreshed efforts. Its standard-route case fails without the thinking-profile change. These focused tests passed:extensions/openrouter/prefer-runtime-model.test.ts,index.test.tsandprovider-runtime.contract.test.tssrc/agents/embedded-agent-runner/openrouter-model-capabilities.test.tssrc/agents/embedded-agent-runner/model.compat-route.test.tssrc/auto-reply/thinking*,src/agents/thinking-runtimeandsrc/plugins/provider-thinking.external-policysuitespnpm tsgo:extensionsandpnpm tsgo:corealso passed.Changelog
xhighdefault reaches the request instead of being lowered tohigh; custom routes and explicit reasoning opt-outs are unchanged. ([Bug]: OpenRouter configured model loses reasoning metadata in prepared runtime; xhigh sent as high #160474) Thanks @Olli0103 and @AXEG0.No overlap with Pash/Sarah changes.
Thanks @Olli0103 for the fix and @AXEG0 for the detailed report and diagnostic.