Skip to main content
Handbook/Automate/Page 88 · Triggers

React Instead of Waiting

Share

Share this page

Pass it to someone who needs it.

Star on GitHub

Key takeaway: Make agents react the instant something happens

Scheduling put your agents on a clock. But some work cannot wait for the clock: it has to happen the instant something occurs. That is the other half of autonomy, the reflex, and it is what this short chapter adds.

9.16.1Scheduled is proactive, triggered is immediate

A scheduled agent asks, "is it time yet?" A triggered agent asks, "did the thing happen?"

The first is a heartbeat, steady and periodic. The second is a reflex, dormant until an event pokes it, then instant. A serious system has both: the heartbeat does the rounds, the reflex catches the fire the moment it starts.

9.16.2Some problems can't wait for the next sweep

A payment fails. A key expires. An error spikes. If your only mechanism is a schedule, the damage runs until the next tick fires.

Reflexes exist for exactly the events where the gap between "it happened" and "we responded" has to be near zero. You do not schedule a smoke detector to check for fire each morning; you wire it to react the instant there is smoke.

Here is the whole reflex on one event:

  1. An error lands in the ledger.
  2. The reflex wakes and pulls the real context: the stack trace, the recent changes, the live state.
  3. Safe and reversible? It makes the fix, proves it with a test, and ships it through review.
  4. Costs money or touches user data? It stops, files a decision card, and waits for you.

Investigating is always safe, so that part runs on its own; only the risky call waits for you.

9.16.3Triggers listen to the ledger

A reflex is an agent watching the event stream for one specific line. Something has to do the watching, and the simplest version is a small watcher on a tight loop. It reads new lines in the ledger every few seconds, and when a line matches, it runs the right agent.

Bigger setups let the tool that raised the alert, the automatic warning something is wrong, call a web address itself. The idea is the same, a rule that maps an event to an agent:

on event alert.fired -> run incident-responder on event payment.failed -> run billing-retry
A watcher reads new ledger lines on a tight loop and runs the mapped agent when one matches.

Watch out: the same event can arrive twice, and a reflex that fires twice can charge the customer twice. Have it mark the event handled before it acts. Have a scheduled job skip if its last run is still going. That way nothing ever runs on the same thing twice.

This is why the ledger comes first: without one honest stream of events, there is nothing to watch. With it, any event can become a trigger.

9.16.4Together they cover the whole clock

Heartbeat plus reflex is complete coverage of time. The scheduled agents handle the rhythm of the work, the routine that happens on a cadence. The triggered agents handle the surprises, the events that arrive on their own and demand a response now.

Between the two, nothing falls through: if it happens on a clock, the heartbeat has it; if it just happens, a reflex catches it.

Hint: reach for reflexes once you have a ledger and a few events that genuinely cannot wait for the next scheduled run.

9.16.5Wire your first reflex

This prompt gives your system its first reflex:

Ready prompt
Act as a senior engineer adding an event-driven trigger to my system. Read my event ledger, my guardrails file, and the jobs already on my scheduler, then pick the one event that most needs an instant response and is not already covered by a job on a clock. Watch the ledger for it and run the right agent the moment it lands. Use an approach that works on my operating system. Keep the agent's job small, inside the guardrails I already set, and record the trigger as one line in my decision log. If you need the full reasoning behind this step, read https://zalt.me/guides/vibe-coding/ai-os/triggers My operating system and the event that can't wait:

Do this now: paste the prompt and wire one reflex to the single event you would hate to catch a day late.

Mahmoud Zalt

Mahmoud Zalt

Software engineer, 16+ yrs · built Sistava.com in 3 months, idea to production, using these methods

Resources
Star on GitHubContribute
Donate

Support my work

A small tip keeps the free work coming.

© 2026 Mahmoud Zalt. Free to read, not to republish.
Copyright & license