← Back to PRs

#10663: feat(hooks): add agentId support for webhook routing

by nityatrish open 2026-02-06 20:33 View on GitHub →
gateway stale
## Summary Adds `agentId` field to hook mappings, allowing webhooks to route to specific agents instead of always using the default agent. ## Motivation This enables multi-agent architectures where different webhook endpoints can target different agent instances. For example, a project management system can route notifications to project-specific agents. ## Changes - Add `agentId` to `HookMappingConfig` type and zod schema - Add `agentId` to `HookMappingResolved` and `HookAction` types - Thread `agentId` through `normalizeAgentPayload` and `dispatchAgentHook` - Pass `agentId` to `runCronIsolatedAgentTurn` (which already supported it) ## Usage ### Static routing in config: ```yaml hooks: mappings: - id: project-a match: { path: "project-a" } action: agent agentId: agent-a messageTemplate: "{{message}}" ``` ### Dynamic routing from payload: ```yaml hooks: mappings: - id: dynamic match: { path: "webhook" } action: agent agentId: "{{targetAgent}}" messageTemplate: "{{message}}" ``` ### Direct /hooks/agent endpoint: ```json { "message": "Hello", "agentId": "my-agent" } ``` ## Testing - Built and tested locally - Verified webhook routing to different agents works correctly <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> - Extends hook mapping/config types and schema to support an optional `agentId`. - Threads `agentId` through mapping normalization/templating so it can be statically configured or dynamically rendered from the webhook payload. - Passes `agentId` through the HTTP hook handlers so `/hooks/*` requests can route to a non-default agent. - Updates the cron-isolated agent turn dispatch path to accept the requested `agentId`. <h3>Confidence Score: 3/5</h3> - This PR is close, but has a concrete hook-dispatch typing/threading issue that can prevent `agentId` from being forwarded correctly. - Changes are mostly additive and consistently threaded through config/mapping, but `dispatchAgentHook`'s declared parameter shape in `server-http.ts` omits `agentId` while call sites now pass it, which indicates a real integration gap (and may fail type-check or drop the value depending on implementation). - src/gateway/server-http.ts <!-- 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