Repository navigation
fix(agents): recover final summaries after transient post-tool failures - #138362
Conversation
Record producer-owned error payload provenance so generated provider errors do not suppress isolated tool-free finalization after completed tool work. Preserve structured refusals, delivery, async, cancellation, and silence gates. Co-authored-by: VACInc <[email protected]>
Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]> OpenClaw-Publication: cf00ce96-8d54-4618-bff4-5c73f8a82b44
|
🦞👀 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. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The producer-side provenance is the right missing fact. Discounting only a payload explicitly marked terminalProviderError lets settled-tool finalisation proceed without shape-based guessing, while structured refusals, tool errors/presentations and prior authored output remain terminal. The no-replay and failure-honest fallback cases cover the risky boundary.
|
Codex review: blocked before merge. Reviewed September 4, 2026, 1:43 PM ET / 17:43 UTC. ClawSweeper reviewWhat this changesThis PR marks generated terminal provider-error payloads so completed embedded tool runs can use the existing tool-free finalizer after a transient post-tool model failure. Merge readiness⛔ Blocked before merge - 3 items remain Keep open. Current main still counts the generated provider-error payload as a reply, so the isolated finalizer cannot run; this patch corrects that narrow eligibility gap without a new correctness or security finding. The protected Priority: P2 Review scores
Verification
How this fits togetherThe embedded agent runner turns model and tool activity into reply payloads for delivery. After all tools settle, its finalizer may make one tool-free request for a summary while preserving cancellation, delivery, media, and unsafe-replay safeguards. flowchart LR
U[User turn] --> R[Embedded agent runner]
R --> T[Completed tool work]
T --> E[Transient final model error]
E --> P[Reply payload preparation]
P --> G{Settled-turn eligibility}
G -->|eligible| F[Tool-free finalizer]
G -->|not eligible| O[Existing error or fallback]
F --> O
Decision needed
Why: The PR is labeled Before merge
Agent review detailsSecurityNone. PR surfaceSource +5, Tests +523. Total +528 across 6 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep this producer-to-owner repair as the sole path: mark only generated terminal provider errors privately, then let the existing guarded tool-free finalizer decide whether a summary is safe. Do we have a high-confidence way to reproduce the issue? Yes. Current main visibly counts the generated provider error as a payload, and the added exact-head loopback test defines a focused transient-503, completed-tool reproduction path; this read-only review did not execute it. Is this the best way to solve the issue? Yes. Recording provenance at the payload producer and consuming it in the existing recovery owner is narrower and safer than inferring generated warnings from their visible shape or replaying the entire turn. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9f1c8a1c58bd. LabelsLabel 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)
|
Keep the real HTTP 503 and no-replay proof while consolidating fixtures and removing mocked backend scaffolding. Test non-transient classification at the actual context producer instead of manufacturing a missing context. Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]>
Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]> OpenClaw-Publication: f762ae96-6ea6-419b-96dd-18307295512e
…es (openclaw#138362) * fix(agents): finalize settled work after transient provider errors Record producer-owned error payload provenance so generated provider errors do not suppress isolated tool-free finalization after completed tool work. Preserve structured refusals, delivery, async, cancellation, and silence gates. Co-authored-by: VACInc <[email protected]> * fix(agents): recover final summaries after transient post-tool failures Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]> OpenClaw-Publication: cf00ce96-8d54-4618-bff4-5c73f8a82b44 * test(agents): streamline settled finalization coverage Keep the real HTTP 503 and no-replay proof while consolidating fixtures and removing mocked backend scaffolding. Test non-transient classification at the actual context producer instead of manufacturing a missing context. Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]> * fix(agents): recover final summaries after transient post-tool failures Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]> OpenClaw-Publication: f762ae96-6ea6-419b-96dd-18307295512e --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: VACInc <[email protected]>
Closes #126848 — settled tool work loses its final summary after a transient provider failure.
What Problem This Solves
Fixes an issue where users whose tool work had already completed would receive only a provider-connection error when the final model request failed transiently. This addresses VACInc’s September 4 reopening evidence, not the already-merged context producer in #128840.
Why This Change Was Made
Record generated provider-error provenance at payload creation in existing private reply metadata, then discount only generated plain error surfaces for isolated finalization eligibility. Reuse existing tool-warning provenance instead of identifying tool warnings by shape alone. Prepared payloads remain untouched whenever recovery is rejected.
The canonical finalizer still owns the tool-free request and the failure-honest fallback from #133520. Exact current-batch settlement, captured recovery context, prior final delivery/media, async work, cancellation, and tool presentations retain their gates. Structured provider refusals and ambiguous/previously-produced output are explicitly terminal. Cron tool-authored silence is evaluated after the effective payload count is known.
No whole-turn replay, new retry family, provider/model/error-string special case, config, schema, or protocol change. Production delta: +5 lines across three files. The small growth records a missing producer fact and preserves the terminal-error boundary; shape-only warning inference and duplicated count branching are removed. Tests/test support: +461/-5 lines (net +456) after consolidation, separate from production.
User Impact
Completed work can reach the existing tool-free finalizer and produce a truthful summary instead of only a generated connection-error reply. Completed tools are not executed again. If finalization fails, the existing honest settled-work fallback remains available.
Co-authored with @VACInc, who supplied the live report, composition diagnosis, and repair/coverage requirements.
Evidence
{"httpRequests":3,"requestToolCounts":[1,1,0],"toolExecutions":1,"persistedToolResults":1,"finalAnswerPayloads":1,"additionalTranscriptAnswers":1,"wholeTurnReplays":0}The loopback uses a synthetic provider identity to avoid unrelated bundled-plugin discovery; the wire transport, agent loop, persistence, payload preparation, finalization eligibility, and core finalization boundary are real. It is not a live external-provider or channel-delivery test. The existing producer integration test is also included; the loopback supplies its settled-context fixture explicitly.
node scripts/check-changed.mjsplan, including core-test typecheck and all dead-export scans.Focused validation used
node scripts/run-vitest.mjsfor the provider-error, HTTP transport, finalizer, unavailable-finalizer, settled-tool-evidence, context-producer, payload-errors, structured-refusal, and outer provider-failure suites.Named follow-up: a separate raw-socket-reset probe lost transient classifier evidence when the Responses SDK projected a generic connection error. This PR fixes the reported prepared-payload composition for an already-captured transient failure; it deliberately does not broaden upstream transient-error classification or retry policy.
Sibling contract inspection: the existing native harness capture remains unchanged. Inspected upstream Codex codex-rs/protocol/src/protocol.rs:2062-2080,2140-2147 and codex-rs/app-server-protocol/src/protocol/v2/turn.rs:27-36 at 986ff1cc7ced for independent error/completion and interrupted/failed status contracts.
Test consolidation requested by Vito
588f90ec9344e123ff645eafe1d3341fbc304ee6. The exact-head rollup watcher also completed GREEN (exit 0, zero pending checks). Publication metadata commit and tested cleanup commit share tree095a3b15203fad77fbb3a4a6e079c73cfb7bc15d.Review follow-up — September 4, 2026
Original implementation CI passed: CI run 33889653398, head 1a6c543. The subsequent cleanup changes tests only; updated-head CI is tracked above.
ClawSweeper’s latest durable review, reviewed September 4 at 17:43 UTC against
1a6c543f3663ca555ac1a170bec54f401907a433, reports no correctness or security findings, sufficient proof, and high confidence. It recommends ordinary maintainer review rather than automated merging. This is a review of the original implementation, not an exact-head review of the subsequent test-only cleanup.Its current remaining items are explicitly retained, not treated as waived:
The fresh independent P0–P2 review of the cleanup is scoped-clean. No separate actionable
Rank-up moves:list is present in the latest durable review.The parallel PR #138353 was closed at Vito’s request in favor of this canonical repair. VACInc’s co-author credit is preserved in the original commits and the test-consolidation commit.
Worked on by:
Co-authored-by: VACInc [email protected]
Team session
Worked on by
View the OpenClaw team session