Repository navigation
fix(agents): a Codex turn that fails at the provider is shown as stopped with no explanation - #165488
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 6:16 AM ET / 10:16 UTC (Revision 2). ClawSweeper reviewWhat this changesPreserve 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 Review scores
Verification
How this fits togetherAgent 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +58, Tests +120, Docs +5. Total +183 across 7 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…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
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.
…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)
…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]>
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
errorwith sanitizederrorMessage/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
errorlifecycle carryingstopReason: "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 plusprojectChatErrorDetail(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
errorcontained"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".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 expectedcompleted-emptyand the generic successful fallback. The focused local run reproduced both failures (2 failed, 4 passed). Those assertions now expect the preservedfailedoutcome 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, andsrc/meeting-bot/runtime-facade-types.ts. This PR changes none of those owners. The remaining lint steps were run separately and passed.