Lesson 7 of 7 · A First Agent
When Not to Use an Agent
Agents are slow, costly and less predictable. Learn when a single LLM call or a fixed workflow is better, compare token costs and use a checklist to decide.
- 6 min read
- Beginner
- Reviewed
- Explain the difference between a workflow and an agent
- Compare the cost and speed of each
- Use a checklist to decide whether a task needs an agent
- Combine workflows and agents sensibly
Not everything needs an agent
Agents are exciting, so it's tempting to use them everywhere. But many tasks that sound complex are really a fixed sequence of steps, and those are better built as a workflow.
| Workflow | Agent | |
|---|---|---|
| Who decides the steps | Your code | The model |
| Predictability | High: same steps every time | Lower: paths vary |
| Cost and speed | Low: a few calls | Higher: many calls, growing history |
| Testing | Test each step | Test many full runs |
| Best for | Known, repeatable processes | Open-ended tasks where steps depend on findings |
The cost of flexibility
Each agent step sends the whole conversation again, so input tokens grow with every step:
# Why agents cost more: every step re-sends the whole conversation so far.
system_and_task = 1_500 # tokens: instructions, tool definitions and the task
added_per_step = 600 # tokens: each tool call plus its result
def input_tokens(llm_calls):
total = 0
for step in range(llm_calls):
total += system_and_task + added_per_step * step # the history grows each step
return total
workflow = input_tokens(2) # a fixed pipeline: e.g. classify, then draft a reply
agent = input_tokens(10) # an agent that takes 10 steps on the same task
print(f"Workflow (2 calls): {workflow:,} input tokens")
print(f"Agent (10 calls): {agent:,} input tokens ({agent / workflow:.0f}x more)")Twelve times the input tokens for the same task, plus the extra waiting time of eight more model calls. If a fixed sequence does the job, that's money and time saved on every single run.
A quick checklist
Use an agent only if most of these are true:
- You can't list the steps in advance: they depend on what is discovered.
- The task benefits from trying, checking and retrying.
- Waiting seconds or minutes is acceptable.
- Mistakes can be caught or undone, or a person approves important actions.
- The value of the task is worth several model calls.
Otherwise, start with the simplest option that works: a single LLM call, then a workflow, and only then an agent.
Common mistakes
Decide whether each task needs an agent or a simpler fixed workflow.
tasks = {
"translate every new product description into French": "?",
"investigate why a customer's three orders failed, using logs and the order system": "?",
"extract the invoice number and total from each uploaded invoice": "?",
"research a topic across many websites and write a report": "?",
}
# Replace each "?" with "workflow" (the steps are known in advance)
# or "agent" (the steps depend on what is discovered along the way).
for task, choice in tasks.items():
print(f"{choice}: {task}")
You need to extract the date, total and supplier from thousands of invoices in the same format. What should you build?
Summary
- A workflow fixes the steps in code; an agent lets the model choose them.
- Agents cost more and are less predictable, because each step re-sends a growing history.
- Use an agent when steps can't be known in advance and the task justifies the cost and wait.
- Start simple (one call, then a workflow) and mix workflows and agents where it helps.
Course complete
You now know what an AI agent is, how it differs from a plain LLM, how the agent loop works, what agents can and can't do, how to give a model tools, how to build a minimal agent in Python, and when to choose a simpler workflow instead. Next, the Tool and Function Calling course goes deeper into designing tools that models use correctly.
Finished reading? Tick it off to track your progress.