DEV Community

Cover image for The anatomy of an AI agent: model, loop, tools, memory
Tyler Edwards
Tyler Edwards

Posted on Originally published at overmindlab.ai

The anatomy of an AI agent: model, loop, tools, memory

An AI agent is a language model wrapped in a loop that plans, calls tools and iterates toward a goal across many steps. Five components make one up. A model that picks the next action, a harness that runs the loop, tools that reach outside the model, memory that carries state, and a trajectory, the record of the whole run.

Originally published at overmindlab.ai.

An agent has a model, loop, tools and memory.

In 2024, most AI products were chatbots. A single LLM inference call, one prompt in, one completion out. In 2026, the default architecture is an AI agent, an agentic system that plans, calls tools, and iterates toward a goal across many steps.

Chatbot (the 2024 default) AI agent (the 2026 default)
Model calls per task One Many
Shape One prompt in, one completion out Plans, acts, observes, repeats
Tools None APIs, databases, code execution
Execution path A single step Varies run to run, non-deterministic
What you get back The first model response An outcome, plus a trajectory

Instead of returning the first model response, teams wrap the LLM in an agent harness, expose tool calling (APIs, databases, code execution), and let the system work toward an objective. Frameworks such as LangChain, Agno, CrewAI, and the OpenAI Agents SDK exist to make it easier to build the harness.

This article decomposes an AI agent into its core components. We define each part of the AI harness and walk through one complete agent run. Worth stating where we sit. Overmind is the model training platform for AI teams, and the trajectory, component five below, is the raw material it works from.

What are the five components of an AI agent?

Strip an agentic system down and you get five components. Four you assemble and the fifth is what they produce.

  • Model. Selects the next action given goal and state.
  • Harness. Runs the loop of reason, act, observe, repeat.
  • Tools. How the agent interacts with external systems.
  • Memory. How the agent persists and retrieves state.
  • Trajectory. The record of one complete agent run.
Component What it does Assembled or produced How you change it
Model Selects the next action given goal and state Assembled Swap it, or train and fine-tune it
Harness Runs the loop of reason, act, observe, repeat Assembled Rewrite prompts, context rules and stop conditions
Tools How the agent interacts with external systems Assembled Add, remove or redescribe tools
Memory How the agent persists and retrieves state Assembled Change what stays in the context window, change retrieval
Trajectory The record of one complete agent run Produced by the other four Not directly. It changes when the other four change

What is the model in an AI agent?

The language model is the only component that reasons, and the only one you can train or fine-tune. Conditioned on the goal and the observations so far, it chooses the next action. Most teams start on a frontier model API and some migrate to an open-weights model they host themselves or run through a third-party provider.

More on that trade-off in open-weights LLMs vs frontier APIs.

What is an agent harness?

The harness assembles what the model sees, reads the action it picks, calls the matching tool, and feeds the result back in. It also decides everything the model does not. Which tools exist and how they are described, what stays in the context window, what happens when a tool call fails or comes back malformed, and when to stop, whether that is the goal being met, a step limit, or an error.

This is what agent frameworks give you. It is the part of an agent you can change immediately.

What is tool calling?

Tools are how the agent reaches outside the model, whether that is querying a database, calling an HTTP API, running code, or sending an email. OpenAI shipped function calling in June 2023, letting the model emit a structured request to invoke a function instead of prose. Anthropic open-sourced the Model Context Protocol (MCP) in November 2024 to standardise how agents connect to those tools, and now everything is an MCP server.

What is agent memory?

Memory is how the agent carries state across loop iterations. Short-term memory is the context window, the running transcript of the goal, prior steps, and tool outputs. Longer-term memory is retrieval, pulling documents or past runs from outside the window (often via RAG or a vector store). Without memory, the agent loses its way.

What is an agent trajectory?

The trajectory, also called the agent trace, is the full ordered record of a single run. The goal, every LLM call, every tool invocation, every observation, and the final outcome. It is the agent's stack trace. You do not build it; the other four components produce it. It is also the only unit of analysis at which you can honestly say whether the agent succeeded. Capture it.

One agent run, start to finish

Watch a support agent handle a refund. The user goal enters, the agentic loop runs, an outcome exits.

  • The user goal arrives. Refund this customer.
  • The model calls get_order(id); the tool returns the order details.
  • The model checks the order against the refund policy.
  • The model calls issue_refund(amount); the tool returns a confirmation.
  • The model reports back. Refund done.

Four model calls, two tool calls, one outcome. That entire sequence is the agent trajectory. Change the goal, the tool responses, or the model's sampling behaviour and the next run takes a different path. Agents are non-deterministic. The same prompt does not guarantee the same execution path.

What does each layer of the AI stack actually control?

Each layer of a typical AI stack controls an aspect of the agent. Almost none control the whole run.

Layer What it sees Can it update the model?
LLM gateway One request and response at a time No
Agent observability The full trace, after the fact No
Agent evals A score for the run No
Closed training loop Judged trajectories fed back into training Yes

Three of the four tell you what happened. Only the last one changes what happens next time. More on that gap in so, you have observability. Now what?.

How do you improve an AI agent?

Improving an AI agent means operating at the level of the trajectory, not the individual LLM call. Capture the full run, judge it against your definition of success, and feed judged trajectories back into the system.

There are two distinct ways to improve an agent.

  • Improve the harness. Rewrite prompts, tighten tool definitions, change the context rules and stop conditions.
  • Improve the model. Retrain it on the failure modes in the traces, then benchmark the result against the model you serve today.

This is the loop Overmind is built to close.

FAQ: agents, harnesses and trajectories

What is the difference between an AI agent and a chatbot?

A chatbot is one model call. One prompt in, one completion out. An agent runs many model calls inside a loop, calls tools between them, and keeps going until the goal is met or it stops. The comparison table above sets the two side by side.

Is an AI agent the same thing as a workflow?

No. In a workflow, you decide the order of steps in advance. In an agent, the model decides the next action at each turn given the goal and what it has observed so far. That is why two runs of the same agent can take different paths and a workflow cannot.

Why are AI agents non-deterministic?

Because the model chooses each action, and its sampling behaviour, the goal, and the tool responses all vary. Change any of them and the next run takes a different path. This is why a single run tells you very little and the trajectory is the unit you have to judge.

Do I need an agent framework to build an AI agent?

No. Frameworks such as LangChain, Agno, CrewAI, and the OpenAI Agents SDK exist to make the harness easier to build, not to make it possible. The loop is reason, act, observe, repeat, and plenty of teams write their own.

Which part of an agent should you change first when it fails?

Start with the harness, because it is the part you can change immediately. Prompts, tool descriptions, context rules, stop conditions. Go to the model when the same failure keeps showing up across trajectories after the harness is clean.

Overmind is the model training platform for AI teams. It turns your production traces into specialised models you own. Get started.

Top comments (0)