Skip to content

fix: avoid duplicate CLI replies after a final message send - #194154

Merged
VACInc merged 5 commits into
openclaw:mainfrom
VACInc:fix/cli-completed-source-reply
Nov 6, 2026
Merged

VACInc merged 5 commits into
openclaw:mainfrom
VACInc:fix/cli-completed-source-reply

Conversation

@VACInc

@VACInc VACInc commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

High Level TLDR

Deliver a completed CLI answer once, even when the model rewrites it afterward. Keep automatic replies when other tool work still produces a result.

What Problem This Solves

A successful current-source message(action=send) can be followed by a differently worded automatic final. Text comparison misses the duplicate, including when final is omitted and defaults to true.

User Impact

A confirmed final source send supplies the answer once. Progress sends, other destinations, unsuccessful or unconfirmed sends, result-required internal turns, and subsequent tool work keep their existing reply paths. This includes a previously started parallel tool finishing before or after the final send completes.

Why This Change Was Made

Root Cause

Read-only inspection of the reported Claude CLI turn showed a successful source send followed seven seconds later by a rewritten final with the same report. Private transcript contents and identifiers are excluded.

The shared finality resolver defaults omitted final to true, but automatic CLI settlement previously depended on matching text. The deployed base 27ea834825c92c2f4a1de833bceb1a3b21a8de23 (2026.11.1), overlays #193550/#193775/#193899, and PR base d4ae77eae296fd8eb1f90f7a4ebb5d77fa2e6ad9 retain the affected behavior.

Track confirmed terminal source delivery explicitly. Only the current logical tool call can commit it; distinct tool starts or results invalidate it. A delayed CLI mirror of an already observed loopback result is not new work. Settlement still preserves raw/model text, delivery receipts, failures, interruptions, and private result obligations.

The unchanged internal-source classification helper moves to execute-messaging.ts; the settlement predicate lives in terminal-reply.ts. No runtime configuration, schema, provider, or transport changes. The existing executor matrix gains four overlap cases and a small callback hook, with a justified allocation for its exact 41 net test lines; no global baseline or assertion is relaxed.

Verification

Real behavior proof

The isolated proof exercises production CLI execution, loopback tracking, settlement, and reply-payload filtering with synthetic process/channel I/O:

node scripts/run-vitest.mjs src/agents/cli-runner/execute.supervisor-capture.test.ts --maxWorkers=1
  • 66/66 tests pass, 58.46s total, on c51720e409e9ce91530cf9fb6c13d8fcbdb86b44. Final head e2c5479eb872a563b04c44de21778077b451f4db changes only the allocation file; runtime and test code are identical.
  • Original duplicate-final regression fails against the PR base. Later-started overlap reproduces two failures against the incoming head; earlier-started failed-tool overlap reproduces two failures before the result-order correction. All four cases pass after correction.
  • Focused agents-root TypeScript validation passes. This repairs the indexed-access type error reported by the previous head's CI.
  • Test-line ratchet passes against the original merge base: 6,539,953 lines, ceiling 6,539,958. This repairs the previous head's missing allocation.
  • Full-context P0–P3 branch review of c51720e is scoped-clean with no actionable findings, including five complete owner modules. The allocation-only follow-up was separately inspected. Static review is not runtime proof.
  • Formatting and git diff --check pass; correction commits have verified signatures and the contributor co-author trailer.
  • Before merging, require green GitHub checks and resolution of actionable ClawSweeper concerns on the published head. See this PR's Checks and review history for their current state.

What was not tested

No live Telegram/model replay, deployment, or before/after performance measurement was performed. Local runtime evidence uses the production executor with synthetic I/O; it is not deployed-channel proof. Broader validation belongs to the exact-head GitHub checks, not an unstarted testing handoff.

@clawsweeper

clawsweeper Bot commented Nov 6, 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 agents Agent runtime and tooling size: S labels Nov 6, 2026
@VACInc
VACInc marked this pull request as ready for review November 6, 2026 13:51
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Suppress automatic CLI replies after confirmed final source delivery unless other tool work or a required private result still needs an answer.

Example: A CLI agent sends “Report complete” to source-chat with final omitted, then returns “The report is ready.”

  • Before: Both differently worded answers can reach the conversation.
  • After: Only the confirmed message-tool answer is delivered, unless intervening tool work requires the later result.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused repair with meaningful executor regressions and no identified defect; runtime confidence remains bounded by synthetic I/O.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence exercises production CLI tracking, settlement, and filtering with synthetic process/channel I/O, so the prior live-replay suggestion remains a confidence improvement.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users can receive two versions of an answer after a CLI agent already delivered its final answer through the message tool.
Reason: The maintainer-authored direction restores confirmed-final delivery semantics while preserving progress and subsequent-work outcomes.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses duplicate rewritten replies that current main still permits, and no actionable correctness or security defect was found in the reviewed head.

Priority: P2
Reviewed head: e2c5479eb872a563b04c44de21778077b451f4db

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A real CLI/channel replay showing one rewritten answer and a preserved result after overlapping tool work remains unshown.
Agent review details

How this fits together

CLI execution collects tool starts, results, and confirmed delivery receipts; terminal settlement converts those facts and model output into reply payloads for the existing delivery pipeline.

flowchart LR
  A[CLI model output] --> B[Tool event tracking]
  C[Loopback delivery receipts] --> B
  B --> D[Terminal reply preparation]
  D --> E[CLI run settlement]
  E --> F[Reply payload filtering]
  F --> G[Source conversation]
Loading

Technical review

Best possible solution:

Keep completion tracking in the existing CLI tool owner and suppress only redundant automatic output while preserving later work, failures, and private results.

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

Current-main settlement and downstream text deduplication expose the rewritten-final path; the PR reports a regression failing on its base, but this read-only review ran no target code.

Is this the best way to solve the issue?

The change uses existing tracking and settlement owners, reuses the canonical finality resolver, and adds focused ordering coverage without a competing delivery path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2808e34b4ad3.

Provenance checked

  • Automatic CLI final settlement and changed test expectations changes intended behavior with a stated reason (298546d: Preserve distinct final answers after earlier message sends by allowing route-scoped deduplication to decide.)
  • Receipt-only final source completion keeps the original intent (b5e1b21: Recognize confirmed external final delivery without requiring an internal UI mirror body.)
  • CLI tool tracking and moved internal-source classifier keeps the original intent (22226bf: Separate execution lifecycle from stateful tool and delivery correlation; the classifier moves without changing its checks.)
  • Terminal reply, silence, and private-result handling keeps the original intent (bd5f760: Separate authored silence, missing output, and required internal results through canonical terminal facts.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vito Cappello: Raw commit 298546d adds src/agents/cli-runner/execute.supervisor-capture.test.ts:1527 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 298546d88934; files: src/agents/cli-runner/execute.supervisor-capture.test.ts)
  • Vincent Koc: Raw commit b5e1b21 adds src/agents/cli-runner/terminal-reply.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b5e1b2137c51; files: src/agents/cli-runner/terminal-reply.ts)
  • Peter Steinberger: Raw commit c40f3ca adds src/agents/cli-runner/execute-tool-tracking.ts:276 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c40f3ca13352; files: src/agents/cli-runner/execute-tool-tracking.ts)

PR surface

Source +67, Tests +41, Other +5. Total +113 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 99 32 +67
Tests 1 46 5 +41
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 5 0 +5
Total 7 150 37 +113

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Duplicate answers affect CLI-backed conversation delivery, with a focused repair and limited scope.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted real CLI/channel replay showing one answer after a rewritten final and a preserved answer after overlapping tool work.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-06T14:07:13.522Z sha fa37066 :: needs changes before merge. :: [P2] Preserve intervening tool starts when committing a final send
  • reviewed 2026-11-06T15:06:33.201Z sha d370bde :: needs maintainer review before merge. :: none

Reviewed November 6, 2026, 10:24 AM ET / 15:24 UTC (Revision 3).

Only let the latest started tool commit terminal source-reply delivery. Preserve the fresh automatic result when another tool starts while a final message send is still settling. Cover overlapping explicit and default final sends in the existing executor matrix.

Co-authored-by: VACInc <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
Keep the existing length guard and use optional access for TypeScript noUncheckedIndexedAccess. The runtime decision is unchanged; the focused agents-root typecheck passes.

Co-authored-by: VACInc <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
roboclaw-bot and others added 2 commits November 6, 2026 15:13
Invalidate completed-source suppression when distinct tool results arrive, including results from tools started before the final send. Keep mirrored CLI results from invalidating later work. Cover both result orderings with failed-tool regression cases.

Co-authored-by: VACInc <[email protected]>
Account for the 41 net lines added to the existing executor matrix and its small overlap hook. The cases reproduce both start/result orderings; no global baseline or assertion is relaxed.

Co-authored-by: VACInc <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
@VACInc
VACInc merged commit 5310c71 into openclaw:main Nov 6, 2026
135 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 7, 2026
…#194154)

* fix: suppress duplicate CLI finals after completed source replies

* fix(agents): preserve tool ordering after final CLI sends

Only let the latest started tool commit terminal source-reply delivery. Preserve the fresh automatic result when another tool starts while a final message send is still settling. Cover overlapping explicit and default final sends in the existing executor matrix.

Co-authored-by: VACInc <[email protected]>

* fix(agents): narrow the latest loopback candidate safely

Keep the existing length guard and use optional access for TypeScript noUncheckedIndexedAccess. The runtime decision is unchanged; the focused agents-root typecheck passes.

Co-authored-by: VACInc <[email protected]>

* fix(agents): retain replies after earlier parallel tool results

Invalidate completed-source suppression when distinct tool results arrive, including results from tools started before the final send. Keep mirrored CLI results from invalidating later work. Cover both result orderings with failed-tool regression cases.

Co-authored-by: VACInc <[email protected]>

* test(agents): allocate parallel final-send regression coverage

Account for the 41 net lines added to the existing executor matrix and its small overlap hook. The cases reproduce both start/result orderings; no global baseline or assertion is relaxed.

Co-authored-by: VACInc <[email protected]>

---------

Co-authored-by: VACInc <[email protected]>
Co-authored-by: roboclaw-bot <[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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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.

2 participants