Skip to content
AgenticAIWiki
  1. Learn
  2. Part 8
  3. 40. Workflows vs agents
  4. 40.1

Lesson 40.1 · 1 of 3 · 5 min read · Reviewed 24 Nov 2026

What makes a system agentic

By the end, you can

  • Tell an agent from a workflow by who decides the next step.
  • Name the three things every agent has: a model, tools and a loop.

People use “agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done.” for almost anything with a model in it. A useful definition is narrower, and it decides how you build, test and pay for the system.

The line that matters

  • WorkflowWorkflow: A system where LLM calls and tools follow a path defined in code, rather than chosen by the model.: your code fixes the steps. The model fills in each step, but the order and the number of calls are set in advance. Prompt chainingPrompt chaining: Splitting a task into steps where each model call handles one step and passes its output to the next., routingRouting: A workflow pattern that classifies an input and sends it to a specialised prompt, model or handler. and parallel sections are workflows.
  • Agent: the model decides the next step at run time. It picks a tool, reads the result, and decides whether to call another tool or stop.

Every agent has three parts: a model, tools it can call, and a loop that sends tool results back until a stop condition is met. You built exactly this in chapter 0.

A spectrum, not a switch

Real systems mix the two. A support system might route each ticket with a fixed classifier (workflow), then let an agent investigate inside the billing route. Ask of each step: does the model choose what happens next, or does my code?

Why it matters

Workflows are predictable: same input, same steps, easy to test. Agents handle open-ended tasks where you cannot list the steps ahead of time, but you pay for that in cost, latencyLatency: The time from sending a request until you get the response, or until the first token arrives when streaming. and new ways to fail. The next two lessons are about choosing.

Key points

  • In a workflow, your code decides the steps. In an agent, the model decides the next step at run time.
  • Every agent has a model, tools it can call, and a loop that feeds results back until a stop condition.
  • Agentic is a spectrum: most useful systems mix fixed steps with a few model-made choices.
Hands-on labRuns in the Playground

Build the same task as workflow and agent

See the line between a workflow and an agent by running one task both ways and comparing who chose each step.

You will have: Two implementations of a ticket handler and a printed trace showing the steps each took on two different tickets.

Steps

  1. Read the three tools: lookup_order, check_refund_policy and lookup_account.
  2. Write workflow(ticket): your code always calls lookup_order then check_refund_policy.
  3. Write agent(ticket): a loop where a scripted policy, standing in for the model, picks the next tool from what it has seen so far, or stops.
  4. Run both on a refund ticket and on a login ticket.
  5. Print each path and say who decided each step.

Done when

  • The workflow takes the same two steps for both tickets.
  • The agent takes a different path for the login ticket.
  • The agent loop has a step cap even though the policy always stops.

Open in the Playground No API key needed.

Starter code (Python)
def lookup_order(t):   return {"order": "A-1042", "paid": True}
def check_refund_policy(t): return {"refundable": True}
def lookup_account(t): return {"locked": True}
TOOLS = {"lookup_order": lookup_order, "check_refund_policy": check_refund_policy, "lookup_account": lookup_account}

def workflow(ticket):
    path = []
    # TODO: your code fixes the steps: lookup_order, then check_refund_policy
    return path

def policy(ticket, seen):
    """Stands in for the model: choose the next tool from what has been seen, or None to stop."""
    # TODO: refunds need the order, then the policy; login problems need the account
    return None

def agent(ticket, max_steps=5):
    seen, path = {}, []
    # TODO: loop: ask policy for the next tool, run it, record it; stop on None or at max_steps
    return path

for ticket in ["I want a refund for my order", "I cannot log in to my account"]:
    print(ticket)
    print("  workflow:", workflow(ticket))
    print("  agent:   ", agent(ticket))
Show a solution
def lookup_order(t):   return {"order": "A-1042", "paid": True}
def check_refund_policy(t): return {"refundable": True}
def lookup_account(t): return {"locked": True}
TOOLS = {"lookup_order": lookup_order, "check_refund_policy": check_refund_policy, "lookup_account": lookup_account}

def workflow(ticket):
    path = []
    for name in ["lookup_order", "check_refund_policy"]:   # code decides
        TOOLS[name](ticket)
        path.append(name)
    return path

def policy(ticket, seen):
    """Stands in for the model: choose the next tool from what has been seen, or None to stop."""
    if "refund" in ticket:
        if "lookup_order" not in seen: return "lookup_order"
        if "check_refund_policy" not in seen: return "check_refund_policy"
        return None
    if "log in" in ticket and "lookup_account" not in seen:
        return "lookup_account"
    return None

def agent(ticket, max_steps=5):
    seen, path = {}, []
    for _ in range(max_steps):
        name = policy(ticket, seen)                         # "model" decides
        if name is None:
            break
        seen[name] = TOOLS[name](ticket)
        path.append(name)
    return path

for ticket in ["I want a refund for my order", "I cannot log in to my account"]:
    print(ticket)
    print("  workflow (code chose):", workflow(ticket))
    print("  agent (model chose):  ", agent(ticket))
Quick checkWhich system is an agent rather than a workflow?
How sure are you?
Pick an answer and how sure you are