II · Planning & Control FlowMature★★

Event-Driven Agent

also known as Event Subscriber, Reactive Agent, Webhook Agent

Trigger the agent on external events (webhooks, message queues, file changes) instead of user requests or schedules.

This pattern helps complete certain larger patterns —

  • used-byLLM as Periphery·Invert the typical LLM-in-the-middle architecture: a deterministic state machine and event store form the core; the LLM is restricted to edge tasks — input interpretation and output synthesis only.

Context

A team operates an agent whose job is to react to things happening in the wider system — a pull request opened on a repository, a customer message arriving in a queue, a monitoring alert firing, a file appearing in a watched folder. The work should happen when the event occurs, not when a human remembers to ask and not on a fixed schedule. An event source (webhook, message queue, file watcher) is already available or can be added.

Problem

If the agent has to discover these events by polling a status endpoint on a schedule, most polls find nothing and burn tokens and quota; the few that find something arrive up to one polling-interval late. Inviting the agent only on user demand misses everything that happens overnight. Wiring the agent naively to an event firehose without validation, deduplication, or rate limits exposes it to event storms, replayed deliveries, and spurious triggers that can drain budgets or cause duplicate side effects.

Forces

  • Event source reliability.
  • Burst handling: event storms can overwhelm.
  • Dedup of events that fire multiple times.

Example

A monitoring agent polls a status endpoint every thirty seconds to see whether a build has finished. Most polls find nothing, burning tokens. The team flips to Event-Driven Agent: the build system fires a webhook on completion, and the agent wakes up only when an event arrives. Latency to react drops from up to thirty seconds to roughly the webhook round-trip, and idle cost drops to near zero.

Diagram

Solution

Therefore:

Subscribe to event source (webhook, queue, watcher). On event, validate, deduplicate, and invoke the agent with event payload as input. Apply rate limiting and idempotency. Acknowledge after successful processing.

What this pattern forbids. The agent runs only on validated events; spurious or duplicate events are filtered.

And the patterns that stand alongside it, or against it —

  • alternative-toScheduled Agent★★Run the agent on a fixed schedule independent of user requests.
  • complementsRate Limiting★★Cap the number of requests, tokens, or tool calls per user (or session) within a time window.
  • complementsAgent Resumption★★Persist agent execution state so a long-running run survives restarts, deploys, or user disconnects.
  • complementsSalience-Triggered Output·Have the agent emit a message only when an internal salience signal crosses a threshold, not on every cycle.
  • complementsActor-Model AgentsImplement each agent as an independent actor with its own mailbox, processing asynchronous messages one at a time and never sharing mutable state with peers.
  • complementsTopic-Based RoutingRoute inter-agent messages through named topics that agents subscribe to, instead of having senders address each other by id.
  • complementsVisual Workflow Graph★★Express agentic logic as a visual graph of typed nodes connected on a canvas with Start and End nodes so non-coding stakeholders can read and edit the flow.
  • alternative-toBlocking Sync Calls in Agent LoopAnti-pattern: run synchronous, blocking I/O inside the agent loop or HTTP handler, capping concurrency at the number of OS threads.
  • alternative-toOrchestrator as BottleneckAnti-pattern: route all agent runs through a single-process orchestrator that becomes the system-wide concurrency ceiling.
  • complementsStateless Reducer AgentDesign the agent as a pure function (state, event) → newState; entire execution history is held in an external event log; enables pause / resume / replay / time-travel without bespoke checkpointing.
  • complementsStigmergic Coordination★★Agents coordinate indirectly by leaving and reading marks in a shared environment (files, queues, scratchpads, world model) so that one agent's trace stimulates another's next action, with no direct messaging.
  • complementsCDC-Driven Vector Sync★★Treat the source-of-truth document store as the only writer; keep the vector index in sync by emitting change-data-capture events onto a queue that the feature pipeline consumes.
  • complementsStreaming Feature PipelineProcess raw documents into RAG features as a continuous stream rather than a batch job, with typed models pinning each stage.

Neighbourhood

Click any neighbour to follow the language. Scroll to zoom, drag to pan.

Used in frameworks

Show 10 more

References

Provenance