What Is an AI Agent? Anatomy and Goals
Open up an agent and look at each part: what it does, how it fails, and who is responsible for it.
An AI agent is a software system that pursues a goal by choosing and taking actions. It is built from a model, instructions, tools, state and a runtime that connects them and enforces limits. How well it works depends as much on the goal you give it as on the parts.
What you will learn: a precise definition, the job of each component, how one request travels through them, how to separate intent, goals, tasks and success criteria, and how to review an agent design.
Prerequisites: What Is Agentic AI? is a helpful start. Basic Python for the one code example.
What counts as an agent?
In the broadest classical sense, an agent is anything that observes an environment and acts on it. That definition is old and covers robots, game players and simple control programs. In current practice, "AI agent" usually means something narrower: a system in which a language model decides what to do next, uses tools to do it, and reads the results before deciding again.
Three properties are worth testing for:
- It has an objective that outlasts a single message.
- It chooses actions instead of following one fixed path.
- It receives feedback from its actions and can change course.
A model on its own has none of these. It takes text in and produces text out. Everything else is built around it. That is why people sometimes say an agent is "a model plus a harness", where the harness is the surrounding program.
- Coding assistant: reads files, edits them, runs tests, and fixes what fails.
- Support assistant: looks up an account, checks policy, proposes or performs a remedy, and hands over when unsure.
- Research assistant: plans searches, reads sources, notes evidence and writes a cited summary.
- Operations assistant: gathers logs and metrics after an alert, suggests a cause and prepares a fix for approval.
The anatomy at a glance
| Part | Answers the question | Typical failure |
|---|---|---|
| Instructions | What am I here to do, and within which rules? | Vague or contradictory guidance |
| Model | What should happen next? | Plausible but wrong decisions |
| Runtime | Is this allowed, and should we continue? | No limits, so mistakes repeat |
| State and memory | What do we already know? | Lost, stale or mixed-up information |
| Tools | How can I find out or change something? | Unclear descriptions, unsafe permissions |
The model
The model is the part that interprets language, weighs options and writes. It receives one input, called the context, and returns text or a structured request to use a tool. It does not remember earlier calls by itself. If it appears to remember, the runtime sent that information again.
Choose a model for the task, not for its reputation. Consider how well it selects tools, follows instructions over long runs, produces valid structured output, and what it costs and how fast it responds. Large systems often use a capable model for planning and a smaller one for routine steps. See Choosing Models: Reasoning, Open-Weight and Hosted and How LLMs Power Agents: Transformers, Tokens and Sampling.
The instructions
Instructions tell the model who it is acting as, what it is trying to achieve, which rules apply and what the output should look like. They usually live in a system prompt, joined by tool descriptions and, for each task, the user's request.
Useful instructions are specific where mistakes are costly and open where judgment is wanted. "Ask before sending anything outside the company" is testable. "Be careful" is not. Agent System Prompts and Instruction Hierarchy gives a structure you can reuse.
A model can misread an instruction, and text from a document or web page may try to override it. Anything that must never happen needs a control in code or in the system being called, such as a missing permission.
The tools
A tool is a function the model can ask for: search a knowledge base, run a query, create a ticket, edit a file. Each has a name, a description, an input schema and an implementation that you control. Tools fall into rough risk groups:
| Group | Examples | Sensible default |
|---|---|---|
| Read public information | Search product documentation | Allow, log |
| Read private information | Look up a customer record | Allow only for the signed-in user's scope |
| Make reversible changes | Save a draft, add a label | Allow with limits and undo |
| Make consequential changes | Pay, delete, publish, send | Require approval |
Design guidance is in Agent Tools, Function Calling and Tool Registries and permission models in Tool Permissions, Approvals and Abuse Risks.
State and memory
State is what describes the current run: the goal, the steps taken, tool results, the plan and any pending approval. Memory is information kept so that it can be used later, including in other sessions, such as a user's preferred format.
Keep the two apart. State must be exact, because the runtime depends on it. Memory is a store of claims that may be outdated or wrong, so it needs a source, a date and a way to correct it. Agent Memory Types and Persistence covers the types.
The runtime
The runtime is the ordinary program that does the work around the model:
- assembles the context for each call;
- validates what the model asks for;
- checks identity and permissions;
- runs tools with timeouts and retries;
- saves state, so that a long run can resume;
- pauses for approval;
- counts steps, time and money, and stops the run;
- records a trace that a person can read.
It can be sixty lines of your own code or a framework with durable storage. Either way, this is where reliability is decided. You can build a small one in Build Your First AI Agent and Multi-Agent App.
Follow one request through the agent
A user writes: "I cannot attend on Tuesday any more."
Notice what the sentence does not say. It does not name the meeting, ask for it to be moved, or say who should be told. An agent has to work those out, and the right move is often a short question: "Do you want me to move Tuesday's review, or only tell the others you will be absent?"
Intent, goal, task and success criteria
| Term | Meaning | In the example |
|---|---|---|
| Intent | What the person wants, often unstated | The review should still happen, with them in it |
| Goal | The outcome the agent is asked to reach | Move the review to a slot everyone can make |
| Task | A piece of work toward the goal | Read calendars; pick a slot; move; notify |
| Constraint | A boundary that must hold | Do not cancel; stay within working hours |
| Success criterion | A test of whether the goal is met | New day is not Tuesday; all are free; all were told |
Most disappointing agent behavior starts in the gap between the first two rows. A system that books a new slot at 7 a.m. met a goal and missed the intent. Close the gap by writing constraints for the things people assume, and by allowing the agent to ask when two readings lead to different actions.
Writing criteria that can be checked
- Look at the world, not the wording. "The ticket status is closed" beats "the agent says it closed the ticket".
- Cover what must not happen. A run that reaches the goal by deleting something else is a failure.
- Include a budget. Success in 200 steps may not be success.
- Allow honest stopping. "No suitable slot exists; here are two options" should count as a good result.
Criteria as code
You can express a task as data and checks. The same object then guides the agent, tests it and monitors it.
from dataclasses import dataclass, field
from typing import Callable
@dataclass
class TaskSpec:
intent: str # what the person wants
goal: str # the outcome to reach
checks: dict[str, Callable[[dict], bool]] # success criteria
forbidden: list[str] = field(default_factory=list)
max_steps: int = 8
def evaluate(self, world: dict, actions: list[str]) -> list[str]:
"""Return the list of failures. An empty list means success."""
failures = [name for name, check in self.checks.items() if not check(world)]
failures += [f"forbidden action used: {a}" for a in actions if a in self.forbidden]
if len(actions) > self.max_steps:
failures.append("too many steps")
return failures
spec = TaskSpec(
intent="I cannot attend on Tuesday any more",
goal="Move the review meeting to a slot every attendee can make",
checks={
"meeting moved off Tuesday": lambda w: w["day"] != "Tuesday",
"all attendees free": lambda w: set(w["attendees"]) <= set(w["free"][w["day"]]),
"attendees informed": lambda w: w["notified"],
},
forbidden=["cancel_meeting"],
)
world = {"day": "Thursday", "attendees": ["ana", "ben"],
"free": {"Thursday": ["ana", "ben", "cai"]}, "notified": False}
print(spec.evaluate(world, ["read_calendars", "move_meeting"]))
world["notified"] = True
print(spec.evaluate(world, ["read_calendars", "move_meeting", "send_notice"]))
Output:
['attendees informed']
[]
The first run fails because nobody was informed, even though the meeting moved. A reviewer reading only the agent's cheerful final message might have missed that.
Ask a colleague to read your success criteria and describe a run that passes them but would still annoy the user. Each answer is a missing criterion or constraint.
Minimal and full versions of each part
You do not need every capability on day one. Add each when the need appears.
| Part | First prototype | Dependable service |
|---|---|---|
| Instructions | A paragraph | Versioned, reviewed, tested against cases |
| Model | One model | Routing, fallback and pinned versions |
| Tools | Two read-only functions | Scoped permissions, idempotency, audit records |
| State | A list in memory | Stored after each step, resumable |
| Runtime | A loop with a step limit | Budgets, approvals, retries, tracing |
| Evaluation | Trying it by hand | A test set run on every change |
Where does the agent end?
Draw the boundary explicitly, because security, ownership and testing follow it. A practical rule is that everything inside the boundary is code and configuration your team versions and releases together, and everything outside is reached through a tool or a person. Text arriving from outside is data to be judged, even when it is phrased as a command.
Two boundary questions are often missed:
- Whose authority does the agent use? Acting with the user's own permissions limits damage to what the user could do. A shared service account with broad access removes that limit. See Agent Identity, Authorization and Secrets.
- Who owns the outcome? Name a person or team who answers for the agent's actions, reviews its failures and can switch it off.
A one-page agent design record
Before building something that matters, fill in a short record and keep it with the code.
Agent: Meeting rescheduler
Owner: Workplace tools team
Users: Staff, for their own meetings
Goal: Move a meeting to a slot all required attendees can make
Out of scope: Canceling meetings, booking travel
Model: Chosen by evaluation; version pinned
Tools: read_calendars (read), move_meeting (write, undoable),
send_notice (external effect, preview to user first)
State: Saved per request, deleted after the retention period
Limits: 8 steps, 60 seconds, 1 meeting per run
Approval: Required before send_notice
Success checks: See task specification
Stop and ask: More than one meeting matches, or no common slot
Off switch: Feature flag held by the owner
Design trade-offs between the parts
Responsibilities can move between components, and moving them is the main design tool you have.
| If you move work from | To | You gain | You give up |
|---|---|---|---|
| Model | Runtime code | Predictability, low cost, testability | Flexibility for unusual cases |
| Instructions | Tool design | Mistakes become impossible, not just discouraged | More engineering |
| Context | Memory or retrieval | Smaller, sharper inputs | Risk of failing to fetch what matters |
| One agent | Several agents | Separate contexts and permissions | Coordination errors and cost |
Reference designs that combine these choices are in Single-Agent, Router and Retrieval Patterns and Enterprise Agent and Platform Reference Architectures.
When a failure is reported, assign it to a component before fixing it. "The model was wrong" is rarely the whole story. Often the context lacked a fact, a tool returned an unclear error, or the runtime allowed a step it should have blocked. Counting failures by component shows where to invest.
Design review checklist
- The goal, constraints and success checks are written and testable.
- The agent can ask a question, report failure and hand over.
- Each tool has an owner, a risk group and a permission scope.
- State is separate from long-term memory.
- Limits and approvals are enforced by the runtime.
- Any run can be reconstructed from its trace.
- A named person can disable the agent quickly.
Frequently asked questions
Is a chatbot an AI agent?
Not if it only replies to messages. A chat interface can sit on top of an agent, though, so judge by what happens behind it: whether the system chooses and takes actions toward a goal.
Does an agent need long-term memory?
No. Many useful agents keep only the state of the current run. Add memory when a later task clearly benefits from something learned earlier.
Is the model the most important part?
It matters, but a strong model with unclear tools and no limits is still unreliable. Improving tools, context and checks often helps as much as changing models.
Who is responsible when an agent makes a mistake?
The people and organization that deploy it. Legal duties vary by place and use, so involve your legal and risk teams for consequential uses.
References and further reading
- Building effective agents (Anthropic engineering)
- Agents in the OpenAI Agents SDK (official documentation)
- LangGraph graph API: state, nodes and edges (official documentation)
- NIST AI Risk Management Framework
Next steps
The Agent Loop: Observe, Reason, Plan, Act, Reflect
See how the parts work together over time.
Types of AI Agents
Compare reactive, deliberative and other designs.
Autonomy Levels and Human Oversight
Decide how much the agent may do alone.