Skip to content

fix(ai): preserve declared reasoning tiers in embedded sessions - #146134

Merged
steipete merged 1 commit into
mainfrom
codex/compat-reasoning-owner-20260912
Sep 12, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/compat-reasoning-owner-20260912

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #144866.
Related: #90703, #111367, #130706.

What Problem This Solves

Fixes an issue where custom OpenAI-compatible models declare advanced reasoning tiers, but embedded session creation silently clamps max to high before recording the child transcript. Completions also remapped every surviving max to xhigh, including custom backends that explicitly declare native max.

Why This Change Was Made

The shared thinking-level resolver now consumes the existing reasoning contract. Sessions and Responses use the same decision, and Completions leaves serialization to the existing provider mapping. Explicit compat declarations remain authoritative; implicit built-in defaults respect the selected API's ceiling. This removes competing policy and reduces production code by five lines.

Alex Govorov's work in #90703 informed the repair; contributor credit is preserved in the commits.

User Impact

Explicit custom xhigh and max support survives session creation and request serialization. Native defaults remain API-specific: for gpt-5.6-sol, a maximum request uses xhigh on Completions and max on Responses. Undeclared-model defaults, explicit null caps, ordinary minimal/off behavior, and reasoning opt-outs remain covered.

Evidence

  • Baselines reproduced the child-session/transcript clamp and incorrect request effort, with passing sibling controls. A further hosted check exposed a real API distinction: an earlier candidate sent native max to Completions and received HTTP 400. That failure led to the API-specific default repair; the original source/build/proof remains preserved.
  • On runtime-tested c31caa9a769bd20a56a16e7f9606853ea1111d24, 295 focused tests, the full cumulative changed-file checks, independent P2 review, and a normal pnpm build passed.
  • The compiled public LLM SDK passed 20 loopback cases with exact request/wire efforts, HTTP 200, completed streaming, final OK, and natural exit. Explicit custom native max remains covered. An earlier 9/16 fixture attempt omitted the proxy reasoning opt-in and remains qualified as failed.
  • Fresh hosted OpenAI calls on that same build each requested maximum reasoning: Completions sent xhigh, Responses sent max, and both received HTTP 200 with completed OK replies. All 12,092 build outputs remained unchanged; task credential processes and isolated state were cleaned up.
  • Session proof exercises the real embedded constructor and transcript owner, not a full Gateway-to-child sessions_spawn run. Azure retains its existing max-to-xhigh wire alias. Broader mapping/schema proposals in the related PRs are outside this cut.

The final branch head is 75bdfcbbdcee9ed45cc9b8ea5283c989d4ecb262, a patch-identical carry onto current main after an unrelated CI failure. The failed run tested a merge with main that had 701 Gateway test roots; #146212 restored shard headroom while retaining the limits. On the refreshed branch, all 295 focused tests, the unchanged shard inventory check, and the full changed-file gate pass. All eight changed postimages and the relevant production/caller/dependency inputs match the reviewed candidate. The normal build, compiled cases, and hosted observations remain bound to c31caa9a769bd20a56a16e7f9606853ea1111d24; no new build or hosted run is claimed for the mechanical carry.

@clawsweeper

clawsweeper Bot commented Sep 12, 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 agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 15:43
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 1:49 PM ET / 17:49 UTC (Revision 4).

ClawSweeper review

What this changes

Preserves explicitly declared advanced reasoning levels in embedded sessions and OpenAI-compatible requests while retaining API-specific defaults.

Merge readiness

✅ Ready for maintainer review

This focused repair remains necessary on current main. No introduced correctness or security defect was found, and the refreshed branch preserves the reviewed implementation and its relevant runtime proof.

Priority: P2
Reviewed head: 75bdfcbbdcee9ed45cc9b8ea5283c989d4ecb262

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and relevant runtime evidence; no blocking defect was found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied observations exercise the embedded constructor/transcript owner, compiled SDK requests, and hosted Completions/Responses calls with successful final replies. Changed postimages match the runtime-tested revision; proof remains attributed to that revision and does not claim a full Gateway-to-child spawn run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied observations exercise the embedded constructor/transcript owner, compiled SDK requests, and hosted Completions/Responses calls with successful final replies. Changed postimages match the runtime-tested revision; proof remains attributed to that revision and does not claim a full Gateway-to-child spawn run.
Evidence reviewed 7 items Current main still contains the defect: Current main requires a thinkingLevelMap entry to expose xhigh or max, ignoring compat-only declarations at this boundary. Embedded session creation calls this clamp before recording the initial reasoning level.
Latest release also retains the clamp: The same map-only extended-level condition exists in v2026.9.4; the central repair is neither present in the fetched main nor established as shipped.
Shared owner and preserved caps: The patch consults the existing reasoning-effort resolver for four OpenAI-compatible APIs while retaining explicit null caps and non-OpenAI behavior. Completions preserves the selected level for its existing serializer, and Responses removes its separate bypass. This is OpenClaw's embedded implementation; the changed path does not import or execute the Codex harness.
Findings None None.
Security None None.

How this fits together

OpenClaw resolves a requested reasoning level against model capabilities before recording the session and sending a provider request. The shared capability resolver connects configured model support to both session state and transport serialization.

flowchart LR
  A[Requested reasoning level] --> C[Shared capability resolver]
  B[Model declarations and API defaults] --> C
  C --> D[Embedded session and transcript]
  D --> E[Provider effort mapping]
  E --> F[Completions or Responses request]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -5, Tests +213. Total +208 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 14 19 -5
Tests 4 213 0 +213
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 227 19 +208

Review metrics

Metric Value Why it matters
Policy consolidation Production net −5 lines; tests +213 lines The repair removes a transport-specific bypass while adding session and serialized-request regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #144866
Summary: This PR directly targets the reported embedded-session clamp; older related PRs include overlapping capability work and broader mapping changes.

Members:

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

Technical review

Best possible solution:

Use the existing reasoning contract consistently from session capability checks through provider serialization, preserving explicit declarations and API-specific ceilings.

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

Yes, from source: a reasoning model declaring max only through compat reaches the map-only session clamp and records high. Reporter observations corroborate this; no runtime reproduction was executed in this review.

Is this the best way to solve the issue?

Yes. Reusing the existing effort resolver repairs the downstream capability decision without duplicating catalog projection, adding configuration, or changing stored formats.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Custom-provider sessions silently lose requested reasoning depth, while ordinary execution and lower tiers remain available.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied observations exercise the embedded constructor/transcript owner, compiled SDK requests, and hosted Completions/Responses calls with successful final replies. Changed postimages match the runtime-tested revision; proof remains attributed to that revision and does not claim a full Gateway-to-child spawn run.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied observations exercise the embedded constructor/transcript owner, compiled SDK requests, and hosted Completions/Responses calls with successful final replies. Changed postimages match the runtime-tested revision; proof remains attributed to that revision and does not claim a full Gateway-to-child spawn run.

Evidence

What I checked:

  • Current main still contains the defect: Current main requires a thinkingLevelMap entry to expose xhigh or max, ignoring compat-only declarations at this boundary. Embedded session creation calls this clamp before recording the initial reasoning level. (packages/ai/src/model-utils.ts:54, 486b1fc315f5)
  • Latest release also retains the clamp: The same map-only extended-level condition exists in v2026.9.4; the central repair is neither present in the fetched main nor established as shipped. (packages/ai/src/model-utils.ts:54, 3a9d69db306c)
  • Shared owner and preserved caps: The patch consults the existing reasoning-effort resolver for four OpenAI-compatible APIs while retaining explicit null caps and non-OpenAI behavior. Completions preserves the selected level for its existing serializer, and Responses removes its separate bypass. This is OpenClaw's embedded implementation; the changed path does not import or execute the Codex harness. (packages/ai/src/model-utils.ts:51, 75bdfcbbdcee)
  • Session and request regression coverage: The new session cases assert both effective max and the recorded transcript entry across four APIs. The request-boundary matrix checks custom declarations, API defaults, aliases, opt-outs, null caps, and conservative undeclared behavior across Completions and Responses. Tests were inspected, not executed during this read-only review. (src/agents/sessions/sdk.test.ts:852, 75bdfcbbdcee)
  • Runtime proof and mechanical carry: The captured PR body reports 20 completed compiled-SDK loopback cases and hosted Completions/Responses calls returning HTTP 200 and final OK with their respective maximum efforts on c31caa9a769bd20a56a16e7f9606853ea1111d24. GitHub tree data compared with local HEAD confirms all eight changed postimages match that revision. Agent-core, llm-core, src/llm, and the lockfile also match. Differences elsewhere in the inspected package/session trees concern schema projection, credential redaction, and a session-context test. No new hosted execution is attributed to the refreshed head. (c31caa9a769b)
  • Reporter corroboration and existing contract: The reporter confirmed that adding explicit map entries restores max in child transcripts on two custom providers, supporting the downstream-clamp diagnosis: [Bug]: Subagent spawn clamps thinking level to high for config-declared models — model-level compat.supportedReasoningEfforts never reaches the spawn-path profile resolution #144866 (comment). Current thinking documentation already promises compat-declared xhigh support across session validation and transport behavior. Public docs: docs/tools/thinking.md. (docs/tools/thinking.md:36, 75bdfcbbdcee)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • MonkeyLeeT: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-12T15:50:38.041Z sha 3ddc4d6 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T16:08:26.509Z sha 3ddc4d6 :: needs changes before merge. :: none
  • reviewed 2026-09-12T17:04:01.119Z sha c31caa9a769bd20a56a16e7f9606853ea1111d24 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as draft September 12, 2026 16:01
@steipete
steipete marked this pull request as ready for review September 12, 2026 16:57
Use the canonical reasoning-effort contract in the shared session clamp
instead of a Responses-only bypass. Preserve declared custom-backend max
through session transcripts and Completions serialization, including
explicit mappings, null caps, and serialization opt-outs.

Keep implicit native Chat Completions at its existing xhigh ceiling while
Responses retains max. The API-specific default is proven by the hosted
gpt-5.6-sol request contract; explicit compat remains authoritative.

Related: #144866
Related: #90703
Related: #111367
Co-authored-by: Alex Govorov <[email protected]>
@steipete
steipete force-pushed the codex/compat-reasoning-owner-20260912 branch from c31caa9 to 75bdfcb Compare September 12, 2026 17:43
@steipete
steipete merged commit a023ff8 into main Sep 12, 2026
147 of 148 checks passed
@steipete
steipete deleted the codex/compat-reasoning-owner-20260912 branch September 12, 2026 18:13
@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 13, 2026
…claw#146134)

Use the canonical reasoning-effort contract in the shared session clamp
instead of a Responses-only bypass. Preserve declared custom-backend max
through session transcripts and Completions serialization, including
explicit mappings, null caps, and serialization opt-outs.

Keep implicit native Chat Completions at its existing xhigh ceiling while
Responses retains max. The API-specific default is proven by the hosted
gpt-5.6-sol request contract; explicit compat remains authoritative.

Related: openclaw#144866
Related: openclaw#90703
Related: openclaw#111367

Co-authored-by: Alex Govorov <[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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant