Skip to content

fix(agents): preserve model errors during thinking recovery - #139295

Merged
steipete merged 1 commit into
mainfrom
codex/fix-session-active-followup
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-session-active-followup

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139246

Additional instructions

Maintainers can edit this branch.

What Problem This Solves

Fixes an issue where a model rejected for the connected account was retried with thinking disabled. That unnecessary retry could replace the useful model-access error with a Codex lifecycle error, or delay configured model fallback. Unrelated provider options advertising values such as high and low could also change thinking.

Why This Change Was Made

The shared recovery helper now requires a reasoning constraint or a named thinking/reasoning parameter before selecting a replacement level. Model names containing those words cannot authorize recovery. The same helper serves prompt failures, assistant failures, and compaction. Supported-value parsing and candidate selection are consolidated.

The completed-thread ownership repair in #139246 remains the canonical Codex lifecycle fix. This change repairs the independent retry decision that exposed it. No config, schema, protocol, or fallback-selection policy changes.

User Impact

Model/account restrictions retain their original classification: configured defaults can advance to their existing fallback, while explicit model selections report the real failure. Genuine unsupported-thinking and mandatory-reasoning responses retain their existing recovery behavior.

Evidence

  • Captured the reported gateway sequence: accepted turn, provider account/model restriction classified model_not_found, incorrect retry_thinking_level, then misleading active-thread failure. Private identifiers and original chat contents are omitted.
  • Regression tests failed before the fix for unrelated model/account/service-tier errors and model names containing thinking/reasoning terms. Prompt-boundary coverage proves both configured fallback and strict-selection behavior.
  • 59 focused helper, prompt-failure, and assistant-failure tests passed; the final parser cleanup rerun passed all 16 helper tests.
  • Independent Codex review is clean at P0–P2. Live recording, screenshots, and exact request trace show an injected account/model restriction followed by real OpenAI fallback and same-conversation follow-up, all at high thinking. The real isolated Gateway, Codex app-server, and browser ran the exact PR source.
  • Production +20/-31 (net −11); tests +42/-5; docs +5. Full pnpm build passed in Testbox, and exact-head CI passed all 108 executed checks. Local typechecking rejected the shared dependency symlink; hosted CI supplied complete type/lint/test gates.

Require a named reasoning parameter before retrying with a different thinking level, preserving model/account failures and configured fallback decisions. Consolidate supported-value parsing. Related: #139246.
@clawsweeper

clawsweeper Bot commented Sep 5, 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 docs Improvements or additions to documentation agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 18:53
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 2:59 PM ET / 18:59 UTC.

ClawSweeper review

What this changes

Restricts thinking-level recovery to reasoning constraints or named thinking parameters, preserving unrelated provider errors and existing model fallback behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

The fix remains necessary: current main and the latest release still retry unrelated unsupported errors with thinking disabled. No blocking patch defect was found. The related merged lifecycle repair addresses a distinct problem.

Priority: P2
Reviewed head: 7af1ee5dda955d44ff17ad762a48244a72410641

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused shared-owner repair with useful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate, and no material authority change triggers an exception. The captured body reports focused tests and pre-fix Gateway observations, while after-fix runtime evidence remains pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate, and no material authority change triggers an exception. The captured body reports focused tests and pre-fix Gateway observations, while after-fix runtime evidence remains pending.
Evidence reviewed 10 items Introduced recovery guard: The pinned patch adds a parameter-specific guard while retaining mandatory-reasoning recovery and attempted-level exclusion. Supported-value normalization remains delegated to the existing normalization helper.
Original failure classification survives: Prompt handling invokes thinking recovery before executing its final fallback/error decision. The added cases verify preservation of the model-access message and model_not_found classification with fallback both enabled and disabled.
Shared caller coverage: Assistant failure handling uses this helper before retry selection and retains its terminal/replay-safety guards. Compaction uses the same helper at compaction-session-execution.ts:683, so the repair belongs in the shared selector rather than separate caller exceptions.
Findings None None.
Security None None.

How this fits together

The embedded agent runner processes failures from model requests, assistant responses, and compaction. Its shared recovery helper decides whether changing the thinking level can help before existing fallback or error handling proceeds.

flowchart TD
  A[Model request failure] --> D[Shared thinking recovery]
  B[Assistant failure] --> D
  C[Compaction failure] --> D
  D --> E{Thinking parameter or constraint?}
  E -->|Yes| F[Choose unattempted thinking level]
  E -->|No| G[Existing fallback or original error]
Loading

Before merge

  • Resolve merge risk (P1) - After-fix Gateway behavior is not demonstrated in the captured evidence; the reported focused test results were not independently executed.
Agent review details

Security

None.

PR surface

Source -11, Tests +37, Docs +5. Total +31 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 20 31 -11
Tests 2 42 5 +37
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 67 36 +31

Review metrics

Metric Value Why it matters
Production versus test growth Production +20/-31 (net -11); tests +42/-5 (net +37) The shared recovery repair reduces production code while adding focused error-classification coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep thinking recovery in the shared selector and preserve the existing fallback decision whenever the error does not identify a thinking constraint.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep thinking recovery in the shared selector and preserve the existing fallback decision whenever the error does not identify a thinking constraint.

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

Yes, from source: an account-restricted model error containing “not supported” selects off on current main before prompt handling reaches its fallback/error decision. Runtime reproduction was not executed.

Is this the best way to solve the issue?

Yes. Gating the shared selector repairs all three callers without duplicating exceptions or changing model-selection policy; the existing normalization helper preserves parsing behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This bounded recovery fix prevents misleading model-access failures and unnecessary retries without changing configured fallback policy.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate, and no material authority change triggers an exception. The captured body reports focused tests and pre-fix Gateway observations, while after-fix runtime evidence remains pending.

Label justifications:

  • P2: This bounded recovery fix prevents misleading model-access failures and unnecessary retries without changing configured fallback policy.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate, and no material authority change triggers an exception. The captured body reports focused tests and pre-fix Gateway observations, while after-fix runtime evidence remains pending.

Evidence

What I checked:

Likely related people:

  • steipete: 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.

  • Add the promised redacted after-fix Gateway trace showing the original model restriction reaches configured fallback or strict-selection error handling without a thinking retry.

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.

@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Live proof completed for 7af1ee5dda955d44ff17ad762a48244a72410641 on Blacksmith Testbox tbx_01m1sf4tqy3vh4bd86gv6m4av1 (run). This addresses the requested after-fix Gateway trace and ClawSweeper rank-up move.

The recording uses a real isolated Gateway, real Codex app-server, real Control UI, and real OpenAI inference. A loopback provider proxy injects the recorded account/model restriction once; subsequent inference requests go to OpenAI. Only synthetic conversation content appears in the inspected recording and screenshots.

Observed request sequence:

Request Model Thinking Result
Initial gpt-5.6-luna high Injected HTTP 400 account/model restriction
Configured fallback gpt-5.6-sol high Real HTTP 200; UI shows RECOVERY_OK and fallback active
Same-conversation follow-up gpt-5.6-luna high Real HTTP 200; UI shows FOLLOWUP_OK and fallback cleared

There was no intervening thinking retry, no lower-effort request, and no false active-run error. The recording is 7.6 seconds. The empty startup screenshot was excluded from evidence; the attached result captures show the asserted states.

Validation: 59 focused tests across the helper, prompt-failure, and assistant-failure suites; final parser cleanup rerun passed all 16 helper tests. New model/account/option and model-identifier regressions failed before their fixes. Independent Codex autoreview is clean at P0–P2. Full pnpm build passed on this exact source, and CI 33985458367 passed all 108 executed checks. Local typechecking refused the external shared dependency install; hosted CI supplied the complete type/lint/test gates. Testbox reported a portal-sync warning after its successful run; source identity, command exit, downloaded media, and verdict were verified separately.

Production: +20/-31 (−11 lines). Tests: +42/-5. Docs: +5. No config, schema, protocol, or model-selection policy changes.

attachment-646466118.mp4

Successful configured fallback at high thinking

Same conversation succeeds again and clears fallback

@steipete
steipete merged commit a2421a2 into main Sep 5, 2026
255 checks passed
@steipete
steipete deleted the codex/fix-session-active-followup branch September 5, 2026 19:38
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 5, 2026
Consolidate repeated classification, decision inputs, retry/log payloads and compaction dispatch while preserving retry policy and failure-mark ordering. Follow-up to #139295.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…#139295)

Require a named reasoning parameter before retrying with a different thinking level, preserving model/account failures and configured fallback decisions. Consolidate supported-value parsing. Related: openclaw#139246.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
)

Consolidate repeated classification, decision inputs, retry/log payloads and compaction dispatch while preserving retry policy and failure-mark ordering. Follow-up to openclaw#139295.
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant