LLM vs AI agent vs agentic system
Tuesday, 10:00: a guest types "find and book me a quiet hotel in Lisbon next weekend under €200". The concierge describes "Casa Silêncio, €165 a night", a hotel that isn't on StayHub, and can't book anything.
People use these three words as if they meant the same thing. They don't, and picking the wrong one can be very expensive.
- Problem
A guest types: “Find and book me a quiet hotel in Lisbon for next weekend under 200 EUR.”
- Why the simple system fails
A single LLM call can only write text. It can't search live availability, can't book, and will happily invent a hotel that sounds right.
- Engineering concept
Put the model in a loop with tools, memory and a goal: observe → think → act, until done. Wrap risky actions in human approval.
- Technology
Agent runtime, tool calling, state store, orchestration, approval steps.
- Trade-offs
Each step adds cost, latency and a chance to go wrong. Use the least autonomy that solves the problem.
The problem
2 min- A guest · StayHub customerFind and book me a quiet hotel in Lisbon next weekend, under €200 a night.
- Maya · Product managerIt replied "Casa Silêncio in Alfama, €165". Not on StayHub. And it can't book. 18% of conversations ask it to do something.
- You · Engineer at StayHubBetter retrieval over hotel descriptions?
- Lina · Senior engineer, your mentorGuess first. Then we'll see what's missing.
The big idea
4 minEach level of autonomy adds cost, latency and ways to fail: use the least autonomy that solves the problem.
"Find and book" needs an agent: the path depends on what search returns. But "change my booking to Saturday" always takes the same steps, and 70% of action requests look like that.
How it works
5 minIt starts with : the model asks our code to run a named function with arguments (like search_hotels); our code decides whether to run it and returns the result. From there, four levels:
- 1LLM call
Text in, text out, one step. "What time is breakfast?" with grounded facts: ≈ €0.026, ~2 s.
- 2Workflow
A workflow () is a fixed path decided by our code: find booking → quote change → confirm → apply. The model fills in steps. ≈ €0.03, ~3 s.
- 3Agent
An is an LLM in a loop with a goal, tools and state, choosing the next step from what it observes: search, no luck, try nearby neighbourhoods. About 6 calls: ≈ €0.12, ~14 s.
- 4Agentic system
An agentic system () is several agents and tools, orchestrated, with people approving the risky steps.
- 5The loop is our code
The model proposes; the runtime decides what runs. Step budget, permissions and confirmation live in code, never only in the prompt.
Watch a decision being made
4 minLina designs the first booking agent
Handle ≈3,200 "find and book" requests a day without inventing hotels, booking anything unapproved, or running forever.
- 1Route before you loop
"A small classifier: questions to grounded answers, changes and cancellations to workflows, only open-ended find-and-book to the agent."
Why: The agent is the most expensive, least predictable option; it should only see requests that need it.
- 2Give it narrow tools
"
search_hotels,get_availability,get_quoteare read-only.create_booking(quote_id)is the only side effect."Why: Results come from live systems, so no Casa Silêncio. Booking from a quote id means it can't invent a price either.
- 3Run the loop in our code, gate the side effect
"Up to 10 steps. When it asks for
create_booking, pause and show the guest the exact hotel, dates and total. Only a tap runs it."tsfor (let step = 0; step < 10; step++) { const r = await llm.call({ tools: TOOLS, messages: state.messages }); if (r.type === "final_answer") return r.text; if (r.toolCall.name === "create_booking") return askGuestToConfirm(r.toolCall); state.messages.push(await runTool(r.toolCall, ctx)); } return handOffToHuman(state);Why: A loop we control can be budgeted, logged and stopped; the one money-spending step gets explicit approval.
- 4Plan the way out
"After 10 steps with no result, hand over to a human agent with the trace."
Why: Agents sometimes fail. A clean escalation turns a failure into a slower success.
In real life
3 minDevin (Cognition): an autonomous agent
- Presented in 2024 as an AI software engineer that plans and carries out whole tasks
- Uses an editor, terminal and browser in a long loop
- Powerful on open-ended work, harder to predict
Fits open-ended tasks a person reviews before they matter.
GitHub Copilot: suggest, the developer accepts
- Suggests code as you type; nothing changes until accepted
- Fast, cheap, predictable
- The person controls every change
Fits frequent small steps a person approves.
What goes wrong
3 minKnown paths become slower, costlier, less predictable.
Workflows for fixed paths; agents only where the next step depends on results.
One wrong step or blind retry books or charges twice.
Confirmation bound to the exact action, an per booking, a status check before retrying.
A confused agent loops and never answers.
A hard step and cost budget in code, then escalation to a person.
Trade-offs
3 min| Design | Choose when | Cost / wait | Main risk |
|---|---|---|---|
| Single LLM call | Questions answerable from provided facts | €0.026, ~2 s | Can't act |
| Workflow | Known paths: change, cancel, invoice | €0.03, ~3 s | Rigid when reality differs |
| Agent | The next step depends on results | €0.12, ~14 s | Wanders; needs budgets and gates |
- Maya · Product managerOne agent for everything: questions, changes, cancellations, bookings. One system.
- Karim · CTOChanges and cancellations are 70% of actions, always the same steps. As agent runs: €0.12 and 14 s instead of €0.03 and 3 s.
- Maya · Product managerTwo systems means two things to build and test.
Your job as tech lead
4 minClaude Code can write the code for this. You still own the decisions, and you have to know what good looks like to accept or reject its work.
- Which requests get which design: a grounded answer, a workflow for change or cancel, or an agent only for open-ended "find and book".
- Which tools have side effects (
create_bookingspends money) and need the guest's confirmation, enforced in code. - The limits on every agent run (steps, time, cost) and an idempotency key per confirmed booking.
Concierge action requests: 70% are changes or cancellations. Build those as a fixed workflow (extract booking ref with structured output, validate in code, call the booking API). Only open-ended "find and book" goes to an agent with `search_hotels`, `get_availability`, `get_quote`, `create_booking`. In the runtime, not the prompt: `create_booking` runs only after the guest confirms hotel, dates and total, with an idempotency key; cap runs at 10 steps and €0.30. Plan first, then report cost, latency and success per path on 50 recorded conversations.
- Change and cancel requests take the workflow; only open-ended ones reach the agent.
- The confirmation is a check in runtime code that blocks
create_booking, not a sentence in the prompt. - A simulated timeout and retry on
create_bookinggives exactly one booking and one charge.
- Every request routed through the agent "for flexibility".
- "Always ask before booking" in the system prompt as the only safeguard.
- An agent loop with no step, time or cost limit.
Check yourself
2 minNext episode: a guest wants a quiet hotel in Lisbon under €150. Twenty minutes and 41 tool calls later, the agent is comparing hotels in Porto.
Mark it complete to update your skill map.
Go deeper (optional)You don't need this to understand the lesson. Open it when a project needs the details: Technical deep dive, Interactive simulation, Visual diagram, Analogy, Why it matters, Check your understanding, Practice ladder, Explain it yourself.
Technical deep dive
| LLM call | Workflow | Agent | Agentic system | |
|---|---|---|---|---|
| Who decides the next step? | Nobody: one step | Our code | The model, each iteration | Models + orchestrator + people |
| Can act? | No | Yes, via fixed tool calls | Yes, chooses tools | Yes, many tools and agents |
| Model calls | 1 | Fixed, small | Variable (3 to 50+) | Many |
| StayHub cost / wait | €0.026, ~2 s | €0.03, ~3 s | €0.12, ~14 s | Higher |
Lina designs the first booking agent
Let the concierge handle "find and book" requests (≈3,200 a day) without inventing hotels, without booking anything the guest didn't approve, and without running forever.
- 1Route before you loop
A small classifier sends questions to grounded answers, changes and cancellations to workflows, and only open-ended find-and-book requests to the agent.
Why: The agent is the most expensive and least predictable option; it should only see requests that need it.
- 2Give it narrow tools
search_hotels(city, dates, max_price, tags),get_availability(hotel_id, dates),get_quote(...)are read-only.create_booking(quote_id)is the only side effect.tsconst TOOLS = [ { name: "search_hotels", readOnly: true, schema: SearchArgs }, { name: "get_availability", readOnly: true, schema: AvailArgs }, { name: "get_quote", readOnly: true, schema: QuoteArgs }, { name: "create_booking", readOnly: false, schema: { quote_id: "string" } }, ];Why: Results come from our live systems, so it can't invent Casa Silêncio. Booking from a quote id means it can't invent a price either.
- 3Run the loop in our code
Up to 10 steps. Each step: call the model with goal, tools and state; run the requested read-only tool; save state.
Why: A loop we control can be budgeted, logged and stopped. A loop inside a prompt can't.
- 4Gate the side effect
When the model asks for
create_booking, pause and show the guest: "Hotel Alfama 12, 14–16 Nov, €178/night, total €356. Book?" Only a tap runs it.Why: The one irreversible, money-spending step gets a person's explicit approval, bound to that exact quote.
- 5Plan the way out
If 10 steps pass without a result, hand over to a human agent with the trace, instead of a vague "sorry".
Why: Agents fail sometimes. A clean escalation turns a failure into a slower success.
Interactive simulation
Visual diagram
“Find and book a hotel for me”: an agent in a loop, with a human approval gate before the side effect.
Analogy
- Planning a tripA travel expert you phone onceAI systemsAn LLM
- Planning a tripA booking form with a fixed checklistAI systemsA workflow
- Planning a tripA personal assistant with a laptopAI systemsAn agent
- Planning a tripA whole travel agency with a supervisorAI systemsAn agentic system
- Planning a tripClient signs before anything is chargedAI systemsHuman approval for risky actions
Where the analogy breaks: a human assistant knows when they're out of their depth. An agent will happily keep looping, so you must set limits on steps, spending and actions.
Why it matters
"Let's add an agent" is one of the most expensive sentences in AI engineering, when it's the wrong tool.
An agent that loops 12 times makes 12 or more model calls, each resending a growing history. That's slower and pricier.
Errors also stack up. If each step works 95% of the time, a 10-step chain succeeds only about 60% of the time. More freedom means more ways to go wrong.
So the real question isn't "agent or not?". It's "which actions may the system take without asking a person?"
Workflow
- Path fixed by your code
- Predictable cost and speed
- Easy to test
Default for known tasks.
Agent
- Picks its own steps
- Handles surprises
- More calls, more risk
For open-ended goals.
Check your understanding
Practice ladder
Trace an agent run
Scenario Warm-upThe agent's goal: "Quiet hotel in Lisbon, 14–16 Nov, under €200/night, then book it." Its trace so far:
search_hotels(city: "Lisbon", dates: 14–16 Nov, max_price: 200, tags: ["quiet"])→ 0 results- Model: "No results with the quiet tag. I'll search without it and check reviews."
search_hotels(city: "Lisbon", dates: 14–16 Nov, max_price: 200)→ 7 hotelsget_availability(hotel_id: "alfama-12", dates: 14–16 Nov)→ 2 roomsget_quote(hotel_id: "alfama-12", room: "double", dates: 14–16 Nov)→ quote Q-88213, €178/night
Trace what should happen next, step by step, and say where the runtime (not the model) is in charge.
Add the missing guards
Code PracticeThis agent loop is missing three guards. Add them: a step budget, a gate on side effects, and an escalation when the budget runs out.
async function runAgent(goal: string, ctx: Ctx) {
const state = await loadState(ctx.taskId, goal);
while (true) { // (1) ???
const r = await llm.call({ tools: TOOLS, messages: state.messages });
if (r.type === "final_answer") return r.text;
const call = r.toolCall;
// (2) ???
state.messages.push(await runTool(call, ctx));
await state.save();
}
// (3) ???
}Route five requests
Design PracticeDecide for each request whether it should be handled by a single grounded LLM call, a workflow, or the agent, and say why in one line.
- "What time is breakfast at Hotel Ribeira?"
- "Please cancel booking LIS-2280."
- "Somewhere by the sea in Portugal for a long weekend in May, two kids, under €250, near a beach we can walk to."
- "Can I add an extra bed to my booking POR-3315?"
- "Send me my invoice for last month's stay."
Should the agent cancel without asking?
Decision StretchMaya: "Guests hate the extra tap. When someone clearly says 'cancel booking LIS-2280', let the cancellation workflow run without the confirmation step."
Facts: cancellations are about 4,000 a day. About 1 in 300 cancellation requests in the logs refers to the wrong booking (guests with two bookings, typos). Some cancellations lose a non-refundable payment. A cancelled room is often resold within hours.
Write a short decision: "We chose X over Y because…, accepting the risk of…".
Explain it yourself
A product manager asks: “Should our hotel booking feature be an agent?” Explain the difference between an LLM, an agent and an agentic system, and how you'd decide.