← Back to PRs

#18699: feat(hooks): add deliver: "auto" mode for webhook mappings

by larrylobster9735 open 2026-02-17 00:10 View on GitHub →
gateway stale size: XS
## Summary Adds `deliver: "auto"` as a new option for webhook hook mappings. When set, the isolated agent's response is delivered to the channel **unless** the response is a short acknowledgment (like "ok", "noted", "done", etc.). ## Use case For noisy webhook sources like Gmail, the agent should silently handle routine emails (spam, newsletters, notifications) but deliver real content when there's something worth surfacing. Currently `deliver: true` always notifies and `deliver: false` never does — there's no middle ground. With `deliver: "auto"`, the agent processes every webhook but only delivers when it has real content. Short acks (≤3 chars or matching common patterns like "ok", "noted", "done", "acknowledged", "heartbeat_ok", etc.) are silently dropped. ## Approach The skip logic lives in the isolated agent run (`src/cron/isolated-agent/run.ts`), after the existing `skipHeartbeatDelivery` and `skipMessagingToolDelivery` checks. When `deliver` is `"auto"`: - Empty responses → skip delivery - Short ack responses (≤3 chars or matching known patterns) → skip delivery - Everything else → deliver normally The delivery planner (`src/cron/delivery.ts`) treats `"auto"` as `requested: true` so the delivery pipeline is set up — the actual skip decision happens later when we can inspect the agent's response. ## Changes | File | Change | |------|--------| | `src/config/zod-schema.hooks.ts` | Schema accepts `boolean \| "auto"` | | `src/config/types.hooks.ts` | Type updated to `boolean \| "auto"` | | `src/gateway/hooks.ts` | `resolveHookDeliver` passes through `"auto"`; `HookAgentPayload.deliver` type updated | | `src/gateway/hooks-mapping.ts` | All `deliver` types updated; `mergeAction` handles `"auto"` | | `src/cron/isolated-agent/run.ts` | New `skipAutoDeliverAck` check after existing skip checks | | `src/cron/delivery.ts` | Legacy mode resolution treats `"auto"` as `"explicit"` | | `src/cron/types.ts` | `CronPayload` and `CronPayloadPatch` deliver types updated | <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds `deliver: "auto"` mode for webhook mappings to enable intelligent delivery based on agent response content. When set, responses are delivered unless they're short acknowledgments like "ok", "noted", "done" (≤3 chars or matching predefined patterns). **Changes**: - Schema/types updated across 7 files to accept `boolean | "auto"` for `deliver` field - `resolveCronDeliveryPlan` treats `"auto"` as `"explicit"` to enable delivery pipeline - New skip logic in `runCronIsolatedAgentTurn` filters out short acks after existing skip checks - `resolveHookDeliver` correctly passes through `"auto"` string literal - `mergeAction` properly handles `"auto"` value in deliver field merge logic **Issues found**: - Critical: Auto-deliver skip logic doesn't check for media attachments - responses with media/structured content should always deliver regardless of text (see inline comment) <h3>Confidence Score: 3/5</h3> - Safe to merge after fixing media handling bug in auto-deliver logic - The implementation is well-structured and follows existing patterns, but contains a logical bug where auto-deliver mode doesn't check for media content before skipping delivery. This could cause responses with images or structured data to be incorrectly suppressed. The fix is straightforward and follows the established pattern in `isHeartbeatOnlyResponse`. - Pay attention to `src/cron/isolated-agent/run.ts` - the auto-deliver skip logic needs media checking <sub>Last reviewed commit: ebe21d6</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs