Repository navigation
fix: keep node completion follow-ups in their originating conversation - #160675
Conversation
Co-authored-by: brokemac79 <[email protected]>
Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 3e0ac4d1-fe43-4607-bfe2-67fb6bf957ef
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 1:23 PM ET / 17:23 UTC (Revision 28). ClawSweeper reviewWhat this changesThe branch preserves node commands’ originating account, conversation, and topic through completion replies and delivery-error follow-ups, while separating delivery attempts from transport recovery. Merge readiness✅ Ready for maintainer review This remains a useful fix for the linked node-completion routing bug. The prior conflict and permanent-rejection blockers are resolved, and no actionable introduced defect was found. Likely related people: steipete and obviyus, with medium-confidence routing based on recent merged work. Priority: P1 Review scores
Verification
How this fits togetherPaired nodes return command-completion events to the Gateway, which uses the heartbeat runner to prepare follow-up agent turns. Those turns pass through conversation routing and durable outbound delivery before reaching the user’s chat. flowchart TD
A[Authenticated conversation] --> B[Node command dispatch]
B --> C[Captured originating route]
B --> D[Node completion event]
C --> D
D --> E[Heartbeat event selection]
E --> F[Conversation and authority checks]
F --> G[Durable delivery owner]
G --> H[Original chat or recovery]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +501, Tests +1961, Docs +4. Total +2466 across 40 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep completion output bound to its authenticated origin and let the existing delivery owner exclusively manage retries and reconciliation. Do we have a high-confidence way to reproduce the issue? Yes: the linked report provides two observed wrong-chat deliveries, and current main lacks node-origin capture. This reviewer inspected source and recorded proof without executing a reproduction. Is this the best way to solve the issue? Yes: the reduced patch repairs origin ownership within existing dispatch and recovery paths, preserves legacy nodes, and avoids introducing another protocol or retry manager. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d72a907b6125. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (27 earlier review cycles; latest 8 shown)
|
Co-authored-by: brokemac79 <[email protected]>
Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 4ed07160-e6a0-4b80-a0ed-3a4d718dc7f3
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Co-authored-by: brokemac79 <[email protected]>
Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 9fa11be9-0cf2-4b54-bed6-b324861a9731
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Co-authored-by: brokemac79 <[email protected]>
Co-authored-by: brokemac79 <[email protected]>
Integrate pinned main a38b64b to resolve the conversation identity conflict. Keep main's single normalized merge while retaining synthetic route pairing. Co-authored-by: brokemac79 <[email protected]>
Integrate pinned main947b35844d17 and preserve captured node-event results. Keep shared conversation completion classification bound to its exec producer. Retain typed no-send and released-custody rollback assertions. Co-authored-by: brokemac79 <[email protected]>
Resolve the native-observed main conflict without restoring removed helpers. Keep captured account/thread facts paired through consolidated resolution. Regress stale-topic inheritance through the real channel plugin. Co-authored-by: brokemac79 <[email protected]>
|
Merged via squash.
|
11 upstream commits. Two conflicts, both from openclaw#160675 (630e969, node completion follow-ups stay in their originating conversation): - src/infra/system-events.ts: kept both sides' fields (the feature's delivery-ack, recipient authority and traceparent, plus upstream's deliveryHeld). - src/auto-reply/reply/session-system-events.ts: upstream changed only the exec-completion filter, isExecCompletionEvent(event.text) to isExecCompletionSystemEvent(event), so that only the exec producer takes the dedicated completion route. The feature's prepare path replaced that inline filter with selectGenericSystemEvents, so the consume hunk keeps ours and the selector now calls isExecCompletionSystemEvent(event). The import follows the rename. Upstream's other change (deliveryHeld, peekDeliverableSystemEventEntries, holdSystemEventDelivery) lives in system-events.ts and merged cleanly. Checks, all on the canonical runner: - Typecheck: core, plus test shards messaging-auto-reply, infra, agents-tools and gateway-methods, all clean. - Tests: session-system-events (+ack-formatted, recipient-authority) 8+2+13; system-events 60 + capacity 2 + queue-drain-span 3; heartbeat-events-filter 46; heartbeat-runner event-ownership 11 / event-routing 34 / exec-delivery-custody 12; server-node-events 48 + system-event-owner 4; node-invoke-plugin-policy 28; nodes.invoke-abort 8; session-row-changes 3; deliver.enqueue-worker 4. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
openclaw#160675) * fix(exec): suppress duplicate foreground node completions Co-authored-by: brokemac79 <[email protected]> * fix(exec): prevent duplicate foreground node completions Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 3e0ac4d1-fe43-4607-bfe2-67fb6bf957ef * fix(nodes): recover missed foreground results Co-authored-by: brokemac79 <[email protected]> * fix(exec): prevent duplicate foreground node completions Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 4ed07160-e6a0-4b80-a0ed-3a4d718dc7f3 * fix(nodes): preserve completion recovery route Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 9fa11be9-0cf2-4b54-bed6-b324861a9731 * fix(nodes): harden Telegram completion recovery Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 75bde6b7-fc9d-4562-8bf1-a559a2b1137e * fix(heartbeat): preserve exec completion route Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 13a6b76b-bfa1-417c-9b03-245ef28de773 * fix(telegram): bind completion routes to account Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 11975fca-d536-4e31-9621-136bf68a231a * fix(exec): suppress duplicate foreground node completions Co-authored-by: brokemac79 <[email protected]> * fix(exec): prevent duplicate foreground node completions Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 3e0ac4d1-fe43-4607-bfe2-67fb6bf957ef * fix(nodes): recover missed foreground results Co-authored-by: brokemac79 <[email protected]> * fix(exec): prevent duplicate foreground node completions Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 4ed07160-e6a0-4b80-a0ed-3a4d718dc7f3 * fix(nodes): preserve completion recovery route Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 9fa11be9-0cf2-4b54-bed6-b324861a9731 * fix(nodes): harden Telegram completion recovery Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 75bde6b7-fc9d-4562-8bf1-a559a2b1137e * fix(heartbeat): preserve exec completion route Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 13a6b76b-bfa1-417c-9b03-245ef28de773 * fix(telegram): bind completion routes to account Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 11975fca-d536-4e31-9621-136bf68a231a * fix(telegram): bind forum completion account Co-authored-by: brokemac79 <[email protected]> * fix(exec): prevent duplicate Telegram topic completions Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 00bdcd92-8173-40ef-89f5-8a4b05b9a6d8 * fix(gateway): diagnose withheld exec routes Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: fbacbf1b-56f2-4da3-88f4-8831587d8be5 * fix(heartbeat): drain queued exec routes Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: a70b58c9-509d-42d9-ae0d-84cfa27e0022 * fix(node): gate result-first completion support Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 6eb400c3-8420-4958-a885-a1ece94abab3 * fix(exec): keep Telegram completion turns on their own routes Gate negotiated foreground suppression on the captured Telegram turn source and preserve the non-Telegram terminal fallback. Partition queued work before model admission and retain exact unconfirmed occurrences without regenerating them on unrelated wakes. Advance deferred routes only after the selected group is no longer deliverable, preserve cron retry ownership, and settle generic notices only when their queue was admitted. Keep legacy isolated base bindings for deferred follow-ups and process surviving coalesced work after stale exec wakes. Co-authored-by: brokemac79 <[email protected]> * fix(exec): prevent duplicate Telegram topic completions Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: a10cf6e8-7bed-4865-9956-adfb8e670520 * fix(heartbeat): keep topic command completions out of owner DMs Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> * Publish openclaw/fix-telegram-topic-completion-routing Worked on by: - @brokemac79 Co-authored-by: brokemac79 <[email protected]> OpenClaw-Publication: 99cee306-6411-464c-a87e-44b896d658a7 * fix: legacy exec completion status spills into Telegram DMs Co-authored-by: brokemac79 <[email protected]> * fix: keep node completion follow-ups on their originating route Reduce the candidate to authenticated source capture, per-exec route isolation and safe final delivery custody. Remove the proposed result-first protocol and generalized generic/cron settlement changes. Preserve native no-publication failure facts so original-route wake retries remain possible without replaying queued or ambiguous sends. Co-authored-by: brokemac79 <[email protected]> * fix: keep scheduled heartbeats off uninspected exec routes Require selected completion admission before captured source can own delivery. Preserve the configured monitor route and leave uninspected completion work queued. Co-authored-by: brokemac79 <[email protected]> * fix: isolate invalid completion routes from unbound events A missing route and a rejected route are not the same selection. Retain legacy unbound grouping but isolate each invalid captured occurrence before model input. Co-authored-by: brokemac79 <[email protected]> * fix: require producer provenance for captured exec delivery Keep untagged legacy text handling but do not let it grant an override of configured delivery. Qualify route tests with the real exec producer context and cover untagged look-alike events. Co-authored-by: brokemac79 <[email protected]> * fix: keep untagged notices out of captured completion batches Separate legacy text-only occurrences even when their route hints match a tagged completion. Cover both queue orders through the native heartbeat delivery flow. Co-authored-by: brokemac79 <[email protected]> * test: expect scoped route rejection before refinement The canonical channel grammar rejects conflicting scoped identities before the asynchronous target refinement boundary. Keep the no-delivery assertion and expect its actual no-route diagnostic. Co-authored-by: brokemac79 <[email protected]> * fix: retire terminally rejected completion events Co-authored-by: brokemac79 <[email protected]> * fix: retain exec work when completion turns fail Co-authored-by: brokemac79 <[email protected]> --------- Co-authored-by: brokemac79 <[email protected]>
Closes #160602
Worked on by: @brokemac79
Work sessions
What Problem This Solves
Fixes node-command completion and delivery-error follow-ups escaping their originating Telegram topic into the operator's DM.
User Impact
Completion follow-ups retain the authenticated command's original account, conversation and thread, even when the saved session route or heartbeat destination changes. Existing notification opt-outs, target:none, direct-message restrictions and current delivery authority still apply. Legitimate direct-origin and explicitly requested DM work remain supported.
Legacy nodes may still produce foreground output plus their normal completion follow-up, both in the original conversation. This change does not introduce a duplicate-suppression protocol or a lost-invoke-result recovery guarantee.
Why This Change Was Made
The synthetic completion turn was using execution/heartbeat sender context as its delivery conversation. The fix snapshots authenticated source facts before awaited raw/plugin node dispatch and carries them through the existing registry, completion event, conversation owner and finalizer. Captured exec routes are isolated before model input; unrelated generic/cron work keeps its existing owners.
The candidate has been deliberately reduced. The proposed result-first ordering, protocolFeatures negotiation, terminal-to-invoke recovery, second authority-state class, generalized generic-event holding and cron route-continuation/retirement changes are removed. Current-main features are preserved. The reduced repair retains 40 changed paths against pinned main 3856df4, rather than the earlier 83-path proposal. Current-main conversation continuations and host-generated notice policy are preserved.
A review also found that holding every failed completion could strand work when queue admission failed before any delivery owner existed. Native no-publication facts and actual intent/dispatch boundaries now distinguish that case: the original-route event remains eligible for the existing bounded wake retry. A queued or ambiguous delivery stays with its existing recovery owner and is not regenerated by another model turn. Deferred routes still progress after a permanent rejection.
Evidence
October 7 diagnosis and current-main integration
Current source: 3c1dce4, tree f2cf0a2c7e9be6f36ad8c8139e29e7108f77acc1. After native observation proved a new conflict in
targets.ts, pinned main 3856df4 was integrated. Its outbound helper consolidation is retained, including the captured exec discriminator, pre-await route copy, no stale-thread inheritance and exact post-refinement checks. This was conflict repair, not a CI-green refresh. Earlier source cf7fe6d had integrated main 947b358 to resolve three actual conflicts, retaining the reduced 40-path scope. The node-event adapter keeps its captured authorization result while deriving types from the registry owner. The shared conversation-completion classifier retains producer-aware routing in both prompt and scheduler consumers. The consolidated rollback case keeps its typed queue/released/no-send assertions.pnpm test src/infra/outbound/targets.exec-route-authority.test.ts --maxWorkers=1passed 18 tests in 17.30 s wall; it reuses the existing compiler/plugin fixture and adds no Gateway boot. Fresh production and Gateway-root/messaging/Gateway-method test types, changed resolver lint, line caps and diff checks passed. A fresh one-pass independent P0–P2 review found no actionable issues; it was static, not execution. Hosted CI seconds remain unclaimed.No CI job was rerun to hide these failures, and no generic/cron announcement-settlement feature was added. Older successful review and transport proof remain historical; the successor must pass its own native admission.
Historical October 5 integrated repair
Historical source: f6e47a1, tree b3fee2a26c8b71abb5b99151a965f86698038118. GitHub later reported a real conflict with main, so this candidate integrates pinned main a38b64b. The only overlapping PR owner was
conversation-identity.ts: the resolution preserves main's removal of redundant normalization while retaining synthetic account/conversation/thread pairing. The source scope remains 40 files; no floating-main refresh loop.Affected proof on this repaired candidate: all 27 tests in conversation identity and actual delivery-custody routing passed (97.78 s test wrapper; 98.16 s wall), including original-route recovery, terminal rejection and ambiguous/queued no-replay. Core production types, the infra/agents-sessions test typegraphs, source lint, line caps and diff checks passed. A fresh full-candidate independent static P0–P2 review was scoped-clean; executable proof was performed separately. Unchanged prior proof is retained below, not relabeled as new execution.
The preceding 617b head received a completed exact-head ClawSweeper review at 2026-10-05T20:38:45.252Z, with no actionable findings, and exact-head security review succeeded. Its CI attempt still had never-started hosted-runner failures during the GitHub Actions incident. Those old startup jobs were not rerun against an obsolete conflicting candidate. This new head requires fresh exact-head review and native CI/security admission; no gate is waived.
Prior integrated source: 617b0ed, tree e293891b9a967731edc595d6534450c9f03f709b. Integrated main 3ae653d to resolve four real conflicts. The final source also composes without conflict with native-captured main b2750b2 (merge-tree 98089a958614a8a2f1ccf19efcf91d8060d7e0a9). This is composition evidence, not execution of that merge tree; no repeated floating-main integration.
No current-head live Telegram run is claimed for this integration. The prior live evidence below covers the retained reduced behavior; changed continuation/notice composition was tested locally through native owners. Hosted CI and required reviews remain separate landing gates.
Historical reduced-candidate live proof and supporting checks
Historical source: c1c7f16, tree 420f4c05e592ce10cc85d34dd8713b8b3cba7c19. Actual conflicts were resolved against 260a319; it is an ancestor. No repeated floating-main refresh.
The build, live proof and whole-candidate clean review used dd2406b. The final commit changes only one test expectation/comment to match earlier scoped-route rejection; all production, configuration and build inputs are byte-identical. That changed test and its type/lint checks passed. Prior-head evidence is not mislabeled as execution of the final test-only commit.
Real Telegram Test Server — reduced production candidate
Both cases used a fresh dedicated team QA lease, a run-owned disposable forum/topic, the actual built candidate Gateway and an isolated released 2026.9.4 Linux node with no result-first feature. Each issued exactly one harmless tagged printf. The model was scripted; Telegram, node execution, routing, message tool and finalizer were real.
Both runners exited 0. Native transcripts, tool-result correlation, wire admission/result counts, recorder receipts and rejection records were inspected; each rejection explicitly recorded upstreamForwarded:false. No private sendMessage attempt occurred. Each unrelated main-session control emitted one private typing action after that control started; this is not a zero-private-traffic claim and was not a completion/status message.
Cleanup is confirmed for both fresh leases: owned forums deleted, node/Gateway/provider/userbot consumers joined, credential state removed, lease scratch empty, and Gateway/model/Bot API adapter/node-bridge listeners closed. No paid model calls, new cloud allocation, production permission changes, personal Telegram, VPS or Surface access occurred.
Local/native contract proof and review
Limits and historical context
The injected 400 is the existing Test Server adapter's definite pre-upstream rejection, not genuine server-generated thread-not-found or accepted-but-unacknowledged delivery. Negotiated recovery is no longer part of this PR. No blanket security, migration, deployment or merge clearance is claimed. This patch adds no persistent schema or numeric protocol-version change.
Historical evidence is retained: operator-reported 6f84cb9 failed with an error-final DM spillover; it remains withdrawn. b040d3c later passed an operator legacy topic-retention cell and two qualified team Test Server cases, but is not the final candidate. An earlier interrupted attempt remains inconclusive; later partial fixture failures are not relabeled passing. The former warning-only stale saved-route withholding policy was removed with the broader recovery design; its retired policy request is not treated as approval or as a requirement for behavior no longer present.
Worked on by
View the OpenClaw team session