Skip to content

fix(hooks): preserve multi-account agent delivery - #116095

Merged
vincentkoc merged 2 commits into
mainfrom
audit-hook-issues-a-narrow-20260729
Jul 29, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
audit-hook-issues-a-narrow-20260729

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Jul 29, 2026 •

Copy link
Copy Markdown
Member

Closes #43866

Related: #43951

What Problem This Solves

Fixes an issue where POST /hooks/agent silently discarded accountId, causing direct announce delivery to use the wrong configured account or fail on multi-account channels.

Why This Change Was Made

The hook payload now validates and preserves accountId alongside its explicit channel and to, then carries it through the existing direct announce delivery contract. The change stays within hook normalization and dispatch; it does not rewrite cron normalization or message-tool policy.

The original contributor PR cannot be updated because its closed fork branch has maintainer edits disabled and rejects maintainer pushes. This replacement preserves Paul Desmond Parker's contribution through a co-author trailer.

User Impact

Webhook callers can select a configured channel account for direct agent-hook delivery. Invalid or incomplete accountId destinations fail before a run is scheduled instead of being silently ignored.

Evidence

  • Exact head: 525d63baeffecb7bbfab888b6c7e2be6131fa8cc.
  • 29 focused hook normalization and HTTP-boundary tests passed.
  • Real QA Lab product proof passed: a real Gateway child delivered exactly one outbound message through qa-channel account work, with zero messages through default.
  • Targeted oxfmt, oxlint, and git diff --check passed.
  • QA Lab E2E ownership boundary check passed after moving the product proof under extensions/qa-lab.
  • Fresh exact-head autoreview reported no actionable findings (0.94 confidence).
  • Release-note context is captured here; CHANGELOG.md remains release-owned.

@vincentkoc vincentkoc self-assigned this Jul 29, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review July 29, 2026 22:02
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Jul 29, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 6:55 PM ET / 22:55 UTC.

ClawSweeper review

What this changes

The PR accepts and normalizes accountId for direct POST /hooks/agent delivery, carries it into the scheduled announce delivery, and adds documentation plus focused gateway and QA Lab coverage.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This protected, member-authored PR appears to repair the reported multi-account hook-delivery loss through the existing delivery object; the prior dispatcher-handoff blocker is addressed on the latest head, so it should remain open for maintainer merge review rather than cleanup automation.

Priority: P1
Reviewed head: ec109714929329e51ccde292baedfe1a90a68738

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repair is focused, resolves the prior concrete handoff concern, and includes targeted source-path and QA Lab evidence; protected maintainer review remains the appropriate merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR nevertheless records a selected-account QA Lab Gateway scenario as supporting behavior evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR nevertheless records a selected-account QA Lab Gateway scenario as supporting behavior evidence.
Evidence reviewed 5 items Normalized delivery carries the selected account: The PR adds accountId to the hook payload and announce-delivery shapes, trims and validates it, and places it on the canonical delivery object only for explicit channel-and-recipient delivery.
HTTP boundary preserves the normalized field: The request handler forwards the normalized accountId with the hook request data, while the latest PR comment records that the downstream gateway handler assigns the already-normalized delivery object to the scheduled job.
Previous P1 blocker was directly retested: The latest-head follow-up adds a dispatcher-boundary assertion and reports a selected-account QA Lab Gateway run with one message on work and none on default; this specifically addresses the prior review concern that the account could be lost after request normalization.
Findings None None.
Security None None.

How this fits together

Agent hooks accept authenticated webhook requests, normalize optional direct-delivery fields, and schedule an isolated agent run. The scheduled run uses the normalized delivery object to choose a channel, recipient, and configured channel account for its outbound announcement.

flowchart LR
  A[Webhook caller] --> B[Agent hook endpoint]
  B --> C[Payload normalization]
  C --> D[Direct delivery object]
  D --> E[Scheduled agent run]
  E --> F[Channel account resolution]
  F --> G[Outbound message]
Loading

Before merge

  • Resolve merge risk (P1) - This changes the documented hook destination contract: callers that previously supplied accountId without both channel and to will now receive an admission error instead of silently running completion-only.
  • Resolve merge risk (P1) - Account selection affects outbound routing, so merge review should retain the selected-account regression coverage and verify that the existing default-account behavior remains unchanged for payloads without accountId.
  • Complete next step (P2) - This protected, member-authored PR has no remaining mechanical finding; it needs a maintainer merge decision on the explicit invalid-destination behavior rather than an automated repair.
Agent review details

Security

None.

PR surface

Source +27, Tests +174, Docs +2. Total +203 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 2 30 3 +27
Tests 4 177 3 +174
Docs 2 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 211 8 +203

Review metrics

Metric Value Why it matters
Hook destination contract 1 optional input added; partial selected-account destinations now reject before admission The endpoint now exposes a channel-account selector and intentionally changes how malformed destination data is handled.

Stored data model

Persistent data-model change detected: serialized state: extensions/qa-lab/src/hook-agent-account-routing.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #43866
Summary: This PR is the current candidate fix for the canonical multi-account agent-hook delivery report; the earlier replacement PR is closed unmerged.

Members:

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

Merge-risk options

Maintainer options:

  1. Preserve explicit account routing (recommended)
    Merge with the documented rule that accountId requires both channel and to, retaining the pre-admission error instead of silently selecting a default account.

Technical review

Best possible solution:

Keep one canonical normalized delivery object from hook admission through scheduled dispatch, reject incomplete selected-account destinations before admission, and merge only after a maintainer accepts that explicit validation contract.

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

Yes, from source and the supplied QA Lab scenario: submit a direct agent hook with explicit channel, to, and a non-default configured accountId, then verify the outbound message uses that account. I could not independently execute the repository checkout in this read-only environment.

Is this the best way to solve the issue?

Yes. Carrying the normalized field on the existing delivery object is narrower and safer than reconstructing routing later in the dispatcher or rerouting hooks through a separate cron-normalization path.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against daaaef95f093.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR nevertheless records a selected-account QA Lab Gateway scenario as supporting behavior evidence.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 auth-provider: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 message-delivery.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The patch addresses a direct channel-delivery failure for multi-account operators, where the requested configured account could be ignored.
  • merge-risk: 🚨 compatibility: Existing webhook callers that send incomplete accountId destination data now receive an explicit admission failure rather than the prior completion-only behavior.
  • merge-risk: 🚨 message-delivery: The changed field selects the configured channel account used for an outbound direct announcement, so an incorrect handoff could misroute or suppress delivery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR nevertheless records a selected-account QA Lab Gateway scenario as supporting behavior evidence.

Evidence

What I checked:

  • Normalized delivery carries the selected account: The PR adds accountId to the hook payload and announce-delivery shapes, trims and validates it, and places it on the canonical delivery object only for explicit channel-and-recipient delivery. (src/gateway/hooks.ts:231, ec1097149293)
  • HTTP boundary preserves the normalized field: The request handler forwards the normalized accountId with the hook request data, while the latest PR comment records that the downstream gateway handler assigns the already-normalized delivery object to the scheduled job. (src/gateway/server/hooks-request-handler.ts:387, ec1097149293)
  • Previous P1 blocker was directly retested: The latest-head follow-up adds a dispatcher-boundary assertion and reports a selected-account QA Lab Gateway run with one message on work and none on default; this specifically addresses the prior review concern that the account could be lost after request normalization. (src/gateway/server/hooks.agent-trust.test.ts:172, ec1097149293)
  • Canonical bug remains open behind this candidate fix: The PR uses closing syntax for [Bug]: /hooks/agent silently drops accountId — hook dispatch bypasses cron normalization pipeline #43866, whose described failure is the same missing account selection in direct hook delivery; it should stay open until this PR is merged.
  • Prior replacement branch is not a viable superseding target: Fix/hooks agent accountid normalization #43951 is closed unmerged and dirty, while this PR explicitly replaces its core account-routing repair with the narrower current delivery-object path.

Likely related people:

  • vincentkoc: Authored the two current-head commits that implement the hook delivery change and add the dispatcher-boundary regression proof. (role: recent hook-path contributor; confidence: medium; commits: f1720a2eb55c, ec1097149293; files: src/gateway/hooks.ts, src/gateway/server/hooks-request-handler.ts, src/gateway/server/hooks.agent-trust.test.ts)
  • pauldesmondparker: Reported the canonical hook account-routing failure and authored the earlier related implementation, whose contribution this replacement preserves. (role: original report and adjacent fix author; confidence: medium; commits: 8499f96ed3fd; files: src/gateway/hooks.ts, src/gateway/server/hooks.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-07-29T22:07:12.717Z sha 11c64b5 :: found issues before merge. :: [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-29T22:19:00.002Z sha 648840e :: needs maintainer review before merge. :: none
  • reviewed 2026-07-29T22:30:58.513Z sha 525d63b :: needs maintainer review before merge. :: none
  • reviewed 2026-07-29T22:35:00.272Z sha 525d63b :: needs maintainer review before merge. :: none
  • reviewed 2026-07-29T22:43:59.998Z sha f1720a2 :: found issues before merge. :: [P1] Forward accountId into the scheduled delivery object
  • reviewed 2026-07-29T22:47:52.540Z sha f1720a2 :: needs changes before merge. :: [P1] Forward accountId into direct announce delivery

@vincentkoc

Copy link
Copy Markdown
Member Author

Exact head is now 648840efd7aee7894f9b333bd03951b723381def.

The release-owned CHANGELOG.md entry was removed per the prior rank-up move. The narrow hook normalization, docs, focused tests, and real Gateway QA-Lab proof are unchanged. Fresh exact-head autoreview is clean at 0.95.

Maintainer decision remains: accountId is valid only with an explicit channel and to; incomplete destinations fail before admission instead of silently degrading to completion-only behavior.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 29, 2026
@vincentkoc
vincentkoc force-pushed the audit-hook-issues-a-narrow-20260729 branch from 648840e to 525d63b Compare July 29, 2026 22:26
@vincentkoc

Copy link
Copy Markdown
Member Author

Exact head is now 525d63baeffecb7bbfab888b6c7e2be6131fa8cc.

The previous CI failure was valid: the QA Lab E2E imported plugin internals from a core test path. The proof now lives under the owning extensions/qa-lab package and no longer crosses that boundary.

Reproof:

  • selected-account real Gateway E2E passed;
  • extension ownership boundary suite passed (11/11);
  • formatting, type-aware oxlint, and diff check passed;
  • exact-head autoreview is clean at 0.94.

The previously recorded maintainer decision remains unchanged: incomplete accountId destinations fail before admission.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 29, 2026
@vincentkoc
vincentkoc force-pushed the audit-hook-issues-a-narrow-20260729 branch from 525d63b to f1720a2 Compare July 29, 2026 22:38
@vincentkoc

Copy link
Copy Markdown
Member Author

Exact-head refresh: f1720a2eb55c613e2fea0ea00e98113a277d20c4

The branch is rebased onto current main; the account-routing contract remains unchanged and narrowly scoped.

Fresh proof:

  • 29/29 focused Gateway hook tests pass.
  • The real selected-account QA Lab Gateway E2E passes.
  • oxfmt, type-aware oxlint, and git diff --check pass.
  • Fresh full-branch autoreview is clean (0.95).

Maintainer decision remains unchanged: accountId is valid only with explicit channel and to; incomplete destinations fail before admission.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 29, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer refresh at exact head ec109714929329e51ccde292baedfe1a90a68738.

I verified the reported P1 against the full dispatcher path and did not add duplicate runtime plumbing:

  • normalizeAgentPayload puts the normalized accountId on the canonical announce delivery object
  • createHooksRequestHandler passes that object through dispatchAgentHook
  • createGatewayHooksRequestHandler assigns job.delivery = value.delivery
  • cron delivery resolution already treats explicit job.delivery.accountId as authoritative

The suggested runtime reconstruction would create a second source of truth for the same destination. I kept the canonical path and added a focused dispatcher-boundary regression assertion instead.

Exact proof:

  • 47 focused Gateway normalization, HTTP, and dispatcher tests pass
  • real QA Lab Gateway E2E passes with exactly one outbound message from account work and zero from default
  • formatting, type-aware oxlint, and git diff --check pass
  • fresh branch-wide autoreview: clean, no accepted/actionable findings, 0.89

This head therefore addresses the review concern with source-path proof plus behavior proof, without widening the runtime diff.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 29, 2026
@vincentkoc
vincentkoc merged commit 9e041cd into main Jul 29, 2026
127 of 135 checks passed
@vincentkoc
vincentkoc deleted the audit-hook-issues-a-narrow-20260729 branch July 29, 2026 23:10
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

@vincentkoc

Copy link
Copy Markdown
Member Author

Post-land overlap audit complete.

The fresh linked-worktree QA Lab retry stopped before runtime assertions because that worktree had no built dist/; the original exact-head QA Lab proof and hosted CI remained green.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
* fix(hooks): preserve account routing for agent delivery

Refs openclaw#43866

Co-authored-by: Paul Desmond Parker <[email protected]>

* test(gateway): prove hook account delivery handoff

---------

Co-authored-by: Paul Desmond Parker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /hooks/agent silently drops accountId — hook dispatch bypasses cron normalization pipeline

1 participant