Repository navigation
fix(agents): stop duplicate replies after terminal question delivery failures - #126603
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Land-ready proof for exact head
|
|
Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 4:50 AM ET / 08:50 UTC. ClawSweeper reviewWhat this changesThe PR records a verified terminal tool batch as an intentional no-reply completion, preventing Telegram control-delivery failures from triggering retries, fallback replies, or cron/follow-up empty-result errors. Merge readinessKeep this maintainer-owned PR open for exact-head CI and a maintainer proof-sufficiency decision. Static review found the terminal-owner repair coherent and no blocking code defect. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe embedded agent runner turns model and tool activity into a terminal result. Auto-reply, queued follow-ups, cron, and model fallback consume that result to decide whether another user-visible message is needed. flowchart LR
A[Model tool batch] --> B[Embedded agent runner]
B --> C[Exact terminal evidence]
C --> D[Completion result]
D --> E[Model fallback]
D --> F[Reply and follow-up delivery]
D --> G[Cron finalization]
Decision needed
Why: The patch deliberately suppresses fallback output across multiple delivery consumers, and the PR body describes but does not publish the claimed verdict artifact; a maintainer must set the acceptable proof bar for this protected PR. Before merge
Agent review detailsSecurityNone. PR surfaceSource +40, Tests +178. Total +218 across 19 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Mantis proof suggestionA Telegram Desktop transcript would directly show that a visible streamed question with failed control attachment does not produce duplicate chat output. A maintainer can ask Mantis to capture proof by posting this exact PR comment: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one terminal-owner completion fact and attach a redacted current-head adapter-harness verdict showing the visible-preview/control-edit-failure path has one final outcome and no continuation or fallback. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main’s class-instance check rejects an equivalent error from a separately loaded module, and the changed regression test models that path; no live run was executed during this read-only review. Is this the best way to solve the issue? Yes: recording one narrowly proven completion fact at the embedded-run terminal owner is safer than teaching each fallback consumer to infer delivery state independently. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 69d30286eb52. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Related: #126248 (merged Telegram streamed-question finalization; provenance only).
What Problem This Solves
Fixes an issue where users responding to a streamed interactive Telegram question could receive a spurious failure warning, duplicate fallback reply, or unnecessary model continuation after the question preview became visible but attaching its controls failed. The same terminal-tool completion was also incorrectly reported as a failed empty response in queued follow-ups and scheduled runs.
Why This Change Was Made
Classify reply-dispatch delivery errors by a stable error code and a closed set of delivery outcomes so their identity survives separately loaded runtime bundles. At the embedded-run terminal owner, prove that the exact current-turn tool-call batch settled successfully, belongs to the right calls and tool owners, contains only intentional terminal tools, and has no failed, asynchronous, stale, reused, mixed, or prior-turn evidence; record that single closed completion fact once and share it with model fallback, direct/follow-up auto-reply, and cron consumers.
The completion fact means only that an exactly proven terminal tool batch intentionally ended the turn. It does not assert visible delivery, silence, authority, or authorization, and existing fail-closed delivery evidence remains unchanged.
User Impact
Streamed Telegram questions continue using the same preview message and receive one final response after a successful answer. If question controls cannot be attached after the preview is already visible, OpenClaw cancels the pending question cleanly without retrying the model, emitting a misleading warning, sending duplicate fallback text, or deleting the visible preview. Equivalent queued follow-up and scheduled-agent turns no longer misreport this intentional completion as an empty-response failure; accidental empty turns still surface their existing errors.
Evidence
Rebased cleanly onto current
mainwith an identical patch (git range-diffreports=); the merged-base pre-aborted-delivery regression and this fix's cross-bundle delivery regression both remain present. Scope: 19 files; production +130/-90 (net +40), tests +223/-45 (net +178). The production growth is the minimum shared ownership contract needed to prove one exact terminal tool batch once and make its closed completion fact available to model, auto-reply, follow-up, and cron consumers. No protocol, configuration, schema, generated/baseline, changelog, or dependency changes.Five focused commands passed across 10 files and 306 tests (the previous 305 plus the new pre-aborted-delivery regression already present on rebased
main):Pre-rebase deterministic real-plugin/adapter proof used the actual Telegram adapter, Crabline transport, ephemeral Gateway, local Telegram API doubles, and a mock model provider: 1/1 scenario and 3/3 steps passed. It proved direct-message topic routing with
direct_messages_topic_id=77and nomessage_thread_id; a streamedask_userquestion stayed on one message lifecycle and produced exactly one final answer; an injected control-edit failure produced one preview send, one rejected edit, a non-error terminaldelivery_failedresult, zero provider continuations/warnings/fallback replies/deletes, a cancelled question, and zero pending questions.That disposable scenario is not tracked in Git and was not rerun after rebase. Its recorded source patch SHA-256 is
6b4bb58b0d8a57384d143768ccc2fe0fc7a3965c5f627e1696205978da513841, exactly matching the original committed patch;git range-diffindependently proves the rebased patch is identical. Local-only proof summaries are under.artifacts/qa-e2e/telegram-final-19-f289685/, includingverification-summary.json,harness-metadata.json, andchannel-proof/telegram-routing-interactive-finals-verdict.json; raw artifacts and secrets are not published.Known proof limitation: authenticated Telegram Desktop and Discord live credentials were unavailable. The channel proof exercised real OpenClaw plugins/adapters and Crabline with local channel API doubles and a mock provider; it was not an authenticated live Telegram or Discord run.
AI-assisted; maintainer-reviewed implementation and proof.