AI agent: what it is, how it is built and how it differs from a chatbot
An agent is a model that picks its own actions and repeats a loop until the task is done. The structure, examples and honest limits.
5 min · · агенты · models
AI agent, what is it, if we already have chatbots that work as "ask a question, get an answer"? In short: an agent does not only answer, it acts. It decides which tool to call, looks at the result and continues until the task is solved. Below we cover what it consists of, how the loop works, how it differs from an ordinary chat and where agents are already useful.
Chatbot and agent: what is the difference
An ordinary chat is simple: you write a message, the model replies with text. All it does is generate text. It does not open files, run commands or browse the internet.
An agent is built differently. It is given a set of tools and a goal. It finds the right file in a project, reads it, runs the tests, sees an error, fixes the code and runs the tests again. A person does not dictate each step.
| Chatbot | Agent | |
|---|---|---|
| What it does | replies with text | picks actions and performs them |
| Model requests | usually one per message | dozens per task |
| What it sees | only your message and history | results of its own tools |
| Who decides what is next | you | the model, within set rules |
What an agent consists of
Strip away the marketing and four parts remain.
1. The model
This is the "brain": a language model that receives context and decides what to do. The same agent can run on different models, and both cost and result will change.
2. Tools
Functions the agent can call: reading a file, running a command, searching a database, sending an email, calling an external API. The model does not execute them itself: it returns a structured request such as "call read_file with the argument app.py", your code executes it and sends the result back.
3. The loop
The heart of the agent. The scheme:
- Send the model the task, the history and the list of tools.
- If the model asked to call a tool, execute it and add the result to the history.
- Go back to step 1.
- If the model replied with plain text and no tool call, consider the task finished.
The loop must have a safety stop: a maximum number of steps and a budget, otherwise the agent can spin forever.
4. Memory and instructions
Short-term memory is the message history in the current run. Long-term memory is everything the agent writes to files or a database and reads next time. System instructions belong here too: role, rules, constraints. In Claude Code, for example, the CLAUDE.md file in the project root serves this purpose.
A minimal agent in code
Below is a loop in Python using the OpenAI SDK pointed at the Zukko gateway. There is one tool: reading a file.
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.zukko.pro/v1", api_key="fetch_your_key")
tools = [{
"type": "function",
"function": {
"name": "read_file",
"description": "Read a text file by path",
"parameters": {
"type": "object",
"properties": {"path": {"type": "string"}},
"required": ["path"],This is a teaching example: a production version needs path validation (so the agent does not read extra files), error handling and cost tracking. A full walkthrough with a budget is in how to build an AI agent in Python from scratch. If you do not want to write the loop yourself, take a ready-made agent such as Hermes: connection is described in the documentation.
Why an agent costs more than a chat
At every step of the loop the model receives the whole accumulated history. The context grows, and the cost of the steps grows with it.
An example. An agent makes 8 steps, with context at each step of 2,000, 3,000, ... 9,000 tokens, so the sum of input over the session is 2 + 3 + ... + 9 = 44,000 tokens. Output is 300 tokens per step, 2,400 in total. For gpt-6.1-sol (prices at October 18, 2026: $0.27 per 1M input, $1.32 per 1M output):
- Input: 44,000 × 0.27 / 1,000,000 = $0.01188
- Output: 2,400 × 1.32 / 1,000,000 = $0.003168
- Total: about $0.015 for a short task without cache
That is not much. But real coding sessions can run to hundreds of steps with contexts of tens of thousands of tokens, and there cost is determined by cache and model choice. For GPT, cache is accounted on reads; for Claude in the Anthropic format, both reads and writes. Details are in the keys, limits and cache section of the documentation.
Where agents are already useful
- Development. Editing code from a description, running tests, fixing build errors. The result is checked by tests and a git diff.
- Routine data processing. Sorting mail, reconciling tables, filing documents. The task repeats and the rules are clear.
- Research and information gathering. The agent collects material from several sources and prepares a summary that a person checks.
Where agents are still unreliable
- Tasks without a clear "done" criterion: the agent may stop early or wander off.
- Irreversible actions: deleting data, payments, sending emails to customers. A human confirmation is needed here.
- Long chains without checks: an error at an early step carries through to the end.
- Looping. More in an agent looped and spent the budget.
A practical rule: give the agent exactly the permissions the task needs, and set a spending limit on the key.
FAQ
Are an AI agent and an AI assistant the same thing?
The boundaries are blurry. Usually an assistant is a chat that answers questions, while an agent is a system that performs steps on its own using tools.
Does an agent need a special type of model?
It needs a model that can call tools (tool calling). Check support and call quality for a specific model on your own examples before building an agent on it.
How much does it cost to run an agent?
It depends on the number of steps, context size and model. To estimate, use the formula: input × input price + output × output price (plus cache at its prices). Prices are on the "Models" page in the dashboard and in GET /v1/models.
How do I protect against uncontrolled spending?
Set a daily and a monthly dollar limit on the key and cap the number of steps in the loop itself. Both the limits and the key itself are set up in the dashboard.
zukko
Pay 25×
less
for Claude Code & ChatGPT
One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.
Related articles
- AI agent vs AI assistant: the difference and what to pick for a taskA model answers, an assistant remembers the dialogue, an agent takes steps with tools on its own. The differences by example, and how to decide what your task needs.
- Roo Code Ollama: local models in Cline and Aider, an honest lookWe connect Ollama to Roo Code, Cline, Aider and OpenCode per each tool's documentation, cover the limits and show when it is simpler to return to a cloud API.
- opencode agents: setting up roles, models and toolsA custom agent in opencode is a role, a model and a set of permissions. A working config where a cheap model handles routine work and a stronger one edits code.
- Plan mode in Claude Code: plan first, then edit the codeIn plan mode Claude Code reads your code and proposes a plan but edits nothing until you agree. How to enable it, use it and what it costs.