How an agent decides what to do next (Planning vs Reactive)

It is not given an instruction. It is not told the action order.
On this page
  1. Planning: when the agent thinks ahead
  2. Reactive: when the agent acts by situation
  3. How they differ in practice
  4. In code this looks like
  5. 1) Planning: plan first, then execute
  6. 2) Reactive: step by step by situation
  7. Analogy from everyday life
  8. What this means in practice
  9. In short
  10. FAQ
  11. What’s next

When an agent gets a task, it does not know in advance which steps will lead to a result.

It is not given an instruction. It is not told the action order.

It has to decide on its own what to do next.


At this point, there are two possible approaches.

The agent can build a plan in advance with several steps and follow it.
Or it can act based on the situation, choosing the next step while working.

Both options can lead to a result.

But they work differently.

And this is exactly what determines how the agent behaves when something goes off plan.

Diagram

Planning: when the agent thinks ahead

In this approach, the agent first tries to understand which steps can lead to a result.

It gets a task and creates an approximate action plan.

For example:

  1. Find required data
  2. Process it
  3. Build a report
  4. Send the result

Only after that it starts executing steps one by one.


This approach works well when:

  • The task is clear
  • The data is available
  • And there is low chance something will go wrong

The agent does not make decisions at every step.
It moves according to what it decided in advance.

Reactive: when the agent acts by situation

In this approach, the agent does not build a plan upfront.

It looks at the current situation and chooses the next step right now.

For example:

  • First it tries to fetch data
  • If that fails, it looks for another source
  • If data is sufficient, it moves to processing

So it does not choose the full path at once.

It moves step by step, constantly checking:

"What changed after the previous action?"

And based on that, it chooses the next one.


This approach is more flexible.

If something fails, the agent does not break.
It simply changes the action.

How they differ in practice

AI Agent: Planning vs Reactive

The Planning approach tries to find the path in advance.
The Reactive approach finds it during execution.


In the first case, the agent says:

"Here is what I will do to reach the result."

In the second:

"I will do this and see what changes."


Planning can be faster if everything follows the plan.

But if something goes wrong, the plan can break.
Then the agent has to rebuild it again.


Reactive works more slowly.

But it adapts better to change.

It does not expect everything to work on the first try.

And that is exactly why it often keeps moving where a plan stops.

PlanningReactive
ApproachFinds the path in advanceFinds the path in process
How it acts"Here is what I will do""I will try and see"
SpeedFaster if everything worksSlower
On errorThe plan breaksTries another option
AdaptationNeeds to rebuild the planAdapts during execution

In code this looks like

Below is the same principle in a simple format:
Planning builds a plan first, while Reactive chooses the next step after each result.

First, we have actions (tools) the agent can run:

PYTHON
def search_docs(state: dict):
    return {"notes": "docs-found"}


def call_api(state: dict):
    return {"api_data": "fresh-data"}


def write_report(state: dict):
    return {"report": "ready"}


TOOLS = {
    "search_docs": search_docs,
    "call_api": call_api,
    "write_report": write_report,
}


def run_action(action: str, state: dict):
    return TOOLS[action](state)

1) Planning: plan first, then execute

Here the agent decides the whole route in advance:

PYTHON
state = {}
plan = ["search_docs", "call_api", "write_report"]

for action in plan:
    result = run_action(action, state)
    state.update(result)

# state -> {"notes": "...", "api_data": "...", "report": "ready"}

2) Reactive: step by step by situation

Here the agent looks at the state after each step and decides what to do next:

PYTHON
def choose_next_action(state: dict):
    if "notes" not in state:
        return "search_docs"
    if "api_data" not in state:
        return "call_api"
    if "report" not in state:
        return "write_report"
    return None


state = {}

while True:
    action = choose_next_action(state)
    if action is None:
        break

    result = run_action(action, state)
    state.update(result)

# state -> {"notes": "...", "api_data": "...", "report": "ready"}

In this example, both approaches produce one result.
The difference is when the decision about the next step is made.

Full implementation example with connected LLM

PYPython
TSTypeScript Β· soon

Analogy from everyday life

Imagine you are driving to a new city.

You can:

  • Build a route in advance
  • Or navigate by situation

Planning is when you open a map and build the full route to the end.

You know:

  • Where to turn
  • Where to stop
  • How to bypass a bridge

And you just follow the plan.

But if the road is blocked, you will need to stop and rebuild the route.


Reactive is when you drive without a complete plan.

You see a traffic jam and turn away.
You cannot find a street and choose another one.

You do not know the full path in advance.

But you can change direction quickly when something goes wrong.


It is the same with an agent.

It can:

  • Either build a plan
  • Or react to the situation

And it chooses the approach based on the task.

What this means in practice

Planning works well when:

  • The task is clear
  • The environment is stable
  • And there is low chance something changes

Reactive is better when:

  • Data may be incomplete
  • Tools sometimes fail
  • Or the situation changes during execution

In real systems, an agent often combines both approaches.

It can build a high-level plan, but react when something goes off track.

And this is what determines whether it stops after the first error or finds another path to the result.


In short

Quick take

An agent can:

  • Plan several steps ahead (Planning)
  • Or choose the next action by situation (Reactive)

Planning is faster if everything goes to plan.
Reactive is more flexible when things change.

In real tasks, an agent usually combines both approaches.

FAQ

Q: Does an AI agent plan all steps in advance?
A: Not always. It can build a plan or choose the next action directly during execution.

Q: Which is better: Planning or Reactive?
A: Planning is faster in a stable environment, Reactive works better when the situation changes.

Q: Does an agent use only one approach?
A: In real tasks, an agent often combines Planning and Reactive depending on the situation.

What’s next

Now you know how an agent chooses actions.

But even the best approach does not guarantee it will always make the right choice.

Why?

Because an agent runs on a model, and a model has its limits.

And because of those limits, an agent can:

  • Make mistakes
  • Miss important details
  • Or choose the wrong tool
⏱️ 7 min read β€’ Updated Mar, 2026Difficulty: β˜…β˜…β˜†
Practical continuation

Pattern implementation examples

Continue with implementation using example projects.

Integrated: production controlOnceOnly
Add guardrails to tool-calling agents
Ship this pattern with governance:
  • Budgets (steps / spend caps)
  • Tool permissions (allowlist / blocklist)
  • Kill switch & incident stop
  • Idempotency & dedupe
  • Audit logs & traceability
Integrated mention: OnceOnly is a control layer for production agent systems.
Author

This documentation is curated and maintained by engineers who ship AI agents in production.

The content is AI-assisted, with human editorial responsibility for accuracy, clarity, and production relevance.

Patterns and recommendations are grounded in post-mortems, failure modes, and operational incidents in deployed systems, including during the development and operation of governance infrastructure for agents at OnceOnly.