Reactive agent: fast, rule-driven responses with no plan
A reactive agent maps each input straight to an action, with no plan and no memory of earlier steps. Use it when the right response is clear from the current input alone and speed matters.
Reactive agent in 60 seconds
- What: an agent that picks an action from the current input only. No plan, no stored history, no look-ahead.
- How: match the input to a rule or a learned policy, take the action, then wait for the next input.
- Best for: alert triage, request routing, simple moderation, and any task where the answer is obvious from one event.
- Weak spots: anything that needs several steps, context from earlier turns, or a choice between competing goals.
- Why it matters: it is the cheapest, fastest, and most predictable agent, so it is often the right first layer in front of heavier types.
Where this type fits
The types of AI agents hub groups agents by how they decide. The reactive agent sits in the first family, alongside planning, ReAct, plan-and-execute, reflexive, and learning agents. It is the simplest member. Every other type in that family adds something to it: a plan, a loop with tools, a critique step, or a way to learn. Knowing the reactive agent well tells you exactly what each of those additions buys.
The problem it solves
Imagine a team that sends every incoming event through a full reasoning loop. A disk-space alert arrives at Acme. The system asks a large model to think about it, search for context, draft a plan, and then act. The answer is always the same: clear the temporary folder and notify the owner. The loop worked, but it took several seconds, cost real money, and sometimes produced a different answer on a different day. For a decision that never needed thought, that is waste and risk.
The second problem is predictability. Teams that run agents in production need to explain why the system did something. A rule that says "if the alert type is disk full, run the clean-up job" can be read, tested, and audited in a minute. A multi-step reasoning trace cannot. When the stakes are low and the mapping is clear, a transparent mapping beats a clever one.
The third problem is load. Some inputs arrive thousands of times a minute. A design that spends seconds per input cannot keep up, and a queue of unhandled events is its own failure. A reactive agent answers in milliseconds when it uses rules or a small classifier, and in one model call when it uses an LLM. It gives you a safe, quick default path, and you can reserve slower agent types for the inputs that truly need them.
How it works
- Receive an input event. This might be an alert, a chat message, a webhook, or a sensor reading. The agent sees only this event and a fixed configuration.
- Normalise it. Clean the input into a small, predictable shape: a type, a few fields, and maybe a confidence score from a classifier.
- Match it to a rule or policy. A rule table is checked in priority order. A learned policy, such as a small classifier or a single LLM call with a closed list of labels, returns the best match.
- Take the action. Run the one action tied to the match. Good actions are narrow and safe to repeat, such as tagging, routing, replying with a template, or starting a known job.
- Wait for the next input. Nothing carries over. If two events belong together, the agent does not know.
The diagram has two halves. The top row is the whole behaviour. There is no branch that asks "what should I do next after this?" because the agent never asks it. The dashed boxes underneath are the design trade, stated openly. Each is a feature you give up in return for speed and clarity.
One point is easy to miss. A reactive agent can still use a model. The label "reactive" describes the control flow, not the technology. If an LLM reads a message and returns one of six labels, and your code maps each label to one action, that is a reactive agent. What makes it reactive is that no step depends on an earlier step.
A worked example
Acme runs a monitoring system. Its on-call channel receives alerts, and a reactive agent handles the routine ones. The rule table has four entries, checked in order: disk_full runs the clean-up job, cert_expiring opens a renewal ticket, login_spike pages the security team, and anything else goes to the general queue.
At 02:14 this event arrives: {"type": "cert_expiring", "host": "shop-eu-3", "days_left": 9}. The agent normalises it, which here means checking that the type is a known string and the fields exist. It scans the table. The first rule that matches is cert_expiring. The action is "open a ticket in the renewal queue, priority normal, with the host and days left". The agent calls the ticket service once, logs the rule name that fired, and returns to waiting. Total time is a few milliseconds plus the ticket call.
At 02:15 a second event arrives: {"type": "cert_expiring", "host": "shop-eu-3", "days_left": 9} again, because the monitor repeats alerts. The agent has no memory, so it opens a second ticket. This is the classic weakness. The fix is not to give the agent memory. The fix is to make the action safe to repeat, for example by using the host and certificate as an idempotency key (see idempotency) so the ticket service ignores the duplicate.
[
{"when": {"type": "disk_full"}, "action": "run_cleanup", "safe_to_repeat": true},
{"when": {"type": "cert_expiring"}, "action": "open_ticket", "safe_to_repeat": true},
{"when": {"type": "login_spike"}, "action": "page_security", "safe_to_repeat": false},
{"when": {}, "action": "send_to_general", "safe_to_repeat": true}
]Building it
The sketch below shows the whole pattern. It checks rules in priority order, falls back to a safe default, guards against duplicate events, and applies a timeout to every action. The names call_action and classify_with_model are placeholders for your own code, not a real library.
import time
# Placeholders: replace with your own integrations.
def call_action(name, event, timeout_s):
... # run the named action; must raise on timeout
def classify_with_model(event):
... # one LLM call that returns a label from a closed list, or None
RULES = [
(lambda e: e.get('type') == 'disk_full', 'run_cleanup'),
(lambda e: e.get('type') == 'cert_expiring', 'open_ticket'),
(lambda e: e.get('type') == 'login_spike', 'page_security'),
]
DEFAULT_ACTION = 'send_to_general' # safe fallback: a person sees it
ACTION_TIMEOUT_S = 5 # never let one action block the loop
DEDUP_TTL_S = 300 # ignore identical events for 5 minutes
MODEL_CONFIDENCE_MIN = 0.8 # below this, use the default
seen = {} # event key -> time first seen (in production use a shared store with a TTL)
def event_key(event):
# Why: the agent has no memory, so duplicates must be caught by key.
return (event.get('type'), event.get('host'))
def is_duplicate(event, now):
key = event_key(event)
first = seen.get(key)
if first is not None and now - first < DEDUP_TTL_S:
return True
seen[key] = now
return False
def choose_action(event):
for matches, action in RULES: # cheap, explainable rules first
if matches(event):
return action, 'rule'
label = classify_with_model(event) # only reached when no rule fits
if label and label['confidence'] >= MODEL_CONFIDENCE_MIN:
return label['action'], 'model'
return DEFAULT_ACTION, 'default'
def handle(event):
now = time.time()
if is_duplicate(event, now):
return {'status': 'ignored_duplicate'}
action, source = choose_action(event)
try:
call_action(action, event, ACTION_TIMEOUT_S)
status = 'done'
except Exception:
# Why: a failed action must not crash the loop. Escalate to a person.
call_action(DEFAULT_ACTION, event, ACTION_TIMEOUT_S)
status = 'escalated'
# Log the decision source so every action can be explained later.
return {'status': status, 'action': action, 'source': source}
Three details are worth noticing. Rules run before the model, so the common cases cost nothing. The model is only a fallback, and its answer is accepted only above a confidence threshold. And every result records whether a rule, the model, or the default made the decision. That one field makes later review far easier.
Design decisions
- Rules or learned policy: start with rules. They are free, instant, and explainable. Add a classifier or a closed-label LLM call only for the long tail that rules cannot cover.
- Fallback action: always define one, and make it harmless. Routing to a human queue is a good default because it fails safe.
- Idempotent actions: assume every event can arrive twice. Use idempotency keys or check-then-act logic in the action itself, since the agent will not remember.
- Latency budget: set a hard time limit per action and per decision. A reactive agent exists to be fast, so a slow action defeats its purpose.
- Access control: give each action the least permission it needs. Because rules are fixed, you can grant narrow rights per action rather than one broad role.
- Versioning: store the rule table in version control and log the version with every decision. A change to a rule is a change to production behaviour.
- Escalation path: decide up front which inputs should leave the reactive layer and go to a planning or ReAct agent, and how the hand-off works.
Measuring it
- Action accuracy: take a labelled sample of past events with the correct action. Accuracy is the share of events where the agent chose that action. Report it per rule, not just overall.
- Coverage: the share of events handled by a rule or the model above threshold, rather than by the default. Low coverage means the rule table is stale.
- Fallback rate: the share of events that hit the default action. A rising rate often signals a new kind of input.
- Decision latency: time from receiving the event to starting the action. Track the median and the 95th percentile.
- Duplicate and error rate: count repeated actions caused by repeated events, and failed actions that needed escalation.
When to use it, and when not to
| Situation | Use this type? | Why |
|---|---|---|
| Routing alerts or tickets to the right queue | Yes | The label is clear from the input and speed matters. |
| Replying to a fixed set of frequent questions with templates | Yes | Each question maps to one answer, so no planning is needed. |
| Filtering obvious spam or unsafe content before a slower check | Yes | A cheap first layer removes most volume. |
| A request that needs several tool calls in sequence | No | A reactive agent cannot carry results from one step to the next. Use a ReAct or planning agent. |
| A conversation where earlier turns change the meaning of later ones | No | It keeps no history, so it will misread follow-up messages. |
| Tasks where the best action depends on weighing trade-offs | No | There is no look-ahead or scoring. A goal or utility agent fits better. |
Trade-offs
| Dimension | Effect | What to do about it |
|---|---|---|
| Quality | Excellent on clear inputs, poor on ambiguous or multi-step ones. | Escalate low-confidence inputs to a heavier agent or a person. |
| Latency | Lowest of any agent type. Milliseconds for rules, one model call otherwise. | Keep actions short and set timeouts. |
| Cost | Very low per event. Rules are free, and one model call is small. | Put rules before any model call. |
| Complexity | Simple to build, test, and explain. | Resist adding hidden state. If you need it, pick a different type. |
| Failure modes | Repeats on duplicate events, misses context, and acts on stale rules. | Use idempotent actions, review the rule table regularly, and watch the fallback rate. |
Compared with related types
The closest neighbour is the planning agent. It writes out the steps before it acts, which suits tasks with several dependent stages. That plan costs time and tokens, so use it only where a single action cannot do the job. The ReAct agent goes one step further by looping between thinking and tool use, adjusting as it learns. It handles open-ended questions but is slower and harder to predict.
A common design layers them. A reactive agent handles the routine majority in milliseconds. Anything it cannot place, or places with low confidence, is handed to a heavier agent. The tool-using agent page covers how actions are validated and permitted, which applies directly to the actions a reactive agent triggers.
What this means for your role
Common mistakes
Further reading
- Types of AI agents: the hub page that compares every agent type.
- Russell and Norvig, Artificial Intelligence: A Modern Approach: a book that sets out the classic agent taxonomy of simple reflex, model-based, goal-based, utility-based, and learning agents. The reactive agent here corresponds to the simple reflex kind.
- Idempotency: how to make repeated actions safe.
- Guardrails and safety: checks to place around actions.
A reactive agent is the smallest useful agent, and that is its strength. Build it first, measure how many inputs it handles well, and add heavier types only for what remains.