Automations: how a GitHub event becomes an agent task
Schedules, webhooks, GitHub, Slack, and Sentry triggers compile onto durable schedules and a fast-ack ingress. Here is the path from event to task.
5 min read
Four products became one#
Before automations, Nested had four separate ways to start work without a person: scheduled tasks, generic webhooks, a Slack bot, and a GitHub integration. Each had its own setup screen and its own template language for turning an event into a message. Building “when a pull request opens, review it” meant learning one of them; “and every Monday, summarize the week” meant learning another.
An automation is one object that says when (one or more triggers), which agent runs the work, and what it does — instructions, or a formula from that agent’s packs. Triggers are OR-combined: any of them firing starts a run.
The interesting part is what we did not build. Automations do not have their own timers or their own webhook receivers. They compile onto the pieces that already worked.
Compile, don’t re-implement#
When you save an automation, the server turns each trigger into its backing:
| Trigger | Backing |
|---|---|
| Schedule | A Temporal Schedule on a dedicated queue |
| Webhook | A generic inbound hook, tagged with the automation |
| GitHub | A binding on the official GitHub App’s deliveries |
| Slack | A binding on the Slack bot’s events |
| Sentry (and other catalog providers) | A binding on that provider’s ingress |
| Run now | Nothing — only manual runs |
Compilation is a compensating saga. If the third backing fails to create, the first two are deleted, so a half-saved automation never leaves a timer firing into nothing. On startup, a reconciler re-creates any backing that went missing. A paused automation keeps its schedules, created paused.
Schedules are calendars, not cron#
A schedule trigger has a timezone and one or more calendar entries (days of the week, time of day, day of month) or intervals. They are Temporal Schedule specs, not cron strings. That gives us timezone-correct firing and an explicit overlap policy for when a run is still going at the next tick.
Each firing starts a small workflow whose single activity has a two-minute timeout and up to five attempts. The idempotency key is derived from the workflow id, so a retried activity never starts the same run twice.
The ingress hot path is four steps#
Webhook providers are impatient. Slack expects an answer within about three seconds and GitHub within ten. So the ingress does as little as possible before it acknowledges:
- Resolve the target hook or binding.
- Verify the request.
- Deduplicate on the provider’s delivery id.
- Insert one row, and answer.
Everything else — rendering templates, matching bindings, creating tasks — happens afterwards in a worker pool that claims deliveries in batches with a lease. A transient failure retries with exponential backoff (starting at one second) up to eight attempts; after that, or on a permanent error, the delivery is marked failed and shows up in the deliveries list, where you can redeliver it.
Unknown, disabled, and deleted hooks all return the same empty 404, so an outsider cannot probe which URLs exist. Request bodies are capped at 1 MiB.
How each source is verified#
| Source | Verification | Replay protection |
|---|---|---|
| Generic webhook | HMAC-SHA256 of the raw body in X-Hook-Signature (recommended), a shared token, or none | Dedupe only, when the caller sends X-Idempotency-Key |
| GitHub App | X-Hub-Signature-256 HMAC with the App’s webhook secret | Dedupe on the delivery id |
| Slack | v0 HMAC over timestamp and body | ±5-minute timestamp window, plus event-id dedupe |
| Sentry | sentry-hook-signature HMAC | Dedupe on the delivery id |
All comparisons are constant-time. Signature headers and secrets are redacted before a delivery is stored. Hook secrets are encrypted at rest, and a webhook trigger shows you its secret exactly once when you create it.
Two honest caveats. Only Slack enforces a timestamp window; the others rely on deduplication. And “none” is available for generic hooks because some senders cannot sign — the app makes you type the hook’s name to confirm it.
From event to task#
Whether the trigger was a timer or a delivery, a run follows the same path:
- Load the automation. If it is paused (and this is not a manual run), record a skipped run and stop.
- Deduplicate on the idempotency key, and create a running run.
- Make sure the automation has its stable context, so all its tasks group under its name.
- For instructions: create a task with request kind
automationand send your instructions as the first message, with the event payload appended (capped at 64 KiB). For a formula: map the event payload onto the formula’s inputs and start a run. - Store the task as submitted. If the agent was stopped for being idle, the task service wakes it.
- The agent claims the task from the queue and works on it like any other.
Slack and GitHub deliveries can match several bindings at once — a GitHub delivery fans out to one task per matching agent and automation.
Talking back#
An automation can also answer where the event came from:
- Acknowledge comments adds an emoji reaction to the GitHub comment that matched, so the person who wrote it sees the delivery landed before the agent even starts.
- Comment on the pull request posts the agent’s final message on the PR.
- Slack posts the result in a channel or in the originating thread. The task service pushes status snapshots to a per-task URL, checked with a per-task bearer token, and follow-ups in the thread continue the same task.
- While it runs, the agent can be allowed to read the Slack channel the automation is bound to — and only that channel.
Closing the loop on fire-and-forget work#
A normal agent turn ends in “needs you”, because the person who asked decides when the work is done. For a weekly digest, nobody is going to come back and click Complete. So automations have an opt-in flag: mark the task complete when the agent finishes. A durable watch polls the task every 15 seconds for up to 24 hours and completes it once the agent has stopped and nothing is still running in the background. Formula runs ignore the flag; the formula decides when it is done.
Reports without a model#
Every closed UTC day, a schedule at 00:15 UTC asks the task, automation, and formula services for structured facts and writes a frozen report per agent and per account: outcomes by kind, successes and failures per automation and formula, active and wall-clock latency with p50 and p95, what was still open, and the change from the previous period. Weeks fold on Sundays and months at month end. The current day refreshes hourly.
Reports deliberately contain no LLM summaries, no message text, and no token totals. They are counts you can trust, kept for 24 months.
Closing#
The pattern underneath is the same one we use everywhere: acknowledge fast, persist first, do the work durably, and make every run visible in history. Start with Automations, or go straight to Webhooks and GitHub.
Last revised .
Questions
- Does Nested support cron expressions for schedules?
- Schedules use calendar entries (days, time of day, day of month) and intervals with a timezone, backed by Temporal Schedules, rather than cron strings.
- How are Nested webhooks secured?
- Generic webhooks verify an HMAC-SHA256 signature of the raw body (or a shared token), GitHub and Sentry use their signature headers, and Slack adds a five-minute timestamp window. Secrets are encrypted at rest and shown once.
- What happens if the agent is stopped when an automation fires?
- The task is queued as submitted and the task service asks the deploy service to wake the agent. The agent picks the task up when it is running again.
- Do reports use an LLM to summarize activity?
- No. Reports are built from structured counts and latencies only, with no message text, summaries, or token totals.
More from the blog
6 min read
Inside cloud-agent: how a Nested agent runs, sleeps, and recovers
What runs in each agent pod: ACP sessions with Cursor, Claude Code, or Kimi, the sandbox, idle scale-to-zero, crash recovery, and drain-and-restart reloads.
6 min read
The Nested security model, layer by layer
Sign-in, tokens, teams, secrets at rest, site logins, agent sandboxes, and audit: how Nested protects an install, and the gaps we have not closed yet.
6 min read
Agents talking to agents: tasks, A2A, and discovery in Nested
Every request to an agent is a task in one system of record. How Nested uses the A2A model for delegation, discovery, lineage, and who closes a task.