( Engineering Notes · 2026 · 4 min read )
Process Once, Deliver Everywhere: Reliable Scheduled Agent Pipelines
How to design fan-out pipelines that process expensive work once and deliver it to every subscriber without ever silently dropping a run.
Many products share a hidden shape: an expensive piece of work, such as parsing a long document and extracting structured data from it with an LLM, whose result many customers need. Doing that work once per customer multiplies cost and produces inconsistent answers. The better design is to process once centrally, publish the result to a feed, and deliver it to every subscriber. The hard part is not the processing; it is making delivery reliable enough that no customer ever silently misses an update.
Why this architecture matters
The shape in one line: producer, then a durable outbox, then a feed with stable IDs, then a scheduler that sweeps subscriptions, then delivery workers, then the subscriber's own store.
How to build it well
1. Give every item a permanent global ID before publishing
Revisions, deduplication and cross-references all depend on stable identity. If an item does not have its global ID yet, the outbox should defer it rather than publish something that cannot be referenced later.
2. Use the outbox pattern
Write the event in the same transaction as the source change, and let a separate worker publish it. Never write to the database and the queue as two separate steps. Sooner or later one of them fails and the two disagree.
3. Build a scheduler that never loses a minute
A naive cron job that runs "if due now" loses every run that falls inside an outage. Track a high-water mark instead: each sweep evaluates every minute since the last completed one, oldest first, with a maximum backlog so recovery never turns into a storm. Tenants that fail for transient reasons go into a per-tenant backlog that is replayed later.
for m := lastDone.Add(time.Minute); !m.After(now); m = m.Add(time.Minute) {
if now.Sub(m) > maxBacklog {
abandoned++ // alert on this: it means real work was dropped
continue
}
if err := evaluateMinute(ctx, m); err != nil {
backlog.Add(tenantOf(err), m) // replay this tenant later
continue
}
lastDone = m
}4. Retry the right things, and cache what you depend on
Retry transient failures (502, 503, 504 and timeouts) with a small retry budget and backoff. Never retry 4xx responses. Keep a stale-if-error copy of configuration and directory lookups, so a brief blip in a dependency does not cancel an entire sweep.
5. Deduplicate by content, not by time
Compute the dedupe digest over the content itself and exclude volatile fields such as timestamps or retrieval timing. If you include them, every tick looks "new" and every subscriber is re-delivered the same item.
6. Deliver parents before children
If deliveries form a graph (a document, its sections, the tasks derived from them), deliver in tiers so no child ever references a parent that does not exist yet. Children whose parents are missing are deferred and retried, not failed.
7. Bound failure loops
Content that fails deterministically must not retry forever, especially when every attempt costs an LLM run. Cap the attempts, record why each one failed, and alert. An unbounded retry loop is a silent bill.
8. Sandbox every agent run
Run each delivery agent in an isolated, short-lived sandbox (a container or a serverless task) with credentials scoped to exactly one subscriber. Measure the unit cost per run from day one, so you know your scaling limits before your customers find them.
9. Secure external subscribers properly
For subscribers outside your network, derive a key for each client from a master secret using HMAC. Verification is then stateless, rotation is simple, and every rejected token can be logged with its source, which turns "mystery 401s" into a ten-minute investigation.
How to know it is working
Alert on the signals that mean customers are missing updates, not just on errors: