Repository navigation
fix(agents): count explicit-route current-source sends as source replies (embedded/app-server path) - #114680
fix(agents): count explicit-route current-source sends as source replies (embedded/app-server path)#114680zeroaltitude wants to merge 4 commits into
Conversation
…ies in the embedded/app-server dispatch path App-server harnesses (claude-bridge, and any other non-CLI-runner harness) route tool calls through embedded-agent-subscribe.handlers.tools.ts rather than cli-runner/execute.ts. Its call to isDeliveredMessageToolOnlySourceReplyResult() never passed allowExplicitSourceRoute, so an explicit-route `message` send that actually reached the current source conversation was rejected as source-reply evidence -- tripping stranded-reply recovery and duplicating/failing the reply -- even though nothing went wrong. This is the embedded-path sibling of openclaw-kg9, which only patched the CLI runner. Add embeddedSendResolvesToCurrentSource(), mirroring kg9's cliSendResolvesToCurrentSource(): resolve the send's destination through the same extractMessagingToolSend() path used for delivery evidence, and compare it to what the same action would resolve to with no explicit route. Both resolutions go through the existing applyCurrentMessageProvider() current- channel injection so they can't drift on provider even when the agent's send omits it. When they match, allowExplicitSourceRoute lets the delivered send count as source-reply evidence; a route that resolves elsewhere still fails safe and lets stranded-reply recovery fire for real outbound side effects. Fixes openclaw-p3j (root-caused by Tabitha, 2026-07-27, Discord #openclaw).
|
Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 12:07 AM ET / 04:07 UTC. ClawSweeper reviewWhat this changesThe branch resolves explicit embedded/app-server Merge readiness⛔ Blocked until real behavior proof is added - 8 items remain This PR targets a real embedded delivery-evidence gap, but the existing P1 blocker remains: it treats sends as replies based only on provider and target, even though the shared resolver also distinguishes account and thread routing. It also still needs redacted after-fix embedded/app-server proof before merge. Priority: P1 Review scores
Verification
How this fits togetherEmbedded agent tool events turn model flowchart LR
A[Embedded app-server tool event] --> B[Message send arguments]
B --> C[Resolve delivery destination]
C --> D[Compare active source route]
D --> E[Source-reply evidence]
E --> F[Normal completion or recovery]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +88, Tests +189. Total +277 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Compare the complete resolved send identity using the canonical messaging-send representation, including account and thread semantics, cover non-source account/thread cases, and then prove the repaired embedded/app-server flow with redacted runtime output. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main rejects explicit routes in this embedded call path without trusted route evidence, and the proposed helper can be inspected with same-target/different-account or thread inputs. A live app-server reproduction has not been supplied. Is this the best way to solve the issue? No. The route-equivalence check is incomplete because the canonical resolver includes account and threading fields that the PR does not compare; the fix should reuse or compare the full resolved destination contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b653597020d3. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
…ite-#3 A separately-dispatched session opened openclaw#114680 for the same defect (embedded-agent-subscribe.handlers.tools.ts's isDeliveredMessageToolOnlySourceReplyResult call missing allowExplicitSourceRoute) before this branch's fix for the same call site landed here, then openclaw#114680 was merged into origin/integration. Landing both would leave two different implementations touching the same lines. Revert this branch's embedded-agent-subscribe.handlers.tools.ts (+ test) changes back to their pre-fix state, since openclaw#114680's embeddedSendResolvesToCurrentSource already covers that call site and is deployed. Keep everything else from this branch's embedded-agent work: messagingToolSendResolvesToCurrentSource (embedded-agent-subscribe.tools.ts) and its wiring into message-tool-terminal.ts's installMessageToolOnlyTerminalHook (call site #3, the native agent-loop afterToolCall terminal hook) — openclaw#114680 never touched that file, so it's still a real, unfixed gap this branch closes. Net result: this branch now covers the original CLI-runner fix (openclaw-kg9) plus call site #3 only; openclaw#114680 covers call site #1. No overlap, no duplicate implementations of the same check. Beads: openclaw-yob
…eply-explicit-route
…eply-explicit-route
…eply-explicit-route # Conflicts: # src/agents/embedded-agent-subscribe.handlers.tools.ts
|
Closing as a duplicate of #113554. #113554 is the older same-author branch and already owns the CLI runner plus both embedded-agent send-resolution surfaces covered here. Keeping both open would split one invariant across overlapping implementations. The canonical branch still needs repair before landing: explicit-route reply accounting must compare the full effective route, including provider/account, destination, thread, and suppression state. This close is consolidation, not a claim that the underlying bug is fixed. |
What problem this solves
App-server harnesses (
claude-bridge, and any other non-CLI-runner harness —isCliProvider()returns false for them since their model provider is the vendor id, not a registered CLI backend) route tool calls throughembedded-agent-subscribe.handlers.tools.tsrather thancli-runner/execute.ts. Its call toisDeliveredMessageToolOnlySourceReplyResult()never passedallowExplicitSourceRoute, so an explicit-routemessagesend that actually reached the current source conversation was rejected as source-reply evidence — tripping stranded-reply recovery and duplicating/failing the reply — even though nothing went wrong.This is the embedded-path sibling of #113554 (openclaw-kg9), which patched the same gap in the CLI runner only. Root-caused live in production: agents running on the Claude app-server harness were genuinely sending replies (confirmed via provenance logs,
message.sendcalls withTOOL_TAINT_EVAL: message.send(trusted)), but[source-reply/private-final]still fired and users saw "I generated a reply but could not deliver it to this chat."See also #103927, a related but distinct sibling in the direct reply-agent and queued-followup-retry paths (
src/auto-reply/reply/agent-runner.ts,followup-runner.ts) — different dispatch surface, same defect family, not a duplicate of this PR's files.Fix
Add
embeddedSendResolvesToCurrentSource()(new file,embedded-agent-send-resolution.ts), mirroring kg9'scliSendResolvesToCurrentSource(): resolve the send's destination through the sameextractMessagingToolSend()path already used for delivery evidence, and compare it to what the same action would resolve to with no explicit route. Both resolutions go through the existingapplyCurrentMessageProvider()current-channel injection (now exported) so they can't drift on provider even when the agent's send omits it. When they match,allowExplicitSourceRoutelets the delivered send count as source-reply evidence; a route that resolves elsewhere still fails safe and lets stranded-reply recovery fire for real outbound side effects.Testing
execute-messaging.test.tscoverage shape.embedded-agent-subscribe.handlers.tools.test.ts: an explicit-route send to the current source now registersmessageToolOnlySourceReplyDelivered; an explicit-route send to a different conversation still correctly does not (fail-safe preserved).tsgo:core,tsgo:core:testclean.oxlint,config:schema:check,git diff --checkclean.Fixes openclaw-p3j (root-caused by another agent session, 2026-07-27).
Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude).