Skip to main content

02. AI Agent Fundamentals

Reflex Agents (Simple and Model-Based)

Reflex agents map situations to actions with rules. Simple reflex uses only the current percept; model-based reflex keeps an internal world state first — still reactive, not goal planners.

What you will learn

  • Define simple vs model-based reflex agents clearly
  • Draw both loops and explain where state lives
  • Know when reflex rules beat (or lose to) goal-based agents
  • Map reflex patterns onto LLM product designs
  • Answer interview questions with short, solid answers
Simple reflex versus model-based reflex agents side by side
Interview staple: same rule idea — one uses percept only, the other updates state first.

Definition

Reflex agents select actions from condition–action rules. They react to what they sense; they do not search for a distant goal the way goal-based agents do.

A simple reflex agent looks only at the current percept. A model-based reflex agent maintains an internal state (a world model) that summarizes what it cannot see right now, then applies rules to that state.

Both are foundational in the classic taxonomy and still appear in production as fast-path policies, safety denials, and deterministic routers next to LLM planners.

Introduction

This lesson (#3 in AI Agent Fundamentals) deepens the first two types from Types of AI Agents. Next you will cover goal-based, utility-based, and learning agents.

Master these before calling every chatbot an “agent.” Many systems are mostly reflex with a thin LLM layer.

Why reflex agents matter

  • Fast, cheap, and auditable — ideal for safety and routing
  • Clear teaching model for how agents decide
  • Explain why memory/state is required under partial observability
  • Production hybrids: reflex guards + goal-based LLM core

Simple reflex agents

Decision depends only on the current percept via a condition–action rule table (or hard-coded if/else). No history, no plan, no utility score.

Simple reflex agent loop from environment through rules to actuators
Percept → match rule → act. Transparent and easy to test.
  • Form — if condition(percept) then action
  • Best when — environment is mostly fully observable and the mapping is stable
  • Examples — spam threshold quarantine; keyword intent reply; thermostat on/off; rate-limit block
  • Failure mode — incomplete percept → wrong action; needs context it does not store

Model-based reflex agents

The agent keeps an internal state that estimates the world. Each percept (and often the last action) updates that state. Rules then fire on the state, not on the raw percept alone.

Model-based reflex agent with world model between percept and rules
State bridges what sensors miss — still rule-driven, not goal search.
  • Form — state ← update(state, percept, action); if condition(state) then action
  • Needs — a model of how the world evolves and how actions change it
  • Examples — vacuum tracking cleaned cells; ticket bot remembering fields already collected; session cart / auth flags
  • Failure mode — bad or stale model → confident wrong actions

What “world model” means here

In classic AI, the model is often a structured state object (flags, maps, entity fields). In Agentic AI products, the same role is played by short-term memory, session context, scratchpads, or a small database row — not necessarily a physics simulator.

  • Hidden variables you must remember between turns
  • Transition knowledge: after action A, expect observation O
  • Enough structure for rules to fire reliably
  • Not the same as a full planner or utility function

Simple vs model-based — quick contrast

  • Input — simple: current percept only · model-based: percept + prior state
  • Memory — simple: none · model-based: yes (world model)
  • Partial observability — simple: weak · model-based: stronger
  • Planning — neither searches future goal paths; both stay reactive
  • Complexity — simple wins for fixed maps; model-based for multi-turn state

When to use each

  • Use simple reflex for clear thresholds, allow/deny, and deterministic routers
  • Use model-based when the next action depends on prior turns or hidden status
  • Escalate to goal-based when success needs multi-step planning toward an end state
  • Keep reflex layers even inside LLM agents for policy, PII, and spend limits

Mapping to Agentic AI / LLM systems

Modern products rarely ship as pure textbook reflex agents, but they reuse the pattern heavily.

  • Guardrail middleware — simple reflex on tool name, user role, or risk score
  • Intent classifiers / routers — reflex to pick a skill or workflow
  • Session state + rules — model-based before the LLM is even called
  • Hybrid — reflex fast-path; goal-based LLM loop only when needed
  • Memory store — the production “world model” for model-based behavior

Program / implementation notes

Implement reflex agents as data + code, not as a vague prompt. Rules should be reviewable in git.

  • Store rules as ordered tables or policy configs with tests
  • For model-based, define an explicit state schema and update function
  • Log which rule fired and the state snapshot for debugging
  • Add timeouts and default actions when no rule matches
  • Next: Goal-Based, Utility-Based and Learning Agents — beyond pure reaction

Advantages and limitations

  • Advantage: speed, cost, and explainability
  • Advantage: strong fit for safety and compliance gates
  • Advantage: model-based handles multi-turn context without a planner
  • Limitation: brittle when the world changes faster than rules
  • Limitation: neither type optimizes long-horizon goals or trade-offs by itself
  • Limitation: stale world models silently mislead

Key points

  • Simple reflex: condition–action on the current percept only.
  • Model-based reflex: update internal state, then apply rules to that state.
  • Neither searches toward goals — that is goal-based territory.
  • Partial observability is why world models exist.
  • Production systems use reflex layers for routing and guardrails beside LLM planners.
  • Prefer explicit rule tables and state schemas over buried prompt logic.

FAQs

Is a chatbot with if/else intents a simple reflex agent?

Often yes for the decision layer. If it also stores session slots and rules over those slots, it is model-based reflex (or a hybrid).

Does adding an LLM make it stop being a reflex agent?

Not automatically. If the LLM only formats a reply after a fixed rule chooses the action, the control policy is still reflex. If the model plans multi-step tool use toward a goal, it is closer to goal-based.

How is a world model different from long-term memory?

A world model is the current estimate needed for the next rule. Long-term memory may store facts across sessions; model-based reflex needs at least short-term state that updates each step.

When should I upgrade from model-based reflex to goal-based?

When success requires choosing among action sequences to reach an end state — not just reacting to the current (or estimated) situation.

Interview questions

  1. What is a simple reflex agent?

    Answer An agent that selects actions using condition–action rules based only on the current percept, with no internal memory of past states.

  2. What is a model-based reflex agent?

    Answer An agent that maintains an internal world state updated from percepts (and often actions), then applies rules to that state before acting.

  3. Why do we need model-based agents?

    Answer Because many environments are partially observable — the current percept alone is not enough, so the agent must remember and estimate hidden state.

  4. Are reflex agents the same as reactive agents?

    Answer Closely related: both emphasize reacting to stimuli. “Reflex” usually implies explicit condition–action machinery; “reactive” is a broader behavior label.

  5. Give one production example of each.

    Answer Simple: block a tool call if risk_score > T. Model-based: support bot that tracks which form fields are filled and asks only for the missing ones.

  6. How do reflex agents differ from goal-based agents?

    Answer Reflex agents map situations to actions with rules. Goal-based agents choose actions by considering future outcomes that achieve a goal state.

  7. Where do reflex patterns appear inside LLM agents?

    Answer In routers, allow/deny guardrails, deterministic pre/post checks, and session-state rules that run before or around the LLM loop.

Related topics

Practice task

Complete each numbered practice step in a notebook or doc before opening the next lesson.

  1. Write the one-line definitions of simple and model-based reflex agents.
  2. Draw both loops from memory and label percept, rules, state, action.
  3. Classify two apps you use: simple reflex, model-based, or hybrid — justify each.
  4. Design five condition–action rules for a spam or support fast-path.
  5. Answer interview questions 1, 3, and 6 in two sentences each.