fix(hooks): suppress system event injection when deliver is false [AI-assisted]#36332
fix(hooks): suppress system event injection when deliver is false [AI-assisted]#36332cioclawcode wants to merge 2 commits into
Conversation
When a hook mapping sets `deliver: false`, the delivery announcement is
correctly suppressed, but a system event ("Hook <name>: <summary>") is
still injected into the main session. This happens because the guard
only checks `!result.delivered` — which is always false when delivery
was never attempted.
Add `value.deliver !== false` to the guard so that hooks with explicit
`deliver: false` complete silently without notifying the main session.
Fixes openclaw#36325
Greptile SummaryThis PR adds a single guard ( Key observations:
Confidence Score: 3/5
|
The error path intentionally always surfaces to the main session even when deliver is false — silent hook failures are harder to debug. Add a comment making this asymmetry explicit per review feedback.
|
Good catch on the error-path asymmetry. I chose to keep errors always surfaced — if a hook with |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Summary
When a hook mapping sets
deliver: false, the delivery announcement is correctly suppressed, but a system event (Hook <name>: <summary>) is still injected into the main session viaenqueueSystemEvent. This PR adds a check forvalue.deliver !== falseso that hooks with explicitdeliver: falsecomplete silently.Problem
In
src/gateway/server/hooks.ts, the guard on line ~83 only checks!result.delivered:When
deliver: false:resolveCronDeliveryPlanresolves to{ mode: "none", requested: false }result.deliveredis alwaysfalse!result.deliveredguard passes → system event fires unconditionallyThis causes the main session to receive "Findings" summaries from every hook completion, even when the user explicitly opted out. The main session agent may then announce these summaries to unrelated channels.
Fix
One additional condition:
value.deliver !== falseWhen
deliveris explicitlyfalse, the hook completes silently — no delivery, no system event. Whendeliveristrue(default) or unset, behavior is unchanged.The error
catchpath intentionally still surfaces errors to the main session regardless ofdeliver— silent failures are harder to debug than noisy ones. This asymmetry is documented with an inline comment.Testing
deliver: false→ no system event injected ✅deliver: true(default) that fail to deliver → system event still fires ✅ (unchanged)deliver: truethat succeed → no system event (unchanged,result.deliveredistrue) ✅deliver: falsethat throw → error system event still fires ✅ (intentional)🤖 AI Disclosure
deliver: falsewere leaking summaries into unrelated Slack channels via the main session.hooks.ts→delivery.ts→run.ts. No unit tests added (the existing test harness is integration-heavy).Fixes #36325