feat(tools): add "webhook" toolset for outbound notifications #3641
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3641"
general
weight: 0.35
dwin-gharibi
Closes #3640
What this is
A toolset that lets an agent send a notification to a chat service, without knowing the URL or the secret.
The agent gets one tool -
send_webhook(message). Where that message goes is decided by config, not by the model:The model wrote the message. It never saw the URL.
<img width="1178" height="374" alt="image" src="https://github.com/user-attachments/assets/ade063ed-9c73-48ca-a544-fb2068e2d7ce" />
Why not just use the
apiorfetchtool?You can already POST to Slack with
api. The difference is what the model has to know, and what happens when the network misbehaves:| |
api/fetch|webhook|| --- | --- | --- |
| Destination | model supplies the URL | fixed in config |
| Secret | in the model's context | never in the model's context |
| Payload shape | model must know Slack ≠ Discord ≠ Telegram | built from
provider|| 429 / 5xx | model sees the error and improvises | retried with backoff, honours
Retry-After|| Duplicate sends | model may retry on its own | suppressed for 30s |
| Blocking | model waits for the HTTP round-trip | returns immediately |
The bottom four rows are the substance. A model that gets an HTTP 429 will happily retry in a loop, or give up and report failure when nothing was wrong. Retry policy is not something a language model should be improvising.
How it works
A
send_webhookcall passes two cheap guards before any network I/O, then delivers - in the background when the runtime allows it:<img width="608" height="822" alt="image" src="https://github.com/user-attachments/assets/79057c0a-fcbc-4b83-beb9-ff6e27230df5" />
1. Fire-and-forget
send_webhookreturns as soon as the message is accepted - the agent isn't blocked on a network round-trip and doesn't stall its turn behind a slow Slack. Delivery continues on a background context (context.WithoutCancel) so it survives the tool call returning. The agent is interrupted only if delivery ultimately fails, viaRecall; success is silent.<img width="803" height="340" alt="image" src="https://github.com/user-attachments/assets/067ad458-8217-4d69-bdd6-070e8ca97980" />
A notification tool that makes the agent babysit every send is worse than no tool. When the runtime doesn't support
Recall, it falls back to delivering synchronously and returning the real result - the semantics degrade to "blocking but correct" rather than silently dropping failures.2. Retries are classified, not blind
Every response is sorted into delivered / transient / permanent, and only transient failures are retried - up to 4 attempts, honouring the server's
Retry-After:<img width="596" height="766" alt="image" src="https://github.com/user-attachments/assets/9f0c750d-e907-44c6-9e5b-4e88405dbcb4" />
| Response | Verdict | Action |
| --- | --- | --- |
| 2xx | delivered | stop |
| 429, 5xx | transient | retry - honour
Retry-After, else exponential backoff || other 4xx | permanent | stop immediately, report |
| network error | transient | retry |
| bad URL / bad payload | permanent | stop, report |
Retry-Afteris capped atbackoff.MaxRetryAfterWait, so a hostile server can't park a delivery forever. Retrying a 401 forever is pointless; not retrying a 503 is careless - hence the split.3. Duplicate suppression and rate limiting
An identical
(message, value2, value3)within 30s is suppressed, and sends are spaced at least 1s apart (the two amber guards in the flow above). Models retry on their own when they think something failed; without a guard, one flaky send becomes ten Slack messages.Providers
providerselects the payload shape. Samesend_webhook(message)call, different body:|
provider| Body || --- | --- |
|
slack,mattermost,rocketchat,googlechat,teams|{"text": "..."}||
discord|{"content": "..."}||
telegram|{"chat_id": "...", "text": "..."}||
ifttt|{"value1": "...", "value2": "...", "value3": "..."}||
generic(default) |{"text": "..."}|value2/value3are optional and exist for IFTTT's three-value contract; other providers ignore them.More examples
Discord:
Telegram - needs a destination chat as well as the token URL:
A generic endpoint that authenticates with a header instead of a secret URL:
urlandheadersexpand through the standard${env.VAR}expander - the same oneapiandopen_urluse - so secrets stay in the environment rather than in the config file or the model's context.Notes for review
webhook_configis required fortype: webhook, enforced by a dedicatedanyOfbranch in the schema, so a misconfigured toolset fails at parse time rather than at send time.LimitReaderbefore being echoed into an error, so a misbehaving endpoint can't flood the transcript.Verification
go test ./pkg/tools/builtin/webhook/ ./pkg/teamloader/toolsets/→ passinggolangci-lint run(repo's own.golangci.yml) → 0 issuesTestSchemaMatchesGoTypes,TestJsonSchemaWorksForExamples,TestDocYAMLSnippetsAreValid) → passingmarkdownlint-cli2fromdocs/→ 0 errors