← Back to PRs

#8084: fix(plugins): wire up message_sending hook in outbound delivery

by lailoo open 2026-02-03 15:22 View on GitHub →
stale
## Summary Wire up the `message_sending` plugin hook in the outbound delivery pipeline. ## Problem The `message_sending` hook was defined in `src/plugins/hooks.ts` and exported via `createHookRunner()`, but was never actually called anywhere in the codebase. This made it impossible for plugins to: - Modify outgoing message content before delivery - Cancel message delivery (e.g., for content filtering) ## Solution Call `runMessageSending()` in `deliverOutboundPayloads()` before each message is sent. The hook: - Receives the message content, destination, and channel metadata - Can return modified `content` to replace the original - Can return `cancel: true` to skip delivery entirely ## Changes - `src/infra/outbound/deliver.ts`: Add hook call before message delivery - `src/infra/outbound/deliver.test.ts`: Add tests for hook behavior ## Testing - `pnpm vitest run src/infra/outbound/deliver.test.ts` - all 15 tests pass - `pnpm lint src/infra/outbound/deliver.ts` - no errors Fixes #7966 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR wires the `message_sending` plugin hook into the outbound delivery pipeline by calling the global hook runner for each normalized outbound payload, allowing plugins to modify message text or cancel delivery before the channel adapter sends. It also adds an integration test suite that exercises hook invocation, text modification, cancellation, and the `sendPayload` adapter path, plus a changelog entry documenting the fix. <h3>Confidence Score: 3/5</h3> - Mostly safe to merge, but there are a couple of behavior/contract edge cases to confirm. - Core wiring is straightforward and tests cover the happy paths, but the added try/catch can change failure semantics (especially when `bestEffort` is false), and the hook contract around media-only payloads vs empty content is unclear and could surprise plugin authors. - src/infra/outbound/deliver.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs