Repository navigation
fix(agents): prevent duplicate recovery after explicit source replies - #113554
vincentkoc merged 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 4:55 PM ET / 20:55 UTC. ClawSweeper reviewWhat this changesThe branch makes explicit, successfully delivered message-tool sends count as replies to the active conversation only when provider, account, target, and thread match across CLI loopback, embedded terminal, and subscription completion. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessNo blocking findings. The PR routes all three completion paths through the existing exact current-source delivery predicate, and its real Gateway/Teams proof covers both suppression and off-route recovery; it remains useful because current main still lacks this route verification. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherMessage-tool-only runs can send a visible reply through a channel tool, after which recovery decides whether another reply is needed. The changed paths convert confirmed send evidence into a canonical source-route decision before that recovery runs. flowchart LR
A[Message tool send] --> B[Confirmed delivery result]
B --> C[Canonical source-route check]
C --> D{Matches active conversation?}
D -->|yes| E[Record source reply]
D -->|no| F[Keep recovery eligible]
E --> G[Suppress duplicate reply]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +121, Tests +204. Total +325 across 11 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the canonical adapter after the clean GitHub merge and exact-head delivery checks confirm the existing mismatch matrices and Gateway scenario remain green. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: current main rejects explicit routes in CLI, terminal, and subscription completion because those callers provide no verified explicit-source route. Is this the best way to solve the issue? Yes—the branch reuses the authoritative delivery matcher and passes prepared route facts through each owner path rather than maintaining parallel partial matchers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d0db8a9241bc. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (14 earlier review cycles; latest 8 shown)
|
Round updateExtended this PR to the whole defect class (openclaw-p3j) and addressed the outstanding finding:
What's new in this roundExtended the openclaw-kg9 fix (CLI-runner only) to the two embedded-agent call sites with the same gap:
Added Result:
Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
|
Reconciled with #114680 (a separately-dispatched fix for the same defect that landed and merged into our integration branch first):
This branch now covers: the original CLI-runner fix (openclaw-kg9) + call site #3 only. #114680 covers call site #1. No overlap. Re-validated after the revert: Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude). |
Use the canonical delivered current-source matcher for CLI, terminal, and subscription completion paths. Preserve provider, account, target, and thread identity so only the active source route suppresses stranded-reply recovery. Punchcard-Session: golden-river-workshop-vj
beac8aa to
11413bc
Compare
|
@clawsweeper re-review Exact-head rewrite is now at The previous rank-up moves are addressed: one canonical full-route adapter, prepared account/thread context, CLI + terminal + subscription wiring, production net |
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Merged via squash.
|
Use the canonical delivered current-source matcher for CLI, terminal, and subscription completion paths. Preserve provider, account, target, and thread identity so only the active source route suppresses stranded-reply recovery. Punchcard-Session: golden-river-workshop-vj Co-authored-by: Edward Abrams <[email protected]>
What Problem This Solves
Fixes an issue where
message_tool_onlyruns could post a reply successfully and then post it again through stranded-reply recovery when the message tool explicitly named the current conversation.The failure affected three completion paths: CLI loopback, the embedded terminal hook, and embedded subscription completion. A send to another account, thread, or target must still remain off-source so recovery can deliver the actual source reply.
Why This Change Was Made
All three paths now adapt their confirmed message send into the existing canonical
isDeliveredCurrentSourceReplycontract. The decision therefore uses the prepared provider, account, target, session, and thread facts instead of maintaining partial route matchers.The rewrite does not pass signed capabilities into CLI subprocesses, synthesize trusted delivery annotations, or change authorization, configuration, SDK, protocol, or session-lifecycle policy.
Architectural closeout:
src/infra/outbound/source-reply-mirror.ts.MessagingToolSendevidence toisDeliveredCurrentSourceReply.+149/-28, net+121, across 8 production files.User Impact
An explicit
message(action=send)to the active conversation now suppresses stranded-reply recovery exactly once. Sends to a different account, thread, or target do not suppress recovery.Evidence
Current-main regression proof before the rewrite:
Focused proof on rewritten head
11413bc0a8feb0cb0586b2674d552c9881d40365:node scripts/run-vitest.mjs src/agents/cli-runner/execute.supervisor-capture.test.ts: 58 passed.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/message-tool-terminal.test.ts: 22 passed.node scripts/run-vitest.mjs src/agents/embedded-agent-subscribe.handlers.tools.test.ts: 174 passed.node scripts/run-vitest.mjs src/infra/outbound/source-reply-mirror.test.ts: 3 passed.git diff --check: passed.oxfmt --checkon all 11 changed files: passed.check:changed: passed all guards, Knip, core/core-test typecheck, lint, import-cycle, database-first, and pairing gates.Mock-gateway boundary proof:
{ "scenario": "msteams-thread-message-tool-final-dedupe", "providerMode": "mock-openai", "channelDriver": "live", "channel": "msteams", "runner": "host", "passed": 1, "failed": 0, "skipped": 0, "head": "11413bc0a8feb0cb0586b2674d552c9881d40365" }The scenario exercises the real Gateway and bundled Microsoft Teams plugin with a loopback Bot Framework connector. It verifies one delivery for the same source thread and preserves recovery for a different thread and different conversation, plus direct-message and group-chat cases.
Contributor credit is preserved: the rewritten commit is authored by Edward Abrams (
@zeroaltitude).Punchcard-Session: golden-river-workshop-vj