Skip to content
AI & MLintermediate

What is an AI agent?

Updated Nov 30, 20263 min readBased on official documentation
What is an AI agent?

In short

An AI agent is a program that uses a language model to plan steps, call tools, and keep track of progress until a task is done. Instead of answering one prompt, it works through several steps on its own. OpenAI offers three ways to build one: a managed Agents API, the Agents SDK, and the Responses API.

The basic idea

A normal call to a language model takes a prompt and returns a reply. An AI agent goes further. It receives a goal, decides what to do next, uses tools to act on the world, and checks the results before it continues. This loop of planning, acting and observing is what makes it an agent.

The documentation describes three things an agent can do. It can plan and complete tasks using tools. It can work with other agents. It can also keep context across steps, so it remembers what it already tried and what it found.

Choosing where the agent runs

Building an agent means deciding who runs the loop and who stores the state between steps. The OpenAI guide lays out three options, each with a different amount of work for you.

  • Agents API. OpenAI runs a managed Codex harness, which is the software that drives the agent. OpenAI also keeps the session and its progress. This suits long-running tasks where you do not want to manage the infrastructure. Integration effort is low.
  • Agents SDK. The SDK runs inside your own application. You define agents, tools and handoffs, and a runner executes the loop. You control deployment, storage and approvals. Integration effort is medium.
  • Responses API. You call the model directly and build the agent logic yourself. You manage the history, or chain responses together. This gives the most control and the most work. Integration effort is high.

A simple rule: start with the lowest-effort option that still fits your needs. Move down the list only when you need more control over storage, tools or the execution environment.

Tools, handoffs and sandboxes

Tools are what let an agent act. A tool might be a function in your code, a call to an external service, or a hosted capability provided by the platform. The agent chooses which tool to call and reads the result. Tool design matters, because a clear tool description helps the model pick the right one.

Handoffs are a way for one agent to pass work to another agent. In the Agents SDK, the runner handles this step for you. This is useful when a task has parts that call for different instructions or tools.

Some agents run code or commands. For that, a sandbox is an isolated environment where that work happens safely. The documentation mentions hosted sandboxes, self-hosted sandboxes, or no sandbox at all. Choose based on how much risk you accept and where your data must stay.

A simple example

Imagine an agent that answers questions about open orders. Its goal is to find the order status and explain it to the user. It has one tool, a function that looks up an order by ID in your database. The loop might look like this:

  1. The agent reads the user's question and sees it needs an order ID.
  2. It asks the user for the ID, or calls a lookup tool if the ID is already known.
  3. It reads the tool result, such as "shipped on Monday".
  4. It writes a clear answer and stops, because the goal is met.

The key point is that the model decides the next step at each turn. Your code supplies the tools and enforces the limits.

Common mistakes

Many first agents fail for predictable reasons. Keep these in mind.

  • Mixing up the resources. An Agents API session, an SDK session, a Responses conversation and a sandbox are separate things. Each one has its own state and cleanup steps. Read the instructions for your chosen runtime before you assume a session is closed.
  • Giving too many tools. A large tool list makes the choice harder for the model. Start with a few well-described tools.
  • Ignoring state. If you do not store history, the agent forgets earlier steps. Decide early who keeps that state.
  • Skipping the docs for prompt caching and usage. Caching and session accounting work differently per API, so check the details for your runtime.

Where to go next

Read the official guide to see the architecture and the configuration for each API. Start with the overview that matches your choice, then add tools one at a time. Build a small agent first, check its steps in a log, and only then add more agents or handoffs.

FAQ

Is an AI agent the same as a chatbot?

Not quite. A chatbot usually answers one message at a time. An agent can plan several steps, call tools, and keep track of what it has done until the goal is reached.

Which OpenAI option should I pick first?

Start with the option that needs the least setup for your case. The Agents API is the lowest effort because OpenAI runs the loop. Choose the Agents SDK or the Responses API when you need more control over storage, tools or deployment.

What is a handoff between agents?

A handoff passes the current task from one agent to another, usually because the second agent has different instructions or tools. In the Agents SDK, the runner manages this step.

Do I need a sandbox for every agent?

No. The documentation lists hosted sandboxes, self-hosted sandboxes, and no sandbox as options. A sandbox matters most when the agent runs code or commands and you want that work isolated.

Sources

This page is based on the official documentation below. Read it for full detail.

AI agent — official documentation ↗
blozhikDeveloper news from across the web, explained. Every story links to its original sources.