Repository navigation
Description
Summary
Add an instance-level Slack webhook so agents can report operational (OPS) notifications to a single configured Slack channel with zero per-agent setup. Configured by one env var, mirroring the existing CANARY_SLACK_WEBHOOK_URL pattern; silent no-op when unset. Agents already emit structured notifications via the send_notification MCP tool (NOTIF-001) — those notifications currently surface only in the Trinity UI. This feature tees them to the configured Slack channel so operators see critical agent events where they already work.
Context / Motivation
Operators need agent OPS events (failures, alerts, questions, custom notifications) visible in Slack without configuring a per-agent Slack channel binding for every agent. The platform already proves this exact shape with the Canary watcher, which posts Block Kit alerts to CANARY_SLACK_WEBHOOK_URL via services/canary_alerts.py. Reusing that pattern gives an "easy integration": set one webhook URL, and any agent's notifications flow to the channel.
This is the instance-level, low-friction complement to the broader per-agent routing tracked in #224.
Scope
Configuration (instance-level)
- New env var
OPS_SLACK_WEBHOOK_URL(mirrorsCANARY_SLACK_WEBHOOK_URL). - Added to
.env.exampleanddocker-compose.ymlbackend env. - Unset = silent sink: notifications still persist + broadcast over WebSocket as today; no Slack post attempted.
- Optional per-notification-type on/off filter (e.g. route
alertanderrortypes, skip routineinfo).
Integration (easy path)
- Tee
send_notification(NOTIF-001) writes inrouters/notifications.pyto the webhook after the existing persist + WebSocket broadcast. - Fire-and-forget POST; a Slack failure must never fail or block the notification write.
- Block Kit composition reusing the
services/canary_alerts.py-style stateless composer (agent name, type/severity badge, title, body, timestamp, link back to the Trinity UI).
Out of scope (covered elsewhere)
- Per-agent Slack channel binding / per-channel routing — that is feat: Agent notifications to Slack with Ops integration (SLACK-NOTIFY) #224 (SLACK-002-based).
- Incident-classified routing decision /
INCIDENT_SLACK_WEBHOOK_URL— that is Define incident-response Slack mechanism (referenced by P-07 / P-25) #900. - Inbound Slack responses / ack-sync back to operator queue — deferred (part of feat: Agent notifications to Slack with Ops integration (SLACK-NOTIFY) #224's broader scope).
Acceptance Criteria
-
OPS_SLACK_WEBHOOK_URLis read at startup and documented in.env.example+docker-compose.yml. - When set, an agent
send_notificationcall results in a Block Kit message in the configured Slack channel. - When unset, no Slack POST is attempted and notification persistence/WebSocket broadcast is unchanged (silent sink).
- A Slack delivery failure (timeout, non-2xx) is swallowed and never fails the originating notification request.
- Notification type filtering is configurable (which types route to Slack).
- Message includes agent name, type/severity badge, title, body, and a link back to the Trinity UI.
- Unit test: composer renders expected Block Kit; sink is a no-op when the env var is empty.
Technical Notes
- Pattern to copy:
src/backend/services/canary_alerts.py(stateless Block Kit composer + webhook POST) and its env wiring insrc/backend/main.py/src/backend/routers/settings.py. - Integration point:
src/backend/routers/notifications.py— tee after the existing_broadcast_notificationstep. Keep the three-layer boundary: router calls a newservices/ops_slack_service.py(or extend the notification service); no HTTP/Slack logic inline in the router. - MCP surface: no new tool needed —
send_notification(src/mcp-server/src/tools/notifications.ts) is already the agent-facing entry point; this is a server-side fan-out. - Reliability: treat the webhook POST as best-effort fire-and-forget (consistent with how the agent liveness heartbeat and canary alerts are non-blocking).
Related Issues
- feat: Agent notifications to Slack with Ops integration (SLACK-NOTIFY) #224 — feat: Agent notifications to Slack with Ops integration (SLACK-NOTIFY) — broader, per-agent channel binding. This issue is the instance-level MVP slice of that surface.
- Define incident-response Slack mechanism (referenced by P-07 / P-25) #900 — Define incident-response Slack mechanism — the sibling instance-level-webhook decision (
INCIDENT_SLACK_WEBHOOK_URL); shares the canary-webhook pattern.
Activity