Agent autonomy spectrum

RoadmapsAI Engineering

Scenario

A developer writes a script that strictly calls a web-search tool, then passes the raw result to an AI for a summary.

Is this an autonomous AI agent or just a basic workflow?

Mental model

A workflow is a train on a track. An agent is a self-driving car.

If you know exactly what steps need to happen, you write a workflow (the track). The AI just processes data at stops along the way. If the steps are unknown and depend on what happens next, you build an agent (the car). The agent looks around, picks its own tools, and drives itself until the goal is met.

Deep dive

Not every app using an AI tool is an agent. A **workflow** (or chain) is a fixed path: Input → Tool → AI → Output. The code controls the order. You use this when the steps never change. **Determinism always beats AI guessing.** Use normal code if you know the exact path.

Workflows are strict, predictable, and run on rails.

A step up is a **router**. Here, you ask the AI to pick a track: 'Is this a billing question or a tech support question?' Based on the answer, your code triggers the strict billing workflow or the strict support workflow. The AI decides *which* track, but the code still drives.

Routers use the AI only for decision branching, not execution.

A true **agent** has operational autonomy. It uses the ReAct (Reason + Act) loop. The agent decides *which* tool to use, sees the result, and loops back to decide its *next* tool. It stops only when it believes the task is done. The path is highly unpredictable.

Agents decide their own sequence of tools in a recursive loop.

Prediction: A developer uses an AI to check if a number is greater than 10. Is this a good use of an agent? No. A simple Python `if number > 10:` is instant and perfect. Using an AI adds latency and a chance of failure to basic logic.

Never use an AI agent to replace a standard code statement; next you'll see how a state machine makes an agent's loop controllable.

Code examples

A strict workflow (Not an agent)

def process_ticket(user_query):
    # 1. Strict tool call
    user_data = fetch_db_record(user_query)
    
    # 2. Strict AI call
    summary = call_llm(prompt=f"Summarize {user_data}")
    
    return summary

This is a basic chain. The AI has zero control over what happens or what order things happen in. It just summarizes the data handed to it. Helper names are placeholders — the control flow is the point.

A router (Branching workflow)

def route_ticket(user_query):
    # AI decides the category
    category = call_llm(prompt="Is this billing or support?")
    
    if category == "billing":
        return run_billing_workflow() # Strict path
    else:
        return run_support_workflow() # Strict path

The AI acts as a smart traffic cop. It makes one decision, and then hands control back to standard, predictable code logic. Helper names are placeholders — the control flow is the point.

A true Agent loop (ReAct)

def run_agent(goal):
    while True:
        # AI decides the next step based on all history
        action = call_llm_for_next_step(goal)
        
        if action == "done":
            break
            
        # Code executes the AI's choice
        execute_tool(action)

This is a true agent. The AI completely controls the loop. It decides what tool to run, inspects the result, and loops again until it chooses to stop. Helper names are placeholders — the control flow is the point.

Key points

Common mistakes

Glossary

workflow
A strict, step-by-step path written in normal code. The AI does exactly what you tell it, in order.
router
A script that uses an AI only to pick which strict path to take next.
agent
An AI that operates in a loop, deciding for itself which tools to use and when to stop.

Recall questions

Questions & answers

A team builds an agent to determine if an integer is greater than 10. What architectural mistake have they made?

They have used a slow, probabilistic AI model for a task that requires basic, deterministic code. Normal code should always be used for known logic; agents should be reserved for ambiguous tasks.

Approach: Identify the performance and reliability cost of using an LLM where an 'if' statement suffices.

How does the ReAct pattern fit into the autonomy spectrum?

ReAct represents true autonomy. Unlike a chain or router, ReAct places the AI in a continuous reason-and-act loop where it controls the sequence of tools and the termination condition.

Approach: Define ReAct as the mechanism that elevates a system from a router to a fully autonomous agent.

Continue learning

Previous: ReAct (Reason + Act)

Next: State machines for agents

Return to AI Engineering Roadmap