Repository navigation
fix(agents): avoid extra finalization after a source reply is delivered - #174948
Conversation
|
🦞👀 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. What this changesThis PR uses reconciled reply-delivery state to avoid an unnecessary finalization request after a source reply is delivered. Example: A rebuilt message tool sends “The result.” to refreshchat conversation C123 after a pre-dispatch refusal.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current-main mismatch between recorded delivery and finalizer admission. The production repair resolves the prior finding without weakening the two-attempt assertion; no actionable introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe embedded runner combines attempt delivery facts and optional delivery observations before deciding whether a settled tool turn needs a final model answer. flowchart TD
A[Settled embedded attempt] --> C[Canonical terminal preparation]
B[Optional delivery observer] --> C
C --> D[Reconciled delivery state]
D --> E[Finalizer admission]
E --> F[Finish delivered or pending turn]
E --> G[Recover missing answer]
Technical reviewBest possible solution: Use canonical prepared delivery state for finalizer admission while preserving missing-reply recovery and separate source-artifact custody. Do we have a high-confidence way to reproduce the issue? Current main exposes the path directly: absent observation resolves to missing, terminal preparation reconciles delivered attempt evidence, but finalizer admission still consumes the raw missing value; no target code was executed during review. Is this the best way to solve the issue? The repair belongs at the existing shared admission owner and reuses its canonical prepared fact, avoiding a second delivery policy or relaxed regression assertion. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 86ad4c4ec0bd. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests +666. Total +667 across 4 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 16, 2026, 11:29 PM ET / October 17, 2026, 03:29 UTC (Revision 2). |
|
@clawsweeper re-review Please review current head Disposition of the prior-head finding: the third finalizer is supported when delivery is genuinely missing, but the captured successor already returned Fresh exact-head CI is running. No repaired runtime pass or landing clearance is claimed yet. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…ed (openclaw#174948) * chore(agents): cover source reply receipts across deferred refresh * chore(agents): preserve real provider owners in refresh fixture * chore(agents): restore real refresh fixture lifecycle owners * chore(agents): expose early refresh fixture settlement * chore(agents): follow visible refresh fixture controls * chore(agents): use stable Responses fixture call IDs * chore(agents): expose refresh attempt ownership in assertions * fix(agents): avoid finalizing an already delivered source reply
What Problem This Solves
Fixes an unnecessary model finalization request after the message tool has already delivered the source reply.
Related: #119057
User Impact
An already-delivered reply should finish without generating another answer. Missing replies still recover, and pending delivery remains protected. No configuration, schema or protocol changes are required; this does not supersede the remaining work in the related PR.
Why This Change Was Made
Finalizer admission used the external observer's raw
missingresult even after canonical terminal preparation had reconciled committed message-tool delivery. It now consumesprepared.replyDeliveryState; source delivery and artifact filtering remain separate and unchanged. Eleven focused owner controls cover delivered, pending, missing and progress-only evidence, including absent observers and explicit observation conflicts.Two composition cases exercise ordinary source-turn admission, the real reply recorder and SQLite receipt, real embedded attempt execution and deferred runner handoff, then a distinctly rebuilt message tool:
already_deliveredwithout another send.The provider stream, transport, prepared runtime/plugin catalogs and auth are scripted fixture inputs. Harness selection, context-engine ownership, prepared tool authority, subscription, transcript persistence, finalization, Code Mode, delivery receipts and tool disposal remain real. Uncertain delivery outcomes, restart recovery and live channel/plugin installation are outside this test.
Evidence
f0eb0bb996d974b3f895f048e937da7f6c9fe9e6, tree997e3ae5a2336aebf7cfb596b89af57ac86144be. It preserves prior signed history and merges only the already-tested main input5b7749ae5bdbefbdb9cbc58778c20e3f8a181625, placing the fix in the extracted canonical helper. The two-attempt assertion is unchanged; no fixture delivery observer or extra-attempt allowance masks the failure.849b20dd4c3ef6f9fbd20d2d1cbe9c609ed92ae3with main parent7d3a763f92e2febeeacd943597673600b4bb17c3. Both real composition cases passed in job117296468336, including the unchanged strict two-attempt and receipt/effect/drain assertions; all 11 new owner controls passed in job117296468266, alongside existing finalization controls. Generation cleanup and shard exit 0 were verified. Production/test types, selected lint and ratchets passed. An independent reviewer consumed the actual retained case records, not just aggregate status.already_deliveredresult. Post-fix scripted provider-call counts and operation identities were not emitted on passing tests and remain unreported rather than inferred.8aa3a96bb934ef4fde4377c69e138fda665e175e, merge83ec4c138a1e89159ee0df37a224c0b03e748dd2, main parent5b7749ae5bdbefbdb9cbc58778c20e3f8a181625. Confirmed delivery passed. Refusal passed distinct rebuilt-tool execution after old-attempt drain, cleared reservation, one physical effect, committeddelivered-terminalreceipt, one original user message and drained Code Mode runtime; it then failed solely at three successful attempts versus two. Immutable successor facts already recorded final source delivery. The third operation was tools-disabledsettled-tool-finalization, not a repeated send. Refusal accounting: 4 scripted provider calls, 2 message-tool calls on distinct instances, 2 transport calls and 1 physical effect. Production/test types, selected lint and ratchets passed. These are deterministic fixture counts, not a live-model benchmark.it.forcontract, with incremental review of the correction.040ce3a7: https://github.com/openclaw/openclaw/actions/runs/38992225698. Both cases failed before transport because the fast provider mock omitted an export consumed by the real attempt. Production/test types and general/core/plugin lint passed. The correction restored the real provider runtime, provider handles and runtime-plan builder locally, and preserved the plugin-tools module exports.902d1c07: https://github.com/openclaw/openclaw/actions/runs/38993038026. Both cases again failed before transport, at the fast context-engine registry mock. A complete review of the active base/fast mock graph also found that mocked harness selection bypassed logical-turn initialization and prepared tool authority. The coherent correction restored context initialization, registry and harness selection together, retaining the real-attempt observer. Independent review verified the exact correction and unchanged assertions/cleanup.2988497fff8d: https://github.com/openclaw/openclaw/actions/runs/38993812435. Both cases resolved before the parked-refresh gate; the helper did not expose the returned semantic result. Production/test types and general/core/plugin lint passed. The independently reviewed diagnostic correction preserved original rejections, expectations, timeouts and cleanup.1e2602170842: https://github.com/openclaw/openclaw/actions/runs/38994648295. Both cases failed with normalok/stopsettlement: one real message invocation and transport call, but the scripted provider selected final instead of waiting. The real provider boundary strips private tool-result details and may append runtime context after a result. The corrected fixture matches the prior call ID and parses its visible JSON control; only a successfulwaitingresult with its returned top-level run ID permitswait, and only completed prior work permits a new-generationexec. Production/test types and general/plugin lint passed; core lint found an unsafe diagnostic string coercion, now limited to Error/string values. Independent review accepted the exact correction.89f5c6057f0b: https://github.com/openclaw/openclaw/actions/runs/38995717965 tested merge9b2f652f26e99879d713f2fd9c11c9994030fa7awith main parent9dd47e67ded4986aabe211c62b5c26fc9eec0299. Both cases failed at the strict result-ID assertion before deferred refresh parked. Source inspection confirmed that the Responses normalizer rewrites the fixture's invalidcall-IDs in both assistant calls and tool results. The correction emits validcall_IDs and also requires the matching provider-visible assistant call ID/name before the existing exact result/control checks. Independent review accepted the exact correction; production/test types and selected lint passed on that prior input.a9bf3fcbaa8b: https://github.com/openclaw/openclaw/actions/runs/38996416401 tested merge3a8f7918785a1998ca7d53f76a1cd5b610107dacwith main parenta5959e02d46c5551bc2dc4bc92f7e459c99741a8. The confirmed-delivery composition passed, including the rebuilt tool'salready_deliveredresult and exactly one effect. The refusal case returned without a semantic error but failed at three successful attempts versus the expected two; later receipt/effect checks did not execute. Production/test types, selected lint and ratchets passed. The subsequent independently reviewed diagnostic-only update recorded actual invocation operation/tool restriction and immutable return facts, and moved unchanged domain assertions before the unchanged attempt-count assertion; its determining evidence is recorded above.update-command-service-maintenance-native.test-support.tsmock-export violation in their merge inputs. The ratchet passed on the89f5c6057f0bmerge input; this PR did not change that fixture or waive its check.git diff --checkpassed. Main-relative production delta: +3/-2 (net +1, including two invariant-comment lines); tests and registration: +666. No build/package/import boundary changed.Focused files:
src/agents/embedded-agent-runner/run.plugin-runtime-refresh-delivery.integration.test.tsandsrc/agents/embedded-agent-runner/run/settled-turn-finalization.test.ts, plus existing selected finalization/delivery siblings. Normal exact-head PR CI is the admitted execution route.