Skip to content

fix(openrouter): configured models send high reasoning effort when xhigh is selected - #160651

Merged
obviyus merged 5 commits into
openclaw:mainfrom
Olli0103:fix/prepared-openrouter-reasoning-160474
Sep 29, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
Olli0103:fix/prepared-openrouter-reasoning-160474

Conversation

@Olli0103

@Olli0103 Olli0103 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #160474

What Problem This Solves

Fixes: a configured OpenRouter model on the standard OpenRouter URL reports xhigh thinking but sends reasoning.effort: "high" when its config row sets sizing such as contextTokens without effort metadata.

User Impact

Configured OpenRouter models on the standard route now send the thinking level they report. Models whose OpenRouter catalog entry lacks xhigh still clamp to high, and requests with thinking off send the same payload as before. For models where OpenRouter requires reasoning, the reported level with thinking off is now low instead of off. This matches the request OpenClaw already sends and is not new behavior: the OpenRouter thinking policy (extensions/openrouter/thinking-policy.ts) drops off when the catalog marks reasoning as mandatory (thinkingLevelMap.off: null), non-configured OpenRouter models already report low, and docs/providers/openrouter.md says models that require reasoning omit the off choice. Configured rows now match both.

Why This Change Was Made

The configured row carries reasoning: true without effort metadata. Two places treated it as the model's complete capability record:

  • Runtime model resolution returned the configured row without asking the OpenRouter provider for its catalog model.
  • The turn's thinking selection read the same row, so it lowered xhigh to high before the run started. Fixing only the runtime model still sent high.

The OpenRouter plugin owns effort capabilities for its catalog route and now applies one route rule to both consumers. preferRuntimeResolvedModel opts configured rows into the existing runtime metadata pass, and configured sizing and explicit reasoning: false still win. resolveThinkingProfile fills missing effort metadata from the OpenRouter capability cache already loaded in process memory (getLoadedOpenRouterModelCapabilities, exported only on the existing private-local provider-stream-family subpath). 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-completions APIs and legacy URLs keep their configured capabilities. The thinking profile hook now receives the selected route's baseUrl, next to the existing api, so a provider can make this distinction. This is a compatible, optional plugin SDK addition to the resolveThinkingProfile hook context that the fix needs; existing plugins are unaffected. The field is documented in docs/plugins/sdk-provider-plugins/runtime-hooks.md.

Evidence

I ran a real isolated Gateway (gateway run with task-owned profile, state, config and port) using the issue's config shape and the standard https://openrouter.ai/api/v1 base URL. OpenRouter traffic went through a local HTTPS proxy using a task-local CA (HTTPS_PROXY, NODE_EXTRA_CA_CERTS). The proxy served GET /api/v1/models from 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 recorded POST /api/v1/chat/completions bodies and refused every other destination. Each run sent one openclaw agent --agent <id> --message ping turn per agent with no thinking override. The baseline was the parent commit, with the production change reverted in the same worktree.

Agent / model Setting Base request Fixed request
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.5 thinkingDefault: "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 carried xhigh, but thinking selection had already lowered the level.

The fixed-run results above were captured again on the final head 69b1eb83 from a fresh state directory, so the first turn after Gateway start already sends xhigh. 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.ts and provider-runtime.contract.test.ts
  • src/agents/embedded-agent-runner/openrouter-model-capabilities.test.ts
  • src/agents/embedded-agent-runner/model.compat-route.test.ts
  • the src/auto-reply/thinking*, src/agents/thinking-runtime and src/plugins/provider-thinking.external-policy suites

pnpm tsgo:extensions and pnpm tsgo:core also passed.

Changelog

No overlap with Pash/Sarah changes.

Thanks @Olli0103 for the fix and @AXEG0 for the detailed report and diagnostic.

@clawsweeper

clawsweeper Bot commented Sep 28, 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.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. agents Agent runtime and tooling extensions: openrouter size: M labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 6:39 PM ET / 22:39 UTC (Revision 7).

ClawSweeper review

What this changes

Configured 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
Reviewed head: 69b1eb834a822ee19c0a426ba488b731861f4bbd
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The central repair has strong production-path evidence, while the unresolved prepared-row refresh behavior needs an explicit disposition.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR reports a fresh-state isolated Gateway run on the pinned head, with a local HTTPS proxy recording the actual OpenRouter request: configured xhigh changed from baseline high to xhigh, while high-only and thinking-off controls retained their expected efforts. This proves the central outbound behavior, but not the later prepared-row refresh case. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports a fresh-state isolated Gateway run on the pinned head, with a local HTTPS proxy recording the actual OpenRouter request: configured xhigh changed from baseline high to xhigh, while high-only and thinking-off controls retained their expected efforts. This proves the central outbound behavior, but not the later prepared-row refresh case. No stored-data contract changes.
Evidence reviewed 8 items Introduced route preference: The pinned PR adds catalog-model preference for configured rows on the canonical OpenRouter route.
Refresh limitation: The new thinking hook returns a prepared row as soon as it contains effort metadata or a thinking map, before consulting refreshed in-memory catalog capabilities.
Test coverage boundary: The refresh test supplies a row without prepared effort fields, so it does not exercise a row retaining catalog-derived xhigh after the catalog removes it.
Findings 1 actionable finding [P2] Resolve stale catalog efforts in prepared configured rows
Security None None.

How this fits together

OpenClaw 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]
Loading

Decision needed

Question Recommendation
May this PR extend the existing prepared-row catalog-refresh limitation to configured OpenRouter models while #160758 tracks the shared repair? Accept parity and track refresh: Land the focused correction with the documented stale-effort window and retain the linked shared follow-up.

Why: The tradeoff is specific and plausibly bounded, but the supplied acceptance comment is not independently verified as an authorized maintainer decision.

Before merge

  • Resolve stale catalog efforts in prepared configured rows (P2) - The new configured-route preference can prepare a row with catalog-derived xhigh. After the catalog cache drops xhigh, this early return keeps that older effort in thinking choices and can carry it into a request. The refresh test passes only a row without those prepared fields. Preserve operator declarations while refreshing derived facts, or obtain verified maintainer acceptance of the documented parity tradeoff before merge.
  • Resolve merge risk (P1) - A configured model prepared with catalog-derived xhigh can keep offering or selecting it after a catalog refresh removes that effort. The linked follow-up describes a similar main-branch limitation, but verified maintainer acceptance of extending it to configured rows is still needed.
  • Complete next step (P2) - Get verified provider-owner acceptance of configured-row refresh parity or repair the stale derived-effort path before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P2] Resolve stale catalog efforts in prepared configured rows — extensions/openrouter/index.ts:77-83
Agent review details

Security

None.

PR surface

Source +80, Tests +353, Docs 0. Total +433 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 81 1 +80
Tests 3 353 0 +353
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 435 2 +433

Review metrics

Metric Value Why it matters
Production and test delta production +80 net lines, tests +353 lines The production growth implements provider-owned route handling; the larger test addition covers model resolution, thinking selection, and outbound effort.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #160474
Summary: This PR is the candidate fix for the reported configured-model effort mismatch; the catalog-refresh issue tracks a related but distinct remaining behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the bounded refresh window (recommended)
    A verified provider owner can accept configured-row parity and keep the shared refresh repair in the linked follow-up.
  2. Refresh derived efforts first
    Update or invalidate catalog-derived prepared facts while retaining operator-declared capabilities.

Technical review

Best 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:

  • [P2] Resolve stale catalog efforts in prepared configured rows — extensions/openrouter/index.ts:77-83
    The new configured-route preference can prepare a row with catalog-derived xhigh. After the catalog cache drops xhigh, this early return keeps that older effort in thinking choices and can carry it into a request. The refresh test passes only a row without those prepared fields. Preserve operator declarations while refreshing derived facts, or obtain verified maintainer acceptance of the documented parity tradeoff before merge.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This fixes a documented provider-setting mismatch with limited reported impact.
  • merge-risk: 🚨 auth-provider: Prepared OpenRouter models can retain a removed catalog effort after refresh, affecting available thinking choices and provider requests.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR reports a fresh-state isolated Gateway run on the pinned head, with a local HTTPS proxy recording the actual OpenRouter request: configured xhigh changed from baseline high to xhigh, while high-only and thinking-off controls retained their expected efforts. This proves the central outbound behavior, but not the later prepared-row refresh case. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports a fresh-state isolated Gateway run on the pinned head, with a local HTTPS proxy recording the actual OpenRouter request: configured xhigh changed from baseline high to xhigh, while high-only and thinking-off controls retained their expected efforts. This proves the central outbound behavior, but not the later prepared-row refresh case. No stored-data contract changes.

Evidence

What I checked:

  • Introduced route preference: The pinned PR adds catalog-model preference for configured rows on the canonical OpenRouter route. (extensions/openrouter/index.ts:362, 69b1eb834a82)
  • Refresh limitation: The new thinking hook returns a prepared row as soon as it contains effort metadata or a thinking map, before consulting refreshed in-memory catalog capabilities. (extensions/openrouter/index.ts:77, 69b1eb834a82)
  • Test coverage boundary: The refresh test supplies a row without prepared effort fields, so it does not exercise a row retaining catalog-derived xhigh after the catalog removes it. (extensions/openrouter/prefer-runtime-model.test.ts:137, 69b1eb834a82)
  • Current-main comparison: Current main still lacks the configured-row preference and still calls the OpenRouter thinking hook without the new catalog enrichment, so the central fix has not landed. (extensions/openrouter/index.ts:354, 6188881e0525)
  • Gateway behavior evidence: The PR body reports a fresh-state isolated Gateway turn through a local HTTPS proxy on the pinned head: the affected model sent xhigh after the fix versus high on the baseline; high-only and thinking-off controls retained their stated payloads. This is contributor-supplied production-path evidence, not a run performed by this reviewer. (69b1eb834a82)
  • Discussion and follow-up: The later discussion links Prepared OpenRouter rows keep catalog-derived thinking efforts after a catalog refresh #160758, documents a similar pre-existing limitation for non-configured rows, and proposes accepting parity for this head. The commenter is marked CONTRIBUTOR in the supplied context, so that comment alone does not establish maintainer acceptance.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Lennart Lopin: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain verified provider-owner acceptance of the bounded refresh tradeoff or repair derived-metadata invalidation before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-28T18:42:06.070Z sha 754c8c1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T19:34:00.543Z sha 754c8c1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T20:53:57.762Z sha 47abc48 :: blocked before merge. :: [P2] Keep the catalog cache read out of Gateway thinking profiles
  • reviewed 2026-09-28T21:19:36.554Z sha 5ae8b49 :: blocked before merge. :: [P2] Invalidate catalog-derived thinking facts on refresh
  • reviewed 2026-09-28T21:51:34.119Z sha 69b1eb8 :: blocked before merge. :: [P2] Refresh catalog-derived facts in prepared thinking profiles
  • reviewed 2026-09-28T22:31:00.050Z sha 69b1eb8 :: blocked before merge. :: [P2] Refresh catalog-derived efforts in prepared thinking profiles

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 28, 2026
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.
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 28, 2026
@obviyus obviyus changed the title fix(openrouter): retain reasoning effort in prepared models fix(openrouter): configured models send high reasoning effort when xhigh is selected Sep 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
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.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Sep 28, 2026
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.
@obviyus

obviyus commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Reply to the Revision 5 P2 ("Refresh catalog-derived facts in prepared thinking profiles", extensions/openrouter/index.ts:77-83):

This limitation already exists on main, and this PR doesn't introduce it. I'm tracking it in #160758 rather than fixing it here.

  • Configured declarations must keep winning. When a row declares compat.supportedReasoningEfforts or a thinkingLevelMap, those values are what the operator asked for, so the guard at index.ts:77-83 returns them unchanged. The "declared route efforts" case pins this: a row declaring ["low","high"] gets off/low/high even while the loaded catalog advertises xhigh.

  • The hook can't tell declared fields from catalog-derived ones. resolveThinkingProfile gets one merged row. A prepared row's thinkingLevelMap and efforts look the same whether an operator wrote them or catalog preparation copied them in. Preferring the refreshed cache whenever those fields exist would override explicit declarations.

  • Non-configured rows already behave this way on main. I checked this with a throwaway Vitest on a main baseline (9366fd94e19 with this PR's source files reverted), using the real buildOpenrouterLiveProvider discovery, the real capability cache and the real OpenRouter thinking hook, with synthetic upstream responses:

    • The prepared row carries supportedReasoningEfforts: ["xhigh","high","medium","low"] and thinkingLevelMap: {"off":null}. The hook offers ["low","medium","high","xhigh"].
    • Upstream then drops xhigh, and a missing-model load refreshes the capability cache to ["high","medium","low"].
    • Preparing the row again returns the same cached row, still with xhigh (no new model-list fetch), and the hook still offers ["low","medium","high","xhigh"].

    This PR gives configured catalog-route rows that declare nothing the same behavior. They get catalog efforts from the currently loaded cache, which also follows refreshes. Rows that already carry effort metadata, whether declared or catalog-derived, keep today's behavior.

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.

@obviyus

obviyus commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Maintainer decision for exact head 69b1eb834a822ee19c0a426ba488b731861f4bbd: accept the parity tradeoff and track the refresh repair in #160758.

This PR fixes the reported bug: a configured OpenRouter model that supports xhigh now sends reasoning.effort: "xhigh" instead of "high", verified through a real Gateway. The review's remaining concern is that after OpenRouter removes an effort from a model's catalog entry, a prepared row can keep offering the old effort until it's re-prepared.

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.

@obviyus

obviyus commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Maintainer landing override for exact head 69b1eb834a822ee19c0a426ba488b731861f4bbd. This comment is by the maintainer, @obviyus.

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 reasoning.effort: "xhigh" for configured openrouter/anthropic/claude-opus-5.5 with thinkingDefault: xhigh. The controls were unchanged: a model without xhigh sent high, and thinking off sent low.

@obviyus
obviyus merged commit 4ddd0e3 into openclaw:main Sep 29, 2026
247 of 251 checks passed
@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Landed as 4ddd0e3. Thanks @Olli0103 for the fix and @AXEG0 for the clear report. The stale-effort-after-catalog-refresh follow-up is tracked in #160758.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…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]>
obviyus added a commit that referenced this pull request Oct 7, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…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]>
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 extensions: openrouter merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenRouter configured model loses reasoning metadata in prepared runtime; xhigh sent as high

2 participants