AI Agents vs. Chatbots and Workflows: How Autonomous AI Systems Work

Humanoid robot representing autonomous AI agents

An AI agent is a system in which a language model decides, step by step, which actions to take and which tools to use to reach a goal, instead of following a sequence a developer fixed in advance. In practice an agent is a model calling tools in a loop: it acts, reads the result, and chooses the next action until the task is done or a stopping rule kicks in. A chatbot, by contrast, replies to a message and waits for the next one.

This article explains what separates an agent from a chatbot and from a scripted workflow, shows what one agent run looks like from the inside, and gives a practical way to decide whether your problem needs an agent at all. If you arrived from our older page on AI agents vs. chatbots, that comparison is covered in the first section.

Chatbot, workflow or agent: the differences in one table

The cleanest way to tell these apart is to ask who decides the next step. Anthropic’s engineering guide Building Effective Agents draws the key line: in a workflow, models and tools are orchestrated through predefined code paths; in an agent, the model directs its own process and tool usage. A plain chatbot sits before both, because it usually takes no actions beyond writing text.

QuestionChatbotWorkflowAgent
Who decides the next step?The user, one message at a timeThe developer’s codeThe model
Uses tools?Usually no, or one call per messageYes, at fixed pointsYes, chosen at run time
Number of stepsOne reply per turnKnown in advanceUnknown until the task is done
Reacts to results?Only when the user doesOnly through branches the developer wroteYes, each result shapes the next action
PredictabilityHighHighLower
Cost and latencyLowestFixed and measurableVariable, can run long
Typical exampleFAQ assistant on a websiteSummarize a document, translate it, format it as an emailFind why a test fails, fix the code, rerun the tests until they pass

Two edge cases cause most of the confusion. A chatbot that can call one tool per message (look up an order, then answer) is better described as a tool-augmented assistant: the human still drives every step. And a workflow that uses a model at several stages is still a workflow if the code decides the order. The word “agent” fits when the system chains several tool calls on its own, reacts to what comes back, and keeps going until the goal is met.

The parts every agent is built from

Every agent combines a model, a set of tools, a loop and a stopping rule. Anthropic calls the starting point the “augmented LLM”: a model given retrieval, tools and memory, which it can use by writing its own search queries, choosing tools and deciding what to keep.

  • The model reads the goal, the history so far and the latest tool results, then decides what to do next.
  • Tools are functions the model can request: search, read a file, run code, query an API, send a message. The model asks for them through function calling (tool use), and your code runs them.
  • The loop is plain application code: send the request, execute any tool calls, append the results, send again.
  • Environment feedback is what makes the loop useful. Test output, an HTTP error or an empty search result tells the model whether it is on track. Anthropic’s guide stresses that agents need this “ground truth” at each step.
  • Stopping conditions end the run: the model says it is done, a maximum number of iterations is reached, a budget is exhausted, or a human checkpoint is hit.
  • Memory and context hold the task state. Short runs keep everything in the context window; longer ones save notes or summaries outside it.

What one agent run looks like from the inside

Watching a single run step by step makes the definition concrete. The trace below is an illustrative example of a coding agent given the task “the test_invoice_total test fails, fix it”. The tools are run_tests, read_file and edit_file; file names and outputs are invented.

Step 1  model  -> run_tests(path="tests/test_invoice.py")
        result <- FAILED test_invoice_total: expected 107.00, got 100.00

Step 2  model  -> read_file(path="billing/invoice.py")
        result <- def total(items, tax_rate): return sum(i.price for i in items)

Step 3  model  -> read_file(path="tests/test_invoice.py")
        result <- assert total(items, tax_rate=0.07) == 107.00

Step 4  model  -> edit_file(path="billing/invoice.py",
                   old="return sum(i.price for i in items)",
                   new="return round(sum(i.price for i in items) * (1 + tax_rate), 2)")
        result <- OK

Step 5  model  -> run_tests(path="tests/")
        result <- 42 passed

Step 6  model  -> final answer: "total() ignored tax_rate. I applied it and
                  rounded to cents; the full test suite passes."

Notice what nobody scripted. The developer did not write “read the test file after reading the source”; the model chose step 3 because step 2 left a question open. It also chose to run the whole suite in step 5, not only the failing test, to check it had not broken anything else. That run-time choice of steps is the defining trait. Had step 5 failed, the loop would have continued with another read and edit, which is also why the number of steps, and therefore cost, cannot be known in advance.

This alternating pattern of reasoning and acting is closely related to the ReAct prompting technique, which interleaves thought, action and observation; modern tool-use APIs build the same cycle into the request format.

The loop in code

The core of an agent is short; the hard parts are the tools, the limits and the error handling around it. This Python sketch uses the Claude Messages API shapes. TOOLS and run_tool are placeholders for your tool definitions and dispatcher.

import anthropic
client = anthropic.Anthropic()

def run_agent(goal, max_steps=15):
    messages = [{"role": "user", "content": goal}]
    for step in range(max_steps):
        resp = client.messages.create(
            model="claude-opus-5-5", max_tokens=4096,
            tools=TOOLS, messages=messages)
        messages.append({"role": "assistant", "content": resp.content})

        if resp.stop_reason != "tool_use":          # model says it is done
            return resp.content

        results = []
        for block in resp.content:                  # may be several calls
            if block.type == "tool_use":
                output, failed = run_tool(block.name, block.input)
                results.append({"type": "tool_result",
                                "tool_use_id": block.id,
                                "content": output,
                                "is_error": failed})
        messages.append({"role": "user", "content": results})

    return "Stopped: step limit reached before the task was finished."

Three lines matter more than they look. max_steps is the stopping rule that keeps a confused model from looping forever. The inner for handles several tool calls in one response. And is_error returns failures to the model as information it can react to, instead of crashing the run.

Workflow patterns to try before an agent

Anthropic’s guide recommends starting with the simplest solution that works and adding agentic complexity only when it clearly improves results, because agentic systems trade latency and cost for task performance. Before building an agent, check whether one of the workflow patterns it describes already covers your task:

  • Prompt chaining: a fixed sequence of model calls, each working on the previous output, with optional checks between steps. Good when the task splits cleanly into known subtasks, such as outline, check, then draft.
  • Routing: classify the input first and send it to a specialized prompt or model. Good for support queues with distinct categories, or sending easy questions to a smaller model.
  • Parallelization: run independent subtasks at once (sectioning) or run the same task several times and compare (voting).
  • Orchestrator-workers: one model breaks the task down at run time and hands pieces to worker calls, then merges the results. This is the step closest to an agent.
  • Evaluator-optimizer: one call drafts, another critiques against clear criteria, and the loop repeats until the critique passes.

When the orchestrator and workers are themselves agents with their own tools and context, you are in multi-agent territory, which has its own coordination problems covered in multi-agent AI.

Deciding whether your task needs an agent

An agent earns its extra cost when a task has a clear success condition but an unpredictable path to it. Anthropic describes the right fit as open-ended problems where the number of steps cannot be predicted or hardcoded and where you trust the model’s decisions. Answer these questions in order:

  1. Can you write the steps down in advance? If yes, build a workflow. It will be cheaper, faster and easier to debug, because you know which step failed.
  2. Is there a reliable signal of success? Tests that pass, a record that exists, a document that validates. Without one, the agent cannot tell when it is done, and neither can you.
  3. Can the environment give feedback after each action? Agents work well in coding and data tasks because errors are visible. They struggle when actions give no feedback.
  4. What does a wrong action cost? Reading files is cheap to get wrong; sending payments, deleting data or emailing customers is not. High-cost actions need human approval no matter how good the model is.
  5. Can you afford variable cost and latency? A run might take 4 steps or 40. Set budgets, and measure the distribution of real runs before promising response times.

Where agents are being used

The tasks that fit the checklist share a pattern. Coding agents read a codebase, change it, run tests and iterate on failures. Research agents run many searches, read sources and synthesize findings. Support agents look up an order, check a policy and propose or apply a resolution. Operations agents investigate an alert by querying logs and metrics before a human decides on the fix. In each case the goal is clear but the number of lookups is not.

Risks and the controls that address them

The main risk specific to agents is that they act, so a wrong decision becomes a wrong action. OWASP’s Top 10 for LLM applications names this Excessive Agency and traces it to three root causes: excessive functionality, excessive permissions and excessive autonomy. Each maps to a concrete control:

Root causeWhat it looks likeControl
Excessive functionalityThe agent has a general shell tool when it only needs to write one fileExpose narrow, purpose-built tools; remove tools the task does not need
Excessive permissionsA reporting agent connects to the database with a read-write accountLeast-privilege credentials; read-only where possible; act in the user’s security context
Excessive autonomyThe agent can issue refunds or delete records with no reviewHuman approval for high-impact actions; enforce authorization in the downstream system, not in the prompt

Two other failure modes are worth planning for. Compounding errors: an early wrong assumption carries through every later step, which is why Anthropic recommends extensive testing in sandboxed environments with guardrails. Prompt injection: an agent that reads web pages, emails or tickets can meet text written to redirect it, so content returned by tools should be treated as data, never as instructions. Logging every tool call and its arguments does not prevent these problems, but it makes them diagnosable.

Designing tools the agent can use well

Tool design usually decides agent quality more than the main prompt does. Anthropic calls this the agent-computer interface and suggests giving tool definitions as much prompt-engineering attention as the prompt itself. Its practical advice:

  • Write descriptions as you would for a new colleague: what the tool does, example usage, edge cases, input format, and how it differs from similar tools.
  • Pick input formats the model writes easily and avoid ones that need bookkeeping, such as counting line numbers or escaping long strings.
  • Make mistakes hard to make. Anthropic reports that switching a tool from relative to absolute file paths removed a class of errors.
  • Test the tools with many inputs, read the transcripts, and change the tool when the model keeps misusing it.

If you want the same tools available to several agents or apps, the Model Context Protocol (MCP) gives you a standard way to package them once.

Common questions

How is an AI agent different from RAG?

Retrieval-augmented generation (RAG) is a technique for giving a model relevant documents at answer time; an agent is a system that decides which actions to take. They combine often: an agent may have a search tool and decide when to retrieve, how many times, and with which query. See retrieval-augmented generation (RAG) for how retrieval works on its own.

Do agents run without human oversight?

Some do, for narrow low-risk tasks with tightly limited permissions. Most production setups add checkpoints where the agent pauses for approval, and the level of oversight usually scales with the cost of a mistake. Anthropic’s description of agents includes returning to the human for information or judgment when the agent hits a blocker.

Is a chatbot with web search an agent?

It depends on what happens after the first search. If it searches once and answers, it is a tool-augmented chatbot. If it reads the results, decides they are not enough, refines the query, opens pages and keeps going until it can answer, it is behaving as an agent for that request.

Sources

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top