Learn
AI agents & tool use

What is an AI Agent vs. a Chatbot?

The short answer

A chatbot maps a message to a reply, usually in a single model call. An agent runs a loop: it receives a goal, chooses tools, observes the results and repeats until the goal is met or a stopping condition fires. The difference is control flow and side effects, not model size or intelligence.

On this page

The distinction in one sentence

A chatbot is a program that turns a conversation into the next message. An agent is a program that uses a model as one component inside a control loop, where the loop can call tools, read their results, change state in other systems and decide what to do next. The model may be identical in both cases. What changes is the surrounding software: whether the model's output is treated as the final product or as an instruction that the runtime executes. That is why "agent" is an architectural label, not a model capability. A 7B model behind a well-built loop can book a meeting; a frontier model in a chat box can only tell you how.

What a chatbot actually is

A chatbot receives messages, builds a prompt, performs one inference and returns text. Its contract is simple: language in, language out. It may stream tokens, query a retrieval index first or apply a safety filter, but the turn ends when the text is produced. It has no authority to change anything outside the conversation, and its memory is whatever the application chooses to resend on the next turn. Failures are cheap: a bad answer can be regenerated, edited or ignored. This is the right shape for questions whose answer already exists in provided context — explaining a policy, drafting an email, summarising a ticket, classifying intent. The product value is the quality of the text, and the engineering work is prompt design, retrieval and evaluation. A support chatbot that says "you can request a refund within 30 days" is useful even though it cannot process the refund.

What an agent actually is

An agent is given a goal rather than a question. "Refund order 4821 if it qualifies" cannot be answered from the prompt alone; the system must look up the order, read the refund policy, check eligibility against dates and status, call the payment provider, confirm the refund posted and report back. Each of those steps is a tool call with a real effect. The model decides the order and the arguments, but ordinary code performs the action and returns the result. The loop continues while the goal is unfinished and stops on success, failure, a step limit or a human interruption. The important consequence is that errors now have consequences: a wrong sentence is embarrassing, a wrong refund is money.

A side-by-side example

Put the same customer request in front of both systems: "My order arrived damaged, I want my money back." The chatbot classifies the complaint, retrieves the damaged-goods policy, explains the thirty-day window and asks for photos. It produces a helpful reply and stops; a human still has to open the order, verify the delivery date, approve the refund and send it. The agent receives the order number from the conversation, calls get_order, sees that delivery was nine days ago and the item is marked fragile, calls check_refund_eligibility with the reason "damaged on arrival", receives an approved decision with a partial-refund limit, calls issue_refund with an idempotency key tied to the ticket, waits for the payment provider's confirmation, then replies with the amount, timeline and reference number. Same model, same language quality. One system produces advice; the other completes work and leaves an audit trail.

The loop, in pseudocode

Every agent framework is a variation on a small loop. Build a message list containing the system prompt, the user goal and any prior turns. Send it to the model together with the JSON schemas of the available tools. If the model returns plain content, the loop ends and that content is the answer. If it returns tool calls, validate the arguments, execute each tool, append one result message per call and send the expanded transcript back. Repeat until the model stops calling tools or a budget expires. ReAct, plan-and-execute, reflection and tree search are refinements of this skeleton: they add a planning step, a critic or branching, but the model still proposes actions and the runtime still executes them. When people say an agent "decided" to do something, they mean the model emitted a tool call that the runtime accepted.

Anatomy of an agent

  • Policy model: the LLM that chooses the next action. Its job is judgement under uncertainty, not reliable arithmetic or API authentication.
  • Tool layer: typed functions with names, descriptions and JSON Schemas. The schema is the interface the model reasons about, so vague descriptions produce vague calls.
  • Executor: the code that validates arguments, injects credentials, applies rate limits and performs the side effect. Credentials belong here, never in the prompt.
  • State: the transcript, a scratchpad, a database row or an explicit run record. If state is not persisted, a crash loses the task.
  • Controller: the loop itself, including step budgets, timeouts, retries and stopping conditions. This is the part most demos omit and most incidents blame.
  • Guardrails: allowlists, confirmation prompts for writes, spend limits and output filters. They sit outside the model because a prompt is not an access control system.
  • Observability: a trace of every model call, tool call, argument, result, token count and latency. Without it, debugging an agent is guesswork.

The agency spectrum

Autonomy is a dial, not a binary. The engineering goal is to turn it up only as far as the task requires.

  • Single-turn chat: one inference, text out, no tools. Good for explanation and drafting.
  • Tool-augmented chat: the model may call a read-only tool such as search or a calculator, then answer. The loop is shallow and the blast radius is small.
  • Fixed workflow: code decides the sequence, and model calls fill specific steps. Most reliable AI features in production are this, even when marketed as agents.
  • Bounded agent: the model chooses the path within a narrow domain and a hard step limit. Suitable for support triage, coding tasks and data cleanup.
  • Open-ended multi-agent system: several agents with different roles negotiate or hand off work. Powerful for research and large builds, expensive and hard to evaluate.

Why the loop changes the economics

Each additional step is another full model call, and in a stateless API each call resends the growing transcript. A five-step task with a 4,000-token context can consume 20,000 tokens or more before tool outputs are counted. Latency compounds too: five sequential calls at two seconds each is a ten-second interaction before any network hop to the tools. Reliability compounds in the other direction. If each step succeeds 95 percent of the time, twenty independent steps succeed about 36 percent of the time; even at 99 percent per step the same task succeeds only 82 percent of the time. Agents feel magical in demos with three steps and one tool. They feel expensive and flaky at fifteen steps unless the runtime is designed for failure.

Memory and state are design decisions

A chatbot usually has no memory beyond the current context window. An agent needs a durable record of what it has already done, or it will repeat actions after a restart and contradict itself within a long run. There are three useful layers. The transcript is the working memory the model sees on each call. A run record in a database holds the goal, step count, status and references to artifacts, so the process can resume. Long-term memory — customer preferences, past tickets, learned procedures — is retrieved selectively and treated as untrusted data, because anything written by a previous run can be wrong or poisoned. Do not confuse a long context window with memory. Context is expensive, finite and resent on every call; a database is cheap, durable and can be queried by key.

Human approval is a feature, not a failure

The most reliable production agents are not fully autonomous. They pause before irreversible actions and ask a person to confirm, or they operate in a dry-run mode that proposes a plan without executing it. Approval gates are cheap to build and they convert a class of costly mistakes into a review queue. The design question is where to put them: after planning, before spending money, before contacting a customer, before deleting anything. Good gates show the human exactly what will happen, to which records, with which arguments, and allow editing rather than only approve or reject. A gate that shows a wall of model reasoning is not a gate; it is a liability transfer.

Frameworks versus a for-loop

Agent frameworks provide tool registration, message handling, tracing and sometimes planning abstractions. They are useful when you need several of those pieces and when the team already knows the framework. They also add a layer between you and the model's actual behaviour, which makes debugging harder when a call fails. For a first agent, a two-hundred-line loop over the chat completions API with explicit tool functions, a step counter and structured logs is often easier to reason about than a graph framework. Reach for a framework when you need durable execution, human-in-the-loop checkpoints, complex branching or a team that benefits from shared conventions. The abstraction should earn its complexity; an agent that works because you can read every line is a good starting point.

Failure modes that only appear with agency

  • Irreversible action: the model calls delete, refund or send before the user has confirmed. Fix with dry-run modes, idempotency keys and explicit approval for writes.
  • Prompt injection through tool output: a fetched web page or ticket comment contains instructions the model follows. Tool results are untrusted input, not trusted instructions.
  • Goal drift: after several observations the model optimises a sub-task and forgets the original constraint. Restate the goal in the system prompt and check the final state against it.
  • Silent tool failure: an API returns HTTP 200 with an error body, the model treats it as success and continues. Validate tool responses before showing them to the model.
  • Runaway loops: the model retries the same failing call with cosmetic changes. Cap steps, detect repeated actions and escalate.
  • Context overflow: accumulated tool output pushes the original instructions out of the window or increases cost sharply. Summarise or store large results by reference.
  • Over-broad credentials: a tool can read any customer record because scoping was easier. Scope tokens to the task and enforce it server-side.

When a chatbot is the better product

If the answer can be produced from the prompt and retrieved context, and no external state needs to change, a chatbot is cheaper, faster, easier to evaluate and safer. Customer FAQs, document Q&A, drafting assistants, summarisers and classifiers all fit. A useful test is whether you can write the required behaviour as a deterministic function of the input; if you can, a single model call plus code will usually beat an agent on cost and reliability. Chatbots also fail gracefully: the user sees a bad answer and retries. Agents fail with side effects, which turns a quality problem into an operational one.

When an agent earns its cost

Agents make sense when the path is not known in advance and depends on what the tools return. A coding agent must inspect a repository, run tests and react to failures. An operations assistant must check several systems before deciding whether an alert is real. A research workflow must choose which sources to open next. In each case, hard-coding every branch would be brittle, and a single model call lacks the information to answer. The economic test is simple: compare the agent's token and latency cost with the value of completing the task, then compare both with a human doing it. If the task is high-volume and narrow, a workflow with one model call is usually the better investment.

Designing the first agent

  • Pick one goal with a clear success condition, such as "resolve a refund request" rather than "help customers".
  • Start with three to five tools, all narrow and typed. Add tools only when traces show the agent asking for them.
  • Make every write idempotent and every destructive action require confirmation. A retry after a timeout must not refund twice.
  • Cap steps, wall-clock time and spend per task, and return a clear partial result when a budget is exhausted.
  • Log the full trajectory: messages, tool arguments, raw results, model names, token counts and latencies.
  • Build an evaluation set of thirty to fifty real tasks before tuning prompts. Score task success, steps used and cost, not just the tone of the final answer.
  • Run the agent in shadow mode against live traffic before letting it act, and review the traces weekly.

Evaluating an agent is not evaluating a chatbot

For a chatbot, you can grade the answer against a reference. For an agent, the final answer may be correct while the trajectory is unacceptable — it read data it should not have, or made three redundant calls. Evaluate at three levels: outcome (did the task actually complete in the external system), trajectory (were the tools and arguments appropriate), and efficiency (steps, tokens, latency). Keep a replayable trace for every failure so the fix can be tested against the same case. Track escalation and human-override rates as leading indicators; they often move before aggregate success does.

Bottom line

A chatbot answers; an agent acts. The difference lives in the runtime — tools, state, loop and guardrails — not in the weights. Treat autonomy as a cost you pay for flexibility, start with the least of it that solves the problem, and measure whether the added steps are buying completion or just movement.

Page feedback

Was this helpful?

A quick signal helps improve these notes.

Report a mistake Straight to the lab inbox

Put it to work

See the models, datasets and gateway this lab runs.