Özer Cem KELAHMETKELAHMET
Articles · Agentic AI basics

What is an AI agent? Agents versus chatbots and workflows, explained with runnable code

The word agent now covers everything from a chat window to software that edits code for hours. This guide gives a precise working definition, compares a chatbot, a workflow and an agent on the same refund request in plain Python, and explains how to decide which one a task needs.

Download Markdown
At a glance
Reading time
14 min
Sections
10
Code examples
3
Tables
2
Sources
7
Published
23 Nov 2026
In 30 seconds
What changed
Agent frameworks converge on the same core loop (November 2026 releases)
Why it matters
Describe systems by where control lives, not by the label.
What to do
Write the task as a flowchart first

An AI agent is a program in which a language model decides, step by step, which actions to take to reach a goal, carries them out through tools, looks at the results and decides again, until it judges the task done or hits a limit. That loop is the whole difference. A chatbot answers once. A workflow follows steps written in code. An agent chooses its own next step.

The distinction matters because it changes cost, reliability and risk. Every extra decision the model makes is another model call, another chance to go wrong and another action someone must be able to audit. Many products marketed as agents are in fact workflows, and many problems that teams try to solve with agents would be cheaper and safer as workflows. This article sets out the definitions used by the main framework builders, runs the three shapes side by side on one request, and gives a practical test for choosing.

What happened

Agent frameworks converge on the same core loop (November 2026 releases)

The current releases of the main agent frameworks all ship the same core: a model, a set of tools, instructions, and a loop that runs until the model stops calling tools. LangChain 1.5.0 was published on 11 November 2026 and 1.5.2 on 18 November; its documentation describes an agent as "a model calling tools in a loop until a task is complete, shaped by a harness of prompt, tools, and middleware". The OpenAI Agents SDK reached 0.25.0 on 18 November 2026, and the Claude Agent SDK for Python reached 0.2.187 on 20 November 2026. The names differ, the loop does not.

The workflow-versus-agent split is now standard vocabulary

LangGraph's documentation draws the same line Anthropic drew in its guide "Building effective agents": workflows "have predetermined code paths and are designed to operate in a certain order", while agents "are dynamic and define their own processes and tool usage". Anthropic's guide uses near-identical wording: workflows orchestrate models and tools "through predefined code paths", and agents are systems where models "dynamically direct their own processes and tool usage". This shared vocabulary is useful, because it lets you describe a system's autonomy precisely instead of arguing about whether it "is an agent".

Chatbot, workflow, agent: three shapes

An everyday analogy: a chatbot is a reference librarian who answers your question from memory. A workflow is a checklist at a bank counter: the clerk follows the same steps for every customer and only uses judgement inside a step. An agent is a personal assistant given a goal ("sort out the refund") who decides which calls to make, in what order, and when to stop.

Table 1. Chatbot, workflow, agent: three shapes
Shape Who decides the steps Model calls per request Can act on systems Predictability
Chatbot Nobody; one reply 1 No High
Workflow Your code Fixed, often 1 to 5 Yes, through coded steps High
Agent The model, at run time Variable, often 3 to 50 Yes, through tools it chooses Lower

The table hides a spectrum. A workflow can contain model calls that classify or route, and an agent can be fenced in by code that forbids some tools or requires approval. Most production systems sit somewhere between, and the useful question is how much of the control flow the model owns.

The same request, three ways

The script below answers "My order 1042 arrived broken. Can you refund it?" as a chatbot, a workflow and an agent. A small deterministic function stands in for the model, so the run needs no API key and always prints the same result. It counts model and tool calls.

# three_shapes.py: chatbot vs workflow vs agent. No dependencies.
import json

ORDERS = {"1042": {"status": "delivered", "damaged": True, "price": 59.90},
          "2077": {"status": "in transit", "damaged": False, "price": 19.00}}
CALLS = {"model": 0, "tool": 0}

def fake_model(messages, tools=None):
    """Stand-in for an LLM. Reads the conversation and returns text or a tool call."""
    CALLS["model"] += 1
    last = messages[-1]["content"]
    if not tools:                                   # plain completion
        return {"text": f"(answer based on: {last[:60]})"}
    seen = [m for m in messages if m["role"] == "tool"]
    if not seen:
        return {"tool": "get_order", "args": {"order_id": "1042"}}
    order = json.loads(seen[0]["content"])
    if order["damaged"] and len(seen) == 1:
        return {"tool": "issue_refund", "args": {"order_id": "1042", "amount": order["price"]}}
    if len(seen) == 2:
        return {"text": f"Refunded {json.loads(seen[1]['content'])['refunded']} EUR for order 1042."}
    return {"text": "Order 1042 is not damaged, so no refund is needed."}

def get_order(order_id):              CALLS["tool"] += 1; return ORDERS[order_id]
def issue_refund(order_id, amount):   CALLS["tool"] += 1; return {"refunded": amount}
TOOLS = {"get_order": get_order, "issue_refund": issue_refund}

def chatbot(question):
    """One model call. No tools, no loop."""
    return fake_model([{"role": "user", "content": question}])["text"]

def workflow(question):
    """Fixed code path: always look up, then decide in code, then one model call to phrase it."""
    order = get_order("1042")                        # step 1 is hard-coded
    action = issue_refund("1042", order["price"]) if order["damaged"] else None   # step 2: rule in code
    return fake_model([{"role": "user", "content": f"Write a reply. Order={order}, action={action}"}])["text"]

def agent(question, max_steps=5):
    """The model chooses the next tool until it answers or hits the step limit."""
    messages = [{"role": "user", "content": question}]
    for step in range(1, max_steps + 1):
        out = fake_model(messages, tools=list(TOOLS))
        if "text" in out:
            return out["text"]
        result = TOOLS[out["tool"]](**out["args"])
        print(f"  step {step}: {out['tool']}({out['args']}) -> {result}")
        messages.append({"role": "tool", "content": json.dumps(result)})
    return "Stopped: step limit reached"

q = "My order 1042 arrived broken. Can you refund it?"
for name, fn in [("chatbot", chatbot), ("workflow", workflow), ("agent", agent)]:
    CALLS.update(model=0, tool=0)
    print(f"{name}:")
    print("  result:", fn(q), "| model calls:", CALLS["model"], "| tool calls:", CALLS["tool"])
chatbot:
  result: (answer based on: My order 1042 arrived broken. Can you refund it?) | model calls: 1 | tool calls: 0
workflow:
  result: (answer based on: Write a reply. Order={'status': 'delivered', 'damaged': True) | model calls: 1 | tool calls: 2
agent:
  step 1: get_order({'order_id': '1042'}) -> {'status': 'delivered', 'damaged': True, 'price': 59.9}
  step 2: issue_refund({'order_id': '1042', 'amount': 59.9}) -> {'refunded': 59.9}
  result: Refunded 59.9 EUR for order 1042. | model calls: 3 | tool calls: 2

What the three runs show:

  1. The chatbot cannot act. It produces text based only on the question. It can explain a refund policy but cannot check the order or issue the refund.
  2. The workflow acts, but your code decides. The lookup and the refund rule ("refund if damaged") are written in Python. The model only phrases the reply. One model call, two tool calls, and the same path every time.
  3. The agent decides the path. The model chose to look up the order, read the result, chose to refund, then chose to stop. Three model calls for the same two tool calls, because each decision is a call.
  4. The agent needs a stop rule. max_steps=5 guarantees the loop ends even if the model keeps calling tools. Real frameworks have the same guard, such as LangChain's ModelCallLimitMiddleware or the max_turns argument in the OpenAI Agents SDK's runner.

In a real framework the agent function shrinks to a few lines. In LangChain 1.5 it is create_agent(model, tools=[get_order, issue_refund], system_prompt=...), and the loop, tool execution and message handling are built in. The agent loop step-by-step article traces that loop in detail, and the ReAct tool-calling simulation animates it.

Inside the agent loop

Every agent, whatever the framework, repeats the same cycle:

  1. Instructions and state. The model receives a system prompt, the conversation so far and descriptions of the available tools.
  2. Decide. The model returns either a final answer or one or more tool calls, each a tool name plus arguments in a structured format. This is function calling.
  3. Act. Your code, not the model, runs the tool. This is where permissions, validation and approval live.
  4. Observe. The tool's result is added to the conversation as a new message.
  5. Repeat or stop. The loop ends when the model answers without calling a tool, or when a limit on steps, time or cost is reached.

The pattern goes back to the 2022 ReAct paper, which interleaved reasoning traces with actions and observations. Modern models do the same thing through native tool-calling APIs. See the ReAct loop for the original idea.

Two consequences are worth stating. First, the model never touches your systems directly; it only asks. Your tool code is the security boundary. Second, every observation is new input to the model, so a tool result can steer the agent, for better (an error message that suggests a fix) or worse (a web page that contains injected instructions).

The parts every agent is built from

Strip away the branding and an agent has five parts. Knowing them makes any framework easier to read.

  • The model. The language model that makes decisions. Its tool-calling skill, context window and price set the limits of the whole system. Agents often mix models: a strong one for planning, a cheaper one for routine steps.
  • Instructions. The system prompt: the goal, the rules, the tone and when to stop. In practice this is where most behaviour is tuned, and it is the agent's procedural memory.
  • Tools. Functions the model may call, each with a name, a description and an argument schema. Tool descriptions are prompts too: a vague description causes wrong calls more often than a weak model does.
  • State and memory. The conversation so far, plus anything saved between sessions such as user preferences. Without it, every step starts from nothing. See agent memory.
  • The harness. The code around the loop: limits, retries, error handling, approval steps, tracing and the rules for what gets fed back to the model. Frameworks differ most here. LangChain calls its version middleware; other SDKs use hooks, guardrails or callbacks.

A useful check when you read about a new agent product is to ask which of these five parts changed. A new model changes decisions. A new harness changes safety and cost. A new tool set changes what the agent can do in the world. Most launches change one of them, and naming which helps you predict what will improve and what will not.

Workflow patterns before agents

Anthropic's guide lists five workflow patterns that cover many tasks before full autonomy is needed:

Table 2. Workflow patterns before agents
Pattern How it works Example
Prompt chaining A fixed sequence of model calls, each using the last output Draft, then translate, then check style
Routing A model or classifier picks one of several fixed paths Send refunds, billing and bugs to different handlers
Parallelisation Several calls run at once and results are combined Check one document against five policies
Orchestrator-workers A model splits a task and assigns parts to workers Edit several files for one feature
Evaluator-optimiser One call generates, another critiques, in a loop Rewrite until a rubric passes

Orchestrator-workers and evaluator-optimiser already hand some control to the model, which is why they sit at the border with agents. The agentic patterns simulation shows each layout, and orchestrator-workers describes the most common one in more depth.

When is an agent worth it?

A practical test has four questions:

  • Can you write the steps down? If the path is the same for most requests, a workflow is cheaper, faster and easier to test.
  • Does the path depend on what you find? Debugging, research and multi-system support tasks branch on intermediate results. That is where agents earn their cost.
  • Can a wrong action be undone? If a mistaken tool call is cheap to reverse, more autonomy is acceptable. If it moves money or deletes data, add approval steps or keep the decision in code.
  • Can you check the result? Agents work best where success is verifiable, such as tests passing or a database reaching the right state.

The cost difference is concrete. In the demo the agent used three model calls where the workflow used one. Each later call also rereads the growing conversation, so token cost grows faster than the step count. The agent run simulation lets you vary the steps and see the effect.

What it means in practice

Describe systems by where control lives, not by the label. "A routing workflow with one agentic step for research" tells an engineer, a reviewer and an auditor much more than "our agent". Start with the simplest shape that works, measure it, and add autonomy only where a fixed path fails. When you do build an agent, put the effort into tools (clear names, tight argument schemas, helpful error messages), limits (steps, cost, time) and visibility (traces of every step). Our frameworks overview compares the libraries that provide these pieces, and the Agentic AI learning path orders the topics for study.

What to do now

  1. Write the task as a flowchart first. If the chart has few branches, build a workflow.
  2. Mark the branch points. Use a model only where the next step depends on content code cannot judge.
  3. Keep actions in code. Let the model request tool calls, and validate every argument before running them.
  4. Set hard limits. Cap steps, tokens and wall-clock time for every agent loop.
  5. Gate irreversible actions. Require human approval for payments, deletions and external messages.
  6. Trace every step. Record each model input, tool call and result so failures can be diagnosed.
  7. Test with repeated runs. Run each test case several times; agents can pass once and fail the next time.
  8. Revisit the shape. When a pattern becomes stable in traces, move it from the agent into a fixed workflow step.

Risks and open questions

Autonomy multiplies failure points. Each model decision can be wrong, and errors early in a run carry forward. More steps mean more chances to fail.

Tool results are untrusted input. Anything a tool returns, especially web pages and emails, can contain instructions that redirect the agent. See guardrails for defences.

Costs are variable. Unlike a workflow, an agent's cost per request depends on how many steps it takes, which makes budgeting harder.

The label is used loosely. Vendors call many things agents. Ask who decides the next step, which actions it can take and what limits apply.

Watch next: whether frameworks converge on shared formats for tools and traces, and how far longer-running background agents push the need for approval and audit tooling.

Frequently asked questions

What is the simplest definition of an AI agent?

A program in which a language model chooses actions, calls tools to carry them out, reads the results, and repeats until the goal is met or a limit is reached. The model decides the path at run time instead of following steps written in advance.

Is a chatbot with tools an agent?

If it can call several tools in a row and decide what to do next based on the results, it behaves as an agent. If it makes at most one fixed lookup before answering, it is closer to a workflow. The useful question is how much of the control flow the model owns.

Are agents always better than workflows?

No. Workflows are cheaper, faster and more predictable, and many tasks have a fixed path. Agents help when the right steps depend on what is discovered along the way, such as debugging or open-ended research.

Why does an agent need a step limit?

Nothing in the model guarantees it will stop calling tools. A limit on steps, tokens or time ensures the loop ends, controls cost, and turns a stuck run into a visible failure rather than a silent bill.

Do I need a framework to build an agent?

Not to understand one. The loop in this article is about 15 lines of Python. Frameworks add tool schemas, retries, memory, tracing, streaming and human approval, which matter in production.

Summary

An AI agent is a model running in a loop: decide, act through a tool, observe, repeat, stop. A chatbot answers once, a workflow follows a code path you wrote, and an agent chooses its own path. On the same refund request, the workflow used one model call and the agent used three, because each decision is a call. Current frameworks, from LangChain 1.5 to the OpenAI Agents SDK and the Claude Agent SDK, ship the same loop. Start with the simplest shape that works, keep actions and limits in code, and give the model control only where the next step truly depends on what it finds.

Sources

Cite this article

Kelahmet, Ö. C. (2026, November 23). What is an AI agent? Agents versus chatbots and workflows, explained with runnable code. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/what-is-an-ai-agent-chatbot-workflow

BibTeX
@online{kelahmet2026what,
  author = {Kelahmet, {\"O}zer Cem},
  title  = {{What is an AI agent? Agents versus chatbots and workflows, explained with runnable code}},
  year   = {2026},
  month  = {nov},
  url    = {https://www.ozercemkelahmet.com/articles/what-is-an-ai-agent-chatbot-workflow}
}
Version historyfirst version
  1. Published

Factual corrections are listed here with what changed. Wording and formatting edits are not listed.

Last updated Nov 23, 2026
Type to search.
    ↑↓ navigate↵ open