What Is Agentic AI?
Generative & Agentic AI · Agentic AI · Intermediate · 18 min
Tell an LLM call, a chatbot, a workflow and an agent apart, know the five common workflow patterns, and decide when an agent is worth its cost and when a simple workflow is better.
A ladder with four rungs. On the bottom rung the model answers once. On the top rung the model holds a to-do list, a toolbox and a notebook, and keeps working in a loop until the job is done. Every rung up adds power, cost and risk.
The idea in everyday words
A recipe card is a workflow: the steps are fixed and anyone can follow them. A chef is an agent: given "make dinner for six, one is vegan", the chef decides what to cook, checks the fridge, changes plans when the shop is out of tofu, and stops when dinner is served. You don't hire a chef to make toast.
The ladder: LLM, chatbot, workflow, agent
The key question is who decides the next step: your code or the model?
| Level | What it is | Who decides the next step | Example |
|---|---|---|---|
| LLM call | one prompt in, one answer out | nobody, it is one step | "Summarise this email" |
| Chatbot | an LLM plus conversation history | the user, turn by turn | a help-desk chat |
| Workflow | several LLM calls and tools in a path your code defines | your code | classify the ticket, then draft a reply, then check it |
| Agent | an LLM that chooses its own actions in a loop until a goal is met | the model | "Book me a trip to Lisbon under 800 euros" |
An agent usually has five parts:
- a goal (the task),
- tools it can call (search, APIs, code),
- memory (what happened so far, and maybe long-term facts),
- planning (breaking the goal into steps),
- a loop with stop conditions: think, act, observe, repeat, until done or out of budget.
The key idea: "agentic" is a spectrum of autonomy, not a yes/no label. The more the model decides, the more flexible the system, and the harder it is to predict and test.
Five workflow patterns you should know
Most production "agents" are really one of these workflows: the path is designed by you, the LLM fills in the steps.
- Prompt chaining. Fixed steps, each output feeds the next. Example: outline → draft → translate. Add a check (a "gate") between steps to stop early on bad output.
- Routing. Classify the input, then send it to a specialised prompt, tool or model. Example: billing questions to one prompt, technical ones to another; easy questions to a small cheap model.
- Parallelization. Run several LLM calls at once. Sectioning: split a job into independent parts (check grammar, check facts, check tone). Voting: ask the same question several times and take the majority for higher confidence.
- Orchestrator-workers. A lead LLM breaks the task into subtasks at run time and hands them to workers, then combines the results. Example: a research question split into "find sources", "summarise each", "write the report".
- Evaluator-optimizer. One LLM drafts, another critiques against clear criteria, the first revises. Loop until it passes or you hit a round limit. Example: writing code until the tests pass.
Then the autonomous agent: the model picks any tool, any order, any number of steps, in a loop.
The key idea: start with the simplest pattern that solves the task, and move up only when you can show it helps.
When NOT to use an agent
Agents cost more, are slower and fail in more ways. A small calculation shows why.
If each step succeeds 95% of the time and the steps are independent, the chance that all steps succeed is 0.95 to the power of the number of steps:
| Steps | Chance everything works |
|---|---|
| 1 | 95% |
| 5 | 77% |
| 10 | 60% |
| 20 | 36% |
Every step is also another model call (more latency = waiting time, and more cost in tokens).
Use a workflow (or plain code) when:
- the steps are known in advance (always classify, then reply),
- you need predictable cost and latency,
- mistakes are expensive and must be auditable (payments, medical, legal).
Use an agent when:
- the number and order of steps truly depends on what it finds (open-ended research, debugging, multi-system support cases),
- the task is valuable enough to pay for several calls,
- you can give it good tools, clear stop conditions and a way to check its own work.
The key idea: autonomy is a cost you pay for flexibility. Only pay it where the flexibility is needed. Even then, keep guardrails: limit tools, cap steps and spend, and ask a human before risky actions.
Step by step
- The request:
A support message arrives: "Login error after upgrade".
- Tokenise:
Lowercase and split into words: {login, error, after, upgrade}.
- Score each route:
billing keywords {invoice, refund, charge, payment} match 0. tech {error, crash, login, bug} match 2 (login, error). sales {price, plan, upgrade, demo} match 1 (upgrade).
- Pick the winner:
tech has the highest score, 2, so the message goes to the tech-support prompt. No model call was needed to route it.
- Tie or no match:
"refund error" scores 1 for billing and 1 for tech: the first route in the list (billing) wins. "Hello there" matches nothing, so it goes to the fallback (for example a general LLM prompt or a human).
- Why this matters:
This is the routing pattern. A cheap deterministic router in front of the LLM keeps cost low and makes behaviour testable. Use an LLM classifier only when keywords are not enough.
Code example
# A fake "LLM" so this runs anywhere. We count calls to show cost.
calls = []
def llm(task, text):
calls.append(task)
if task == "classify":
return "billing" if "money back" in text or "refund" in text else "tech"
if task == "summarise":
return text.split(".")[0] + "."
if task == "translate":
return "[FR] " + text
if task == "draft":
return "Sorry about that! We will refund you."
if task == "critique":
return "OK" if "order number" in text else "Ask for the order number."
if task == "revise":
return text + " Please reply with your order number."
# 1) Prompt chaining: fixed steps, each output feeds the next
summary = llm("summarise", "The blender arrived broken. The customer wants money back.")
print("Chain :", llm("translate", summary))
# 2) Routing: classify, then hand off to a specialist prompt
for msg in ["I want my money back", "App crashes on login"]:
print("Route :", msg, "->", llm("classify", msg))
# 3) Parallelization (voting): 3 independent checks, majority wins
votes = ["safe", "unsafe", "safe"]
print("Vote :", max(set(votes), key=votes.count))
# 4) Orchestrator-workers: a planner splits the job at run time
plan = ["find flights", "find hotels", "check visa rules"]
print("Workers :", {task: "done" for task in plan})
# 5) Evaluator-optimizer: draft, critique, revise (max 3 rounds)
draft = llm("draft", "refund request")
for rnd in range(1, 4):
verdict = llm("critique", draft)
print(f" round {rnd}: {verdict}")
if verdict == "OK":
break
draft = llm("revise", draft)
print("Final :", draft)
print("LLM calls used:", len(calls))
# Why long autonomous chains are risky
for steps in (1, 5, 10, 20):
print(f" {steps:2d} steps at 95% each -> {0.95 ** steps:.0%} chance all succeed")Complexity
- Time: Router: O(w + K) for w words in the message and K keywords in total, thanks to the word set. Patterns: cost is roughly the number of LLM calls, so chaining is n calls, voting is n parallel calls, and an agent is unbounded unless you cap steps.
- Space: O(w) for the set of words.
Interview tips
Define an agent precisely: an LLM that chooses its own next action (usually a tool call) in a loop, with memory and stop conditions, versus a workflow where your code fixes the path.
Name the five workflow patterns with a one-line example each.
Argue for the simplest solution: show the compound-reliability maths and the cost of extra calls, then say when an agent is still worth it.
Mention guardrails: tool allow-lists, max steps and budget, human approval for irreversible actions, logging and tracing.
Map it to AWS: Step Functions or Bedrock Flows for workflows, Bedrock Agents for managed agents, AgentCore to host your own agents.
Challenge: Keyword Intent Router
Write route_intent(message, routes) for the routing pattern.
routesis an ordered list of[name, keywords].- Turn the message into a set of whole words: lowercase, split on anything that is not a letter or digit.
- A route's score = how many of its distinct keywords appear in that set.
- Return the name with the highest score. On a tie, the earlier route wins. If every score is 0, return
"fallback".
Example:
routes = [["billing", ["invoice", "refund", "charge", "payment"]],
["tech", ["error", "crash", "login", "bug"]],
["sales", ["price", "plan", "upgrade", "demo"]]]
route_intent("Login error after upgrade", routes) → "tech"
Solve it in the browser with tests, hints and an AI coach.
Practice problems
- Anthropic: Building effective agents
- Amazon Bedrock Agents (user guide)
- Strands Agents SDK
- Most Common Word (Easy)
More in Agentic AI
- AI Agents & Tool Calling
- Build a ReAct Agent from Scratch
- Agent Memory, Planning & Reflection
- Model Context Protocol (MCP)
- Amazon Bedrock Agents
- Amazon Bedrock AgentCore: Running Agents in Production
- Multi-Agent Systems
Previous: GraphRAG: Knowledge Graphs for Retrieval · Next: AI Agents & Tool Calling