AI agent definition
An AI agent is software that gives a language model a goal and a set of tools, then runs it in a loop: the model picks a tool, the code runs it, the result goes back to the model, and the cycle repeats until the model decides the goal is met or a limit stops the run. The model, not a fixed code path, decides what to do
An AI agent is software that runs a language model in a loop with tools, letting the model decide each turn which tool to call until the goal is met. That loop needs somewhere to fetch trustworthy context on every iteration. Sanity Context supplies it through Context MCP, a hosted read-only endpoint that any agent loop can connect to, so an agent queries live structured content and schema rather than a stale copy pasted into a prompt.

How does an AI agent actually work?
An AI agent works by running a loop: the code sends the model a goal plus a list of tools (named functions the model is allowed to call), the model responds with either a tool call or plain text, the code executes any tool call and appends the result to the conversation history, and the full history goes back to the model for the next turn. Simon Willison's widely reused engineering definition compresses this to a single line: agents run tools in a loop to achieve a goal.
A short example makes the loop concrete. Ask an agent "What time is it in Tokyo?" On iteration one, the model emits one tool call, getTime with the timezone Asia/Tokyo, and no text. The code runs that function and appends the answer to the history. On iteration two, the model emits "It's 2:30 PM in Tokyo" and zero tool calls, so the loop exits. Two iterations. A long autonomous task such as triaging an issue or running a research pass can hit twenty or thirty. Every status line you see in a chat product ("Searching the web for...", "Editing file app.tsx") is one iteration made visible.
An AI agent run ends in one of two ways. The normal exit is the model emitting text with no tool calls, which in Sanity's own observation of real agent traffic is how roughly 99% of conversations finish. The safety hatch is a maximum iteration count, usually between 20 and 50, so a stuck agent cannot loop forever burning tokens. Some systems cap on total tokens or wall-clock time instead.
What is the difference between an AI agent and a workflow?
The difference between an AI agent and a workflow is who controls the sequence of steps. Anthropic draws the line this way in "Building effective agents" (December 19, 2024): workflows are systems where language models and tools are orchestrated through predefined code paths, while agents are systems where the models dynamically direct their own processes and tool usage, keeping control over how they accomplish tasks.
So a pipeline that summarizes a document, translates the summary, then writes it to a database is a workflow, even though every step calls a model. A developer decided the order in advance. An AI agent is given an objective and composes the steps itself, which is why two runs of the same agent on the same input can take different routes.
That distinction matters practically, not just semantically. Anthropic's guidance is to start simple, because for many applications optimizing a single model call with retrieval and good examples is enough, and agentic systems often trade latency and cost for better task performance. An AI agent is not automatically the right architecture. It earns its place when the steps genuinely cannot be known ahead of time.
What is an AI agent made of?
An AI agent is made of five parts, and only one of them is the model. There is the model doing the reasoning, the tools it can call to fetch information or take action, the loop that runs those tools and accumulates history, the context window (the fixed amount of text the model can see on any given call, which is the only memory it has between turns), and the exit conditions that stop the run.
The code wrapping all of this is called the harness, and it is most of what a team actually builds. The model is not the agent, but a component inside it. The harness decides which tools exist, what goes into the context window, how errors are recovered, and when to stop. Harnesses also differ sharply by purpose: a coding agent runs in a harness built for long, sandboxed, autonomous work with a filesystem, a shell, and version control, while a customer-facing agent runs in a harness built for short in-product conversations that act under a user's identity and have to recover from a failure in one sentence.
The practical consequence is that models do not have context, they have a context window, and filling it well is engineering work. What an AI agent can reliably do is largely set by what its harness can put in front of the model at the moment it has to decide.
How is an AI agent different from a chatbot or RPA?
An AI agent differs from a chatbot in where the work lands: a chatbot answers inside the conversation, while an AI agent takes action outside it. The US Government Accountability Office gives a clean illustration in its Science and Technology Spotlight on AI agents (September 10, 2025): a generative AI customer service system can respond to a question about order status, whereas an AI agent could interact with other software systems to process the return or exchange.
An AI agent also differs from traditional automation and robotic process automation (RPA). RPA executes a script someone wrote, step by step, the same way every time. An AI agent is given an objective and composes the steps itself, which makes it more flexible and less predictable.
There is one more distinction worth keeping straight. Retrieval-augmented generation (RAG) adds fetched documents to a single model call. An AI agent may retrieve many times across a run and decides for itself whether to go back for more. Retrieval is a capability an agent uses, not a synonym for agency. Multi-agent systems, where several agents coordinate and one often orchestrates the others, are a further step beyond a single loop.
Why do definitions of AI agent disagree?
Definitions of AI agent disagree because no standards body owns the term and vendors stipulate their own. The GAO stated it plainly in September 2025: there is no universally agreed upon definition of an AI agent. Rather than settle on one, the GAO describes what agents do (sense their environment, process what they find with models and rules, then act toward a goal) and lists properties that make a system more or less agentic. TechCrunch ran a piece in March 2025 titled "No one knows what the hell an AI agent is," and Anthropic opens its own engineering guide by noting that "agent" can be defined in several ways before picking one.
A useful way to read this is as a spectrum rather than a binary. A system is more agentic the more it chooses its own steps, the longer it runs without a human turn, and the more consequential the actions it can take. A scripted form-filler sits at one end, a long-horizon coding agent at the other, and most shipped products sit somewhere in between.
Capability claims deserve the same skepticism. The GAO cites a study finding the best performing AI agent tested could autonomously complete only about 30 percent of software development tasks, and notes that many existing AI evaluation methods are unsuitable for agents because they ignore how agents interact with other systems.
What does an AI agent need from a content system?
An AI agent needs a content system that answers precisely on demand, because every iteration of the loop is a fresh request and the context window has no room for a whole site. This is where Sanity, the Content Operating System for the AI era, fits into an agent architecture: it is not an agent framework that runs loops for you, it is the governed source an agent retrieves from.
Sanity Context exposes content to agents through Context MCP, a hosted read-only endpoint an agent loop connects to. It supports two retrieval modes. GROQ mode queries the dataset at request time and is the right choice when content is structured and the schema tells the agent where to look, so a request like "size L latex gloves, under $200 a pallet" becomes an exact filter over product documents with no index to keep in sync (it requires a deployed schema, using sanity schema deploy on Studio v5.1.0 or later). Knowledge Base mode, currently in beta and opt-in, serves a pre-built index over chosen sources with citations back to the original, for cases where locating the answer is the hard part.
Structure does more of the retrieval work than vector search does. A related detail makes the point sharply: semantic similarity in GROQ is only valid inside a score() function, because
Discover More with Sanity
Now that you've learned about AI agent, why not start exploring what Sanity has to offer? Dive into our platform and see how it can support your content needs.
Last updated: