AI Hints
Home›Agentic AI Tutorial›Agents and Models
Agentic AI · Lesson 4 of 100

When Not to Use an Agent

The most useful lesson here.

⏱ 2 min read▶ Video at 7:22🎓 Free
Watch this lesson in the Agentic AI courseWatch on YouTube ↗Full Agentic AI course

Agents are exciting, so people use them for everything. And that's a mistake. A team once spent months on an agent to sort emails, when a three line rule would've handled ninety percent of them. The best engineers reach for the simplest thing that works.

When Not to Use an Agent
From the video: When Not to Use an Agent
  • Agents are exciting
  • Months spent on a three-line job
  • Use the simplest thing that works

Try plain code first

Many support messages don't need AI at all. A regular expression finds an order number. A keyword spots a question about hours. And anything else goes to a person. Run it. Instant, free, and it's never wrong in a surprising way. Always handle the easy cases with plain code first, then let an agent handle what's left.

rules.pypython
import re

def route(message):
    match = re.search(r"\b[A-Z]\d{2}\b", message)
    if "where" in message.lower() and match:
        return f"Track order {match.group()}"
    if "hours" in message.lower():
        return "Open nine to five"
    return "Send to a person"

for m in ["Where is B42?", "What are your hours?", "My wheel wobbles at speed"]:
    print(f"{m:<28} -> {route(m)}")
Output
Where is B42?                -> Track order B42
What are your hours?         -> Open nine to five
My wheel wobbles at speed    -> Send to a person

The maths of many steps

Agents have two hidden costs. Every step costs money and time. And every step can fail. Let's say each step works ninety seven percent of the time. That sounds great. Run it. Six steps, and we're down to about eighty three percent. Twenty steps, and it's barely more than half. That's why short agents beat long ones, and why tasks should be as small as possible.

steps.pypython
steps = 6
model_call = 0.002
success_per_step = 0.97

cost = steps * model_call
success = success_per_step ** steps

print(f"Cost per task: ${cost:.3f}")
print(f"Cost for 300 tickets a day: ${cost * 300:.2f}")
print(f"Chance all six steps work: {success:.0%}")
print(f"With twenty steps: {success_per_step ** 20:.0%}")
Output
Cost per task: $0.012
Cost for 300 tickets a day: $3.60
Chance all six steps work: 83%
With twenty steps: 54%

Which should you use?

Here's the decision. If the steps are always the same, write normal code. If they're the same, but one step needs judgment, use a workflow with a model in it. Use a real agent only when the steps can't be known in advance, when mistakes are recoverable, and when a person's time is worth more than the risk.

SituationUse
Same steps, no judgmentPlain code
Same steps, some judgmentWorkflow
Steps not known in advanceAgent
Mistakes are expensiveKeep a human in the loop

Summary

If the task is predictable, don't use an agent. If you do need one, keep it short. Now we'll get our hands dirty. Next, we'll talk to a real model.

Key takeaways
  • Handle easy cases with code
  • Reliability falls with each step
  • Use agents only when needed
Next up: Your First Model Call — the brain of the agent