Skip to content

fix(agents): a Codex turn that fails at the provider is shown as stopped with no explanation - #165488

Merged
steipete merged 2 commits into
mainfrom
codex/stab-provider-error-surface
Oct 5, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/stab-provider-error-surface

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: when a Codex-runtime turn fails at the provider after doing work (for example "Selected model is at capacity"), the chat shows "The tool run finished, but no final summary was produced", task progress says "Stopped", and the chat stream reports the turn as aborted — the actual cause and what to do next are never shown.

User Impact

User impact: a provider failure now reads as a failure. The reply explains the cause and the next step (for capacity: wait and retry, or pick another model), the chat terminal is error with sanitized errorMessage/errorDetail, and task progress stays failed instead of "Stopped". Completed actions are still not repeated, and an explicit Stop is still a cancellation.

Why This Change Was Made

After a native turn failed post-tools, settled-turn finalization replaced the failure with its generic successful fallback summary. The run then ended with an error lifecycle carrying stopReason: "stop" and no error detail, which downstream classification treats as a cancellation. Finalization now keeps the failed terminal and renders the fallback reply through the existing user-facing error formatter, and native harness terminal events carry the sanitized error text plus projectChatErrorDetail (provider, model, failover reason, HTTP status), reusing the existing observation and failover classifiers. No retry policy, protocol, or UI change.

Evidence

Live (dev Gateway, OpenAI provider, Codex runtime): a 503 s, 60-tool turn resumed after restart recovery hit the provider error. Gateway lifecycle error contained "Selected model is at capacity. Please try a different model.", but chat published {state: "aborted", stopReason: "stop"} with no error fields; the transcript and Control UI showed only the generic "no final summary" text and "Stopped".

TMPDIR=… pnpm test src/gateway/server-chat.native-provider-error.test.ts --maxWorkers=1                         → 2 passed (32.9 s)
TMPDIR=… pnpm test src/agents/embedded-agent-runner/run/settled-turn-finalization.unavailable.test.ts --maxWorkers=1 → 6 passed (26.3 s)
TMPDIR=… pnpm test src/agents/embedded-agent-runner/run/settled-turn-finalization.test.ts --maxWorkers=1           → 35 passed (16.4 s)
main: three finalization cases produced generic/silent fallbacks and the native-event case lacked sanitized guidance/detail

Built-in provider-error, Gateway events, timeout, stale-tool-error, and cancellation siblings pass. Targeted lint, core types, formatting, docs links pass.

Production +86/−28 (keeps the failure state through finalization and publishes sanitized detail); tests +132/−12; docs +5.

CI follow-up

CI run 37291875857 failed two cases in test/codex-settled-turn-finalization.integration.test.ts: the fixture starts with a provider failure, but empty recovery still expected completed-empty and the generic successful fallback. The focused local run reproduced both failures (2 failed, 4 passed). Those assertions now expect the preserved failed outcome and the existing overload guidance, and verify that the original failed terminal is retained. The test's user-visible silence, cancellation, and no-replay contracts remain intact; production code is unchanged by this follow-up.

After the assertion update, all 14 cases across the integration, unavailable-finalization, and native-provider-error Gateway suites passed in 56.9 seconds total wall time. The failing CI integration suite used 1.28 seconds of test execution and 61.4 seconds including imports. Fresh independent review of the complete candidate found no actionable findings through P2.

Changed-file validation passed formatting, guards, all four root-test typecheck shards, script lint, and the targeted test lint. The aggregate local check stopped at existing Knip unused exports; an independent scan on main reproduced the same production and full-tree findings in extensions/google-meet/src/transports/types.ts, extensions/memory-wiki/src/compiled-cache.ts, extensions/workboard/src/gateway-helpers.ts, and src/meeting-bot/runtime-facade-types.ts. This PR changes none of those owners. The remaining lint steps were run separately and passed.

Keep failed execution outcomes when tool-free finalization is unavailable or empty. Persist sanitized provider guidance under the existing transcript receipt, and publish native lifecycle error details so chat shows a failure instead of a stopped run. Preserve cancellation, successful recovery, and replay ownership.
@clawsweeper

clawsweeper Bot commented Oct 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 gateway Gateway runtime agents Agent runtime and tooling extensions: codex size: M labels Oct 5, 2026
@steipete
steipete marked this pull request as ready for review October 5, 2026 09:42
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 6:16 AM ET / 10:16 UTC (Revision 2).

ClawSweeper review

What this changes

Preserve provider failures after tool work, show sanitized recovery guidance and chat error details, and update regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still replaces unrecovered provider failures with a generic fallback. No actionable introduced defect was found, and the latest commit corrects integration expectations without changing production behavior.

Priority: P1
Reviewed head: 5da3228424f2170ccdf2e41ea5674ce4cfb8e459

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused existing-behavior repair with meaningful boundary coverage and no actionable correctness or security findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from external-contributor proof requirements. Its live account demonstrates the pre-fix finalization failure; reported after-change suites exercise transcript persistence and lifecycle-to-chat projection. No stored-data format or migration changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from external-contributor proof requirements. Its live account demonstrates the pre-fix finalization failure; reported after-change suites exercise transcript persistence and lifecycle-to-chat projection. No stored-data format or migration changes.
Evidence reviewed 9 items Pinned introduction and review continuity: Reviewed the merge-base-to-head changes. Comparing the previous reviewed head with this head shows only integration assertion updates; the previous review retained no findings. The supplied test merge is stale and was not used to infer removal of main behavior.
Current main still needs the repair: Fetched main persists the generic fallback and recomputes terminal state from a synthetic completed assistant. It lacks the introduced preservation of the original provider failure. No merged fixing PR is established, and this review makes no shipped-fix claim.
Failure preservation: The fallback uses the existing error formatter, persists the resulting guidance through the existing receipt, and retains the original failed terminal unless recovery supplies an answer. Cancellation checks and transcript writer fencing remain in place.
Findings None None.
Security None None.

How this fits together

Agent finalization turns settled tool work into a final reply and terminal outcome. The Gateway consumes lifecycle events to display success, failure, or cancellation in chat.

flowchart TD
  A[Provider turn and completed tools] --> B[Agent finalization]
  B --> C{Recovery produces an answer?}
  C -->|Yes| D[Recovered final reply]
  C -->|No| E[Preserved failure and safe guidance]
  D --> F[Gateway lifecycle projection]
  E --> F
  F --> G[Chat and task status]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +58, Tests +120, Docs +5. Total +183 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 86 28 +58
Tests 4 132 12 +120
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 223 40 +183

Review metrics

Metric Value Why it matters
Production and regression growth production net +58 lines; tests net +120 lines Production growth has a stated purpose: preserve failure state and reuse sanitized diagnostic projection across two distinct regression boundaries.

Technical review

Best possible solution:

Keep failure ownership separate from fallback reply content and use the existing sanitized error and chat projection owners.

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

Yes, source establishes the path: a failed provider turn with settled tools and unavailable or empty finalization receives a generic fallback on current main. This review did not execute it.

Is this the best way to solve the issue?

Yes, the patch repairs the existing finalization and lifecycle owners, reuses established sanitization, and preserves successful recovery, cancellation, and no-replay behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The reported live agent workflow hides provider failures as stopped runs and omits actionable recovery guidance.
  • 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 MEMBER-authored PR is exempt from external-contributor proof requirements. Its live account demonstrates the pre-fix finalization failure; reported after-change suites exercise transcript persistence and lifecycle-to-chat projection. No stored-data format or migration changes.

Evidence

What I checked:

  • Pinned introduction and review continuity: Reviewed the merge-base-to-head changes. Comparing the previous reviewed head with this head shows only integration assertion updates; the previous review retained no findings. The supplied test merge is stale and was not used to infer removal of main behavior. (test/codex-settled-turn-finalization.integration.test.ts:98, 5da3228424f2)
  • Current main still needs the repair: Fetched main persists the generic fallback and recomputes terminal state from a synthetic completed assistant. It lacks the introduced preservation of the original provider failure. No merged fixing PR is established, and this review makes no shipped-fix claim. (src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:260, 1b7d11db6a98)
  • Failure preservation: The fallback uses the existing error formatter, persists the resulting guidance through the existing receipt, and retains the original failed terminal unless recovery supplies an answer. Cancellation checks and transcript writer fencing remain in place. (src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:271, 5da3228424f2)
  • Sanitized lifecycle diagnostics: Native lifecycle errors pass through existing user-facing rendering and redacted observation helpers. The existing closed chat projection admits bounded provider facts and excludes raw bodies, previews, and correlation hashes. (src/agents/harness/attempt-events.ts:67, 5da3228424f2)
  • Distinct regression boundaries: The unavailable-finalization suite covers preserved failure, real transcript append, no replay, and scheduled-run behavior. The new Gateway suite covers schema-valid error publication and cancellation. The integration follow-up preserves silence and no-replay contracts. Reported test results were inspected but not rerun in this read-only review. (src/agents/embedded-agent-runner/run/settled-turn-finalization.unavailable.test.ts:162, 5da3228424f2)
  • Captured runtime evidence and proof applicability: The supplied body reports a live pre-fix dev-Gateway failure and after-change regression suites, including 14 passing cases in 56.9 seconds after the integration update. This is not an after-fix live demonstration. Repository State identifies the author as MEMBER, so the external-contributor proof gate does not apply. The patch changes diagnostic content within the existing transcript format, not a stored-data contract. (5da3228424f2)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Sarah Fortune: 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 (1 earlier review cycle)
  • reviewed 2026-10-05T09:51:04.542Z sha e273888 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit b27c0b9 into main Oct 5, 2026
108 checks passed
@steipete
steipete deleted the codex/stab-provider-error-surface branch October 5, 2026 10:24
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…ped with no explanation (openclaw#165488)

* fix(agents): preserve provider failures after settled finalization

Keep failed execution outcomes when tool-free finalization is unavailable or empty. Persist sanitized provider guidance under the existing transcript receipt, and publish native lifecycle error details so chat shows a failure instead of a stopped run. Preserve cancellation, successful recovery, and replay ownership.

* test(codex): expect preserved provider failure after empty recovery
amittell added a commit to amittell/openclaw that referenced this pull request Oct 10, 2026
Upstream openclaw#168326 merged to main as c18324d and is
not in v2026.9.9 or a beta. The request builder's own refusal ("Context
window exceeded: estimated input N leaves only M output tokens within
the C-token context.") is now a context overflow for every classifier,
not only the text heuristic, so a prompt that exhausts the output budget
shows the /reset, /new or larger-context guidance in live chat, Details,
saved history and channel replies. It needs openclaw#167878's refusal wording,
carried in the previous commit; openclaw#158161's old wording would not match.

Conflicts and 9.9 adaptations:
- overflow.ts and overflow.test.ts merged cleanly; the carried openclaw#158161
  TGI wordings stay next to the new REQUEST_BUDGET_OVERFLOW_RE.
- user-copy.ts: took the widened CONTEXT_OVERFLOW_ERROR_HEAD_RE and
  pointed 9.9's FAILOVER_REASON_BASE_COPY.context_overflow at the new
  shared CONTEXT_OVERFLOW_ERROR_MESSAGE (same text); main's unrelated
  provider prompt-size constants are not carried.
- assistant-request-failure-copy.ts: 9.9 keeps its own layout. Its
  recorded-failure context-overflow copy ("this conversation is too
  large for the model ... tighter output limit") now returns
  CONTEXT_OVERFLOW_ERROR_MESSAGE, which is what openclaw#168326 did to main's
  copy, and server.chat.gateway-server-chat.test.ts and
  server-methods.test.ts expect the new text.
- server-chat.native-provider-error.test.ts does not exist on 9.9
  (main added it in openclaw#165488 with a shared test harness 9.9 lacks). It
  is added with only openclaw#168326's case, on a minimal harness built from
  9.9's createAgentEventHandler and test helpers.
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
…ped with no explanation (#165488)

* fix(agents): preserve provider failures after settled finalization

Keep failed execution outcomes when tool-free finalization is unavailable or empty. Persist sanitized provider guidance under the existing transcript receipt, and publish native lifecycle error details so chat shows a failure instead of a stopped run. Preserve cancellation, successful recovery, and replay ownership.

* test(codex): expect preserved provider failure after empty recovery

(cherry picked from commit b27c0b9)
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Oct 22, 2026
…ped with no explanation (openclaw#165488)

* fix(agents): preserve provider failures after settled finalization

Keep failed execution outcomes when tool-free finalization is unavailable or empty. Persist sanitized provider guidance under the existing transcript receipt, and publish native lifecycle error details so chat shows a failure instead of a stopped run. Preserve cancellation, successful recovery, and replay ownership.

* test(codex): expect preserved provider failure after empty recovery

(cherry picked from commit b27c0b9)
(cherry picked from commit 4dc785e)
Co-authored-by: RomneyDa <[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: codex gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. 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

Development

Successfully merging this pull request may close these issues.

1 participant