0
0
Agentic-aiConceptBeginner · 3 min read

Reactive Agent: Definition, How It Works, and Examples

A reactive agent is a simple AI system that responds directly to its current environment without using memory or past experiences. It acts like a reflex, making decisions only based on the present input it senses.
⚙️

How It Works

A reactive agent works like a reflex in humans or animals. Imagine a cat that instantly jumps away when it sees a sudden movement. It does not think about past events or plan ahead; it just reacts to what it senses right now.

In AI, this means the agent looks at its current environment, processes the immediate information, and chooses an action based on fixed rules or simple logic. It does not remember previous states or learn from past actions.

This makes reactive agents very fast and simple, but also limited because they cannot handle tasks that require memory or planning.

💻

Example

This example shows a reactive agent that decides what to do based on the color it sees. If it sees green, it moves forward; if red, it stops.

python
class ReactiveAgent:
    def __init__(self):
        pass

    def decide(self, color):
        if color == 'green':
            return 'move forward'
        elif color == 'red':
            return 'stop'
        else:
            return 'wait'

# Create the agent
agent = ReactiveAgent()

# Test the agent with different colors
print(agent.decide('green'))  # move forward
print(agent.decide('red'))    # stop
print(agent.decide('yellow')) # wait
Output
move forward stop wait
🎯

When to Use

Reactive agents are best when you need quick, simple responses without complex thinking. They work well in environments where the situation changes fast and memory is not needed.

Examples include:

  • Robots that avoid obstacles by reacting to sensors
  • Video game characters that respond instantly to player moves
  • Simple control systems like traffic lights reacting to cars

However, if the task requires learning, planning, or remembering past events, reactive agents are not suitable.

Key Points

  • Reactive agents act only on current input without memory.
  • They are fast and simple but cannot learn or plan.
  • Ideal for tasks needing immediate response.
  • Not suitable for complex decision-making requiring history.

Key Takeaways

Reactive agents respond only to current environment inputs without memory.
They are simple and fast but cannot learn or plan ahead.
Use reactive agents for tasks needing quick, reflex-like responses.
They are not suitable for problems requiring past experience or complex reasoning.