Repository navigation
Conversation
…sult + final_only tool text)
…fter parent ends; closes catalog openclaw#1 + openclaw#15
|
Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 11:41 PM ET / 03:41 UTC. Summary PR surface: Source +192, Tests +615, Docs +1. Total +808 across 8 files. Reproducibility: yes. at source level, but not live-reproduced here. Current main still sends ACP direct deliveries through the dispatcher path without this bind-aware fallback, and the PR body gives a concrete Telegram supergroup reproduction path. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Refresh or replace the branch with a narrow fix that reuses route projection for bound delivery, repairs visible-delivery accounting, covers parentConversationId/topic bindings in tests, and includes redacted live Telegram proof. Do we have a high-confidence way to reproduce the issue? Yes at source level, but not live-reproduced here. Current main still sends ACP direct deliveries through the dispatcher path without this bind-aware fallback, and the PR body gives a concrete Telegram supergroup reproduction path. Is this the best way to solve the issue? No. The PR is a plausible repair direction, but the best fix should reuse existing channel route projection, keep topic/thread delivery intact, and prevent fallback-delivered visible text from replaying at finalization. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9d68f877ac3e. Label changesLabel justifications:
Evidence reviewedPR surface: Source +192, Tests +615, Docs +1. Total +808 across 8 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
… TTS, requester-scoped
|
Rework landed in commit [P1] Real-failure trigger (was: [P2] TTS preservation for final-only output (was: [P3] Requester-scoped routing, fail closed on ambiguous bindings (was: loop all bindings, broadcast) Test results: 4/4 targeted GREEN, 1539/1539 adjacent suite GREEN. Re-review progress:
|
|
This PR adds a bind-aware ACP delivery fallback for spawn-child turns after the parent dispatcher starts failing, plus changes final-only ACP text flushes back to Findings:
By: Eduardo Piva (@efpiva, acct 2014-01-13) | OpenClaw: 17 PRs, 1 issue, 10 commits/12mo | GitHub: 13 repos, 10 commits, 17 PRs, 1 issue, 0 reviews Verification: Best-fix verdict: good direction, but not ready to merge until bound conversation delivery uses the channel target contract and the failed-visible-block path is covered/fixed. |
galiniliev
left a comment
There was a problem hiding this comment.
Requesting changes for the two routing/delivery issues below.
-
Blocking:
src/auto-reply/reply/bind-aware-dispatch.ts:85routes bound replies withto = binding.conversation.conversationIdand never passesparentConversationId/threadId. That bypasses the channel delivery-target contract used elsewhere. For Telegram forum/current-conversation bindings, records can be{ conversationId: "2", parentConversationId: "-1003342490704" }, and the Telegram plugin converts that to{ to: "-1003342490704", threadId: "2" }inextensions/telegram/src/channel.ts:388. This fallback would instead callrouteReplywithto: "2", so the real supergroup topic case can still fail or misroute. Use the existing delivery-target resolver path, assrc/agents/subagent-announce-delivery.ts:153does, and add a regression covering the parent-conversation shape. -
Likely blocking:
src/auto-reply/reply/dispatch-acp-delivery.ts:458triggers fallback from any prior failed dispatcher count, butfinalizeAcpTurnOutputstill treats priorblock/finaldispatcher failures as visible-delivery failure atsrc/auto-reply/reply/dispatch-acp.ts:216and sends the accumulated visible text fallback atsrc/auto-reply/reply/dispatch-acp.ts:267. If the first post-teardown payload is atext_deltablock, later bind-routed live blocks can be delivered in real time and then repeated as one final end-of-turn block. The new test only seedsfailedCounts.tool = 1, so it misses this production-plausiblefailedCounts.block = 1path.
Verification: pnpm test src/auto-reply/reply/dispatch-acp.spawn-child-delivery.test.ts passed on PR head 78dcde5582fa. gitcrawl was unavailable, so I used live gh and source review.
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the contribution. I’m closing this branch because the fallback bypasses the established delivery projection, visible blocks can replay at finalization, the branch conflicts with current |
Summary
Spawn-child ACP turns produced zero outbound channel deliveries until end-of-turn — the projector's deliver callback was tied to the parent run's dispatcher, which tore down ~10s in while the child kept running for minutes. Build a bind-aware fallback that consults the session binding service and routes directly to the bound conversation when the parent dispatcher's async transport starts failing. Closes catalog #1 + #15.
Bug detail
In a Telegram supergroup, the parent agent calls
sessions_spawn(placement: "child"), ends its turn ~10s later, copilot child runs for 2-5 minutes producing events. WS clients see the events stream live; Telegram outbound channel sees nothing until end-of-turn, when one consolidated block arrives. The dispatcher's lifecycle was bound to the parent's run — once that ended, the underlying outbound transport failed asynchronously and subsequent payloads silently dropped.How to reproduce
Live repro before fix (in a Telegram supergroup with the bot):
Watch:
Unit-level:
Root cause
delivery.delivercallback closes over the parent's run dispatch context. When the parent's run completes, the parent's dispatcher's async transport fails. Subsequent calls (sendToolResult,sendBlockReply, ...) queue on the dispatcher but thesendChain.catch()handler incrementsfailedCounts. There was no fallback that consulted the session binding service to route to the bound conversation.Fix approach (rework — addressed 3 bot findings)
[P1] Real-failure trigger for bind-aware fallback
Previous (incorrect) trigger:
!deliveredaftersend*()returningfalse. In production,send*()returnsfalseonly when the payload normalizes to empty — not when the parent run ends. Real parent-teardown failures are recorded asynchronously infailedCountsafter thesendChainrejects.New trigger: Before each call to
send*()indispatch-acp-delivery.ts:deliver(), checkgetFailedCounts(). If the dispatcher's async transport has already failed (totalblock + final + toolfailures > 0), route directly to the session binding instead of queuing more payloads on the failing dispatcher.This matches the real production failure mode: the first payload after teardown is enqueued (returns true), the
sendChainrejects,failedCountsincrements; all subsequent payloads see the failure and go to bindings.[P2] Preserve final-mode TTS for final-only output
Previous (regressive) behavior:
acp-projector.tsdeliveredfinal_onlyaccumulated text as"block"kind.maybeApplyAcpTtsskips non-"final"kinds when TTS mode is"final", so users with final-only TTS lost synthesized audio for all ACP completion text.Fix: Restore
"final"kind for thefinal_onlyflush inacp-projector.ts. The bind-aware fallback operates on all kinds, so the kind used for the flush does not affect whether the fallback fires. The result is a singlesendFinalReplycall rather than the previoussendBlockReply+ fallbacksendFinalReplypattern, which simplifies delivery for channels without a plugin visibility override (e.g., WhatsApp).[P3] Fail closed on ambiguous bindings (requester-scoped routing)
Previous (insecure) behavior:
bind-aware-dispatch.tslooped over ALL active bindings for a session and sent the payload to each. A session with multiple active bindings would broadcast private child updates to unrelated bound chats.Fix: Use
createBoundDeliveryRouter(already used byoutbound-send-service) withfailClosed: true. PassrequesterConversation(built fromctx.Surface/Provider + ctx.To + ctx.AccountId) so the router matches the single binding whose channel/account matches the requester. If resolution is ambiguous (multiple active bindings, no requester match), the payload is dropped and logged — never broadcast.Tests
src/auto-reply/reply/dispatch-acp.spawn-child-delivery.test.ts— 4/4 GREEN"final"kind)failedCounts.tool = 1(real async-failure state) rather thansend*() → false(empty-payload path). Verifies binding service is consulted and routeReply is called for the bound conversation.To: ""). AssertsrouteReplyis NOT called for either binding — fail-closed behavior confirmed.src/auto-reply/reply/— 1539/1539 pass, 0 fail, 115 files.Updates — 3 bot findings addressed (commit
4792ab5501)!delivered(synchronous send returning false) togetFailedCounts() > 0check before each dispatch. Matches production async transport failure path."final"kind forfinal_onlyaccumulated text flush. Users with TTS mode"final"now receive synthesized audio for ACP completion text.createBoundDeliveryRouter(failClosed: true)+ requester context. Ambiguous cases drop + log rather than broadcast.Catalog reference
Catalog findings: #1, #15. Investigation lives in branch
edpiva/acp-native-session-investigation(not yet upstream) atdocs/plans/2026-05-08-acp-findings-catalog.md.Verification commands
Notes for reviewers
failedCountsshows prior async transport failures, meaning the FIRST failed payload is still lost (it's the one that fails the transport and incrementsfailedCounts). A persistent bound dispatcher created at session-bind time (option b from the bot findings) would catch all payloads including the first. This is a known gap — the current fix recovers everything after the first failure, which covers the dominant real-world scenario (child running for minutes, many events after teardown).createBoundDeliveryRouterusesnormalizeConversationReffor matching — whitespace and case-insensitive on channel/accountId — so the requester matching is robust to provider-specific formatting differences."final"kind instead of"block"forfinal_onlyflush, and updating the teardown simulation to usefailedCountsinstead of return-false mocks.