Skip to content

fix: keep configured dispatch owner for bound free-ACP harness sessions - #165517

Draft
jmar5439 wants to merge 2 commits into
openclaw:mainfrom
jmar5439:fix/acp-bound-dispatch-gates
Draft

jmar5439 wants to merge 2 commits into
openclaw:mainfrom
jmar5439:fix/acp-bound-dispatch-gates

Conversation

@jmar5439

@jmar5439 jmar5439 commented Oct 5, 2026 •

Copy link
Copy Markdown

What Problem This Solves

Fixes: bound ACP follow-ups keyed agent:<harness>:acp:<id> lose the channel's configured owner when routing rewrites the session key, so reply dispatch looks up a runtime for the harness id and fails (prepared dispatch runtime owner not published; reply scope mismatch; fast-path session init under the wrong agent scope).

Solution

Three gates, ported from local trial patch verified live on Telegram+opencode:

  1. Carry the pre-rewrite route agent as ownerAgentId/RouteOwnerAgentId and prefer it for the published-runtime lookup (Discord text + slash; other channels inherit via route spread).
  2. Prefer the preserved route owner for free ACP keys in reply preprocessing scope checks.
  3. Derive the fast-path session init agent from free ACP keys so storage stays harness-scoped while only the published runtime uses the configured owner.

Impact

  • ACP harness sessions (opencode/codex/claude) reply in the originating channel instead of erroring on owner mismatch.
  • No behavior change for non-ACP or unbound sessions.

Evidence

  • get-reply.fast-path.test.ts + get-reply.binding-route-owner.test.ts: 16/16 pass (pre-rebase head, direct vitest).
  • binding-routing.test.ts: 25/25 pass (2 expectations updated for the new ownerAgentId).
  • session-key.test.ts: 90/90 pass.
  • Post-rebase re-runs: binding-routing + session-key green; one timing-sensitive orchestration scenario in binding-route-owner (earlier-child-change-during-later-base-read) times out on this small loaded box identically with and without these commits (all additions here are synchronous; the run also shows worker-task timeouts = infra starvation), leaving CI on healthy hardware as arbiter.
  • Live after-fix Telegram evidence (configured owner runtime dispatching to bound harness + returned channel reply) still pending: it requires CI-built dist + gateway restart + live test, none available from this box. Pre-fix live evidence (2026-10-05: ACP final completed with no DM send, preview cleaned, DM left empty) is in the linked investigation. Requesting re-review on the unit-proofed routing change in the meantime.
  • git diff --check clean.

@clawsweeper

clawsweeper Bot commented Oct 5, 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 channel: discord Channel integration: discord size: M labels Oct 5, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The branch preserves the configured channel agent for reply dispatch to bound Agent Client Protocol sessions while keeping session storage scoped to the external harness.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused repair has useful source and test support, but real after-fix behavior remains unproven.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful candidate for an unresolved ACP dispatch failure. Current main lacks the owner propagation, and the overlapping open PRs do not establish a proven replacement. After-fix runtime evidence remains the merge blocker.

Priority: P1
Reviewed head: c31724a1fd242787570947bb8a779c4aaf76987c

Before merge

  • Add real behavior proof - The changed binding projection, configured-runtime lookup, reply scope, and harness-scoped initialization have reported unit coverage, but the captured body explicitly leaves the real Telegram/opencode after-fix run pending. No evidence shows an existing binding dispatching through a distinct configured owner and returning a channel reply. The reviewer-side Telegram request was inconclusive. No stored-data format or schema change was identified. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Complete next step - Provide after-fix evidence from this committed head showing configured-owner dispatch to a bound ACP harness and the returned channel reply, including an existing binding, and record rebased reply-path validation. Screenshots or recordings are welcome when they show the behavior; terminal output and logs also count. Redact private identifiers, endpoints, and credentials. Update the PR body to trigger re-review; if it does not run, ask a maintainer to comment @clawsweeper re-review.

Findings

None.

Agent review details

How this fits together

Channel routing selects a configured OpenClaw agent, then conversation bindings can redirect messages to an external ACP harness. Reply dispatch needs the configured agent's published runtime while ACP execution and session storage retain the bound session identity.

flowchart TD
  A[Channel message or command] --> B[Configured channel route]
  B --> C[Conversation binding]
  C --> D[Preserved dispatch owner]
  C --> E[ACP harness session]
  D --> F[Published reply runtime]
  E --> G[Harness execution and storage]
  F --> G
  G --> H[Channel reply]
Loading

Technical review

Best possible solution:

Keep configured dispatch ownership separate from harness session identity, with existing bindings continuing to work and current binding checks protecting dispatch.

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

Yes, from source: route rewriting replaces the configured agent with the harness identity, while Gateway dispatch publishes configured-agent runtimes only. The linked issue supplies a concrete Discord reproduction; this review did not execute it.

Is this the best way to solve the issue?

Yes, the owner separation addresses the demonstrated invariant without renaming sessions or migrating stored bindings. End-to-end success still needs after-fix evidence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1746280d618b.

Security

None.

Evidence

What I checked:

  • Verified introduced changes: Reviewed the pinned merge-base-to-head patch. The verified test merge has the pinned base and PR head as its two parents; its recorded result contains the same introduced paths, rather than the extensive endpoint drift. (c31724a1fd24)
  • Current main still lacks the repair: Current main resolves the published dispatch owner from the source session key or session agent without RouteOwnerAgentId. A channel-rewritten free ACP key therefore still selects the harness identity. (src/auto-reply/reply/dispatch-from-config.gather.ts:426, 1746280d618b)
  • Owner propagation and storage separation: The binding resolver preserves the pre-rewrite agent; the inbound context carries it into dispatch and reply preprocessing. Discord, Telegram, Slack, and Matrix message context builders spread their routes. Full session initialization independently derives its storage agent from the target session key; the changed fast bootstrap now follows that same scope. (src/channels/plugins/binding-routing.ts:206, c31724a1fd24)
  • Authority and binding lifecycle: The preserved owner originates in channel routing rather than message text. Existing binding observations survive context construction, and dispatch retains binding-current preparation checks before admitted work. No concrete introduced authorization bypass was established. (src/auto-reply/reply/dispatch-from-config.prepare-operation.ts:178, c31724a1fd24)
  • Contributor proof and review continuity: The captured PR body explicitly says live after-fix Telegram proof is pending. Reported tests are supplemental: binding-routing and session-key were rerun after rebase, while the reply tests have pre-rebase passing totals and a reported timing failure on the rebased host. The previous completed review at this same head requested after-fix output and rebased reply-path validation; neither is established by the captured update. Captured context sourceRevision: 722507580b651571ca9b7f8881e9ecb05988986d02297d415d31dc6559949739. (c31724a1fd24)
  • Bounded runtime check was inconclusive: A request to exercise Telegram ACP spawn, binding, and follow-up reply returned state inconclusive with reason stale_or_ineligible_pr_head. No runtime assertions or observations were produced; this is neither a pass nor evidence of a patch defect. (c31724a1fd24)

PR surface

Source +98, Tests +123. Total +221 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 12 109 11 +98
Tests 2 123 0 +123
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 232 11 +221

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #146365
Summary: This branch is another candidate repair for the configured-owner versus ACP-harness dispatch failure; no replacement has demonstrated a safe landing path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The underlying reported failure prevents bound ACP channel messages from reaching the harness and can dead-letter follow-ups.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Successful follow-up replies in a bound Telegram ACP conversation are directly observable on Telegram's Test Server.

Rank-up moves

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

  • Add redacted after-fix logs, terminal output, or a recording showing distinct configured-owner dispatch, ACP harness execution, and a returned reply through an existing binding.
  • Record focused validation of the rebased reply-scope and initialization paths, distinguishing passing results from the reported host timeout.

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-10-05T10:33:58.312Z sha 1d44a8358dffa1c4ad58265c43e62c1a277b7233 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-05T13:24:05.212Z sha c31724a :: needs real behavior proof before merge. :: none

Reviewed October 5, 2026, 10:18 AM ET / 14:18 UTC (Revision 3).

@jmar5439
jmar5439 force-pushed the fix/acp-bound-dispatch-gates branch from 1d44a83 to c31724a Compare October 5, 2026 13:16
@jmar5439

jmar5439 commented Oct 5, 2026

Copy link
Copy Markdown
Author

Rebased onto current main and force-pushed. One conflict in get-reply-fast-path.ts: upstream made the snapshot load async while this stack changes the init agent — combined both (await + initAgentId).

Overlap note: #149801 covers the same #146365 owner problem for Discord+Matrix at monitor level; this stack covers it generically via route spread (binding-routing/session-key/resolve-route) plus reply scope and fast-path init, which is what Telegram turns need. If #149801 lands first, the overlapping hunks here (dispatch-from-config.gather.ts, templating.ts) will need trimming.

Local verification: fast-path + binding-route-owner 16/16, binding-routing 25/25, session-key 90/90 pre-rebase. Post-rebase, one timing-sensitive orchestration test (preserves ownership through getReply after earlier-child-change-during-later-base-read) times out on this small box but fails identically with and without these commits (all our additions here are synchronous), so leaving it to CI on healthy hardware as arbiter.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord P1 High-priority user-facing bug, regression, or broken workflow. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant