Repository navigation
Description
Summary
Add outbound webhooks to the Automation Service so workspace owners can receive signed HTTP callbacks for automation lifecycle events — starting with run.failed — and route failure notifications into any system they already use (PagerDuty, Teams, custom internal tooling, etc.).
Requested by @anton-osmond (customer-facing motivation: customers who don't use Slack need a flexible way to get failure notifications), and endorsed in Slack as "pretty helpful."
Motivation
- Automations can fail silently, especially with infrequent schedules. Related issues: Notify the owner when an automation run fails (esp. low-frequency schedules) #407 (notify the owner when a run fails) and Support post-run callbacks inside automation sandboxes #208 (post-run callbacks inside sandboxes).
- Email/Slack notifications alone aren't enough: customers use a variety of alerting systems and want to integrate programmatically — outbound webhooks make this possible in many places at once.
- The requested model mirrors how Jira/GitHub webhooks work today: configure a destination, scope it all-or-nothing or per-event, and let consumers filter by event type.
Proposed UX (Canvas → Automate)
Add an Outbound webhooks section under Automate:
- Enter a destination URL.
- Choose all automations in the workspace or select specific ones.
- Pick which events to subscribe to — start with
run.failed. - A Send test button and a last delivery status indicator so users can verify the endpoint works before relying on it.
Proposed behavior (Automation Service)
- Send a signed webhook when a run is recorded as failed, even if the sandbox never starts.
- Payload includes: automation name, a short failure reason, and a link to the run.
- If the endpoint is temporarily unavailable, retry delivery without rerunning the automation.
Scope / placement
Build this in the shared Automation Service and Canvas so the same setup works for both Enterprise and open-source deployments.
Related
- Notify the owner when an automation run fails (esp. low-frequency schedules) #407 — Notify the owner when an automation run fails (especially low-frequency schedules)
- Support post-run callbacks inside automation sandboxes #208 — Support post-run callbacks inside automation sandboxes (in-sandbox alternative approach; worth evaluating whether outbound webhooks are the better way to support this)
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
Scope (Automation Service only): Add organization-scoped outbound webhook endpoints so owners receive signed HTTP callbacks when a run reaches a terminal FAILED state, starting with the run.failed event. The design follows this repository's own precedents: org-owned webhook records with HMAC signing secrets (mirroring the CustomWebhook model and webhook_router.py), manage_automations as the permission for endpoint CRUD (same as inbound webhook routes), and the failure data that every terminal writer already persists via mark_run_terminal / mark_run_status (error_detail, status_detail in utils/run.py) — covering dispatch failures before the sandbox starts, callback-reported failures, and watchdog timeouts. Delivery is retried a bounded number of times on transient failures without rerunning the automation, with a per-endpoint delivery status and a test-delivery request, as the issue proposes.
Non-goals: the Canvas "Outbound webhooks" UI (owned by OpenHands/OpenHands per AGENTS.md; a needs-canvas-release follow-up if the API lands first), event types beyond run.failed, in-sandbox post-run callbacks (#208), the general user-notification service (#121/#407), changes to run-state transitions, and delivery guarantees beyond bounded retry of transient failures.
The only product detail this repository cannot decide alone is the run-link URL, which needs a deployment base URL. The service can take it from its existing AUTOMATION_-prefixed configuration pattern; the criteria treat the link as present when a base URL is configured and make documenting that requirement part of the work.
Desired Behavior
When a run is recorded as FAILED — whether the sandbox never started, the run reported failure through its callback, or the watchdog timed it out — every outbound webhook endpoint subscribed to run.failed and scoped to that automation (or to all automations in the organization) receives a signed HTTP POST containing the event type, the automation's name and ID, the run ID, a short failure reason, the run link (when a base URL is configured), and event/run timestamps. A temporarily unavailable endpoint gets bounded retries without the automation being rerun. Owners configure endpoints (destination URL, signing secret, automation scope, event subscription), can send a test delivery, and can see the last delivery status for each endpoint.
Acceptance Criteria
- A user with
manage_automationscan create an outbound webhook endpoint (destination URL, signing secret, event subscription includingrun.failed, and scope of all automations or an explicit automation list); list, get, update, and delete work, and users missingmanage_automationsor from another organization are rejected with 403/404. - After creation, the signing secret is not returned in cleartext by list/get/update responses and is not written to logs, matching the existing
custom_webhookssecret handling. - When a run is marked
FAILED, each subscribed endpoint scoped to that automation receives an HTTP POST whose body includes eventrun.failed, the automation name and ID, the run ID, a short failure reason derived from the run's persisted failure detail, and event/run timestamps. - Each delivery is signed (HMAC-SHA256 over the raw body in a documented header), so a receiver holding the secret can verify the body and a receiver can reject an invalid signature.
- A run that fails before the sandbox starts (dispatch failure) triggers a delivery, verified by a test that fails a run pre-dispatch and observes the delivery attempt.
- When the endpoint is unreachable or answers non-2xx, delivery is retried a bounded number of times with backoff, the automation is not rerun, and each attempt's outcome is recorded.
- The last delivery status (most recent attempt time and outcome) is retrievable per endpoint, and a test-delivery request sends a signed test payload and reports its result.
- Deleting or disabling an endpoint stops its deliveries, and removing an automation that an endpoint is scoped to leaves no orphaned references and does not break the endpoint's other subscriptions.
- New tables/columns behave identically on PostgreSQL and SQLite and ship in one coherent Alembic migration with a single head and an upgrade path from the released schema.
- A page under
docs/documents endpoint setup, signature verification, and the run-link base-URL configuration requirement, and an integration test delivers a real run-failure event to a live local HTTP receiver rather than only asserting on mocks.
Activity