Agent Primer

A modern Agent fits one formula — Agent = LLM + Context + Tools, or more intuitively, reasoning engine + working context + action interfaces. Add time to the three — the engine reasons, the interfaces act, the context observes — and you get the ReAct loop of reason → act → observe, repeated until the task is done.

The essence of a modern Agent system fits into one concise formula: Agent = LLM (Large Language Model) + Context + Tools. The formula is simple and practical, provided each term is read broadly:

  • The LLM is the Agent’s reasoning engine. It is more than a set of model parameters; it is the decision-making core — understanding intent, reasoning, planning, judging. Like a human brain, its ability comes from two parts: world knowledge and language acquired in pre-training, and decision strategies fixed in post-training.
  • Context is the Agent’s working set of information. Not just the text fed into the model, but everything the Agent can see at each decision point — the environment, user memory, domain knowledge, its own state, and task progress. The context window is everything it can look at right now.
  • Tools are the Agent’s action interfaces. Not a handful of callable API functions, but the full set of things the Agent can do — from predefined tool calls to Skills loaded on demand, from generating code to create new capabilities to delegating to sub-agents, from reaching out to the user to responding to external events.

Put more intuitively: Agent = reasoning engine + working context + action interfaces. The engine reasons and decides, the context provides the information those decisions depend on, and the tools turn decisions into changes in the outside world.

Mapping to Reinforcement Learning

These three components correspond exactly to three core concepts in reinforcement learning (RL). The table below is optional — if you have no RL background, skip it; nothing later depends on it. It only helps readers who do know RL map that knowledge onto this terminology:

IntuitionComponentRL Concept (optional)Meaning
Reasoning engineLLMPolicyThe logic that decides “what to do next” — given what it currently sees, pick the most appropriate action from all options
Working contextContextObservation spaceEverything the Agent can see — what it observes, reads, remembers, and which systems it can reach
Action interfacesToolsAction spaceThe full set of things the Agent can do — from sending messages to executing code to controlling interfaces

Understanding what each component does, and how they fit together, is the foundation for building effective Agent systems.

The ReAct Loop

With the three components in hand, a natural question follows: how do they work together? The core pattern by which an Agent executes a task is called ReAct (Reasoning + Acting). The name mentions only reasoning and acting, but the actual loop has three stages: the model first reasons about what to do next, then calls a tool to act, then observes the tool’s result and reasons about the next step. This “reason → act → observe” loop repeats until the task is done.

The clearest way to see it is through the Agent’s trajectory — the message history that accumulates as it works: user messages, assistant messages (with their reasoning and tool calls), and tool results. On every LLM call, the complete context the model receives is the static prefix (system prompt + tool definitions) plus the trajectory (dynamic message history). This reveals a key fact: Agent context = static prefix + trajectory. From that complete context the LLM generates its next response, which is then appended to the trajectory for the following call.

The elegance of this design is the cumulative nature of context. Every LLM call sees the full trajectory, so it can tell where it is in the task, what it already tried, and what came back. But accumulation is one-directional: the trajectory only grows, and sooner or later it overflows the window — or degrades retrieval precision before it ever fills up. That is the seed of compaction.

Three Deviations from the Clean Loop

The “reason → act → observe” above is clean ReAct, enough to build a mental model, but real systems are not always this tidy. Implementations deviate in three common places, each corresponding to a class of engineering decision.

1. Observations do not only come from actions. Some observations are not pulled by one of the Agent’s tool calls but pushed into the loop from outside: the user adds a message mid-task, an external event arrives, a sub-agent reports back. They have no corresponding action and need an entry point independent of tool calls. See Event-Driven Asynchronous Agents.

2. Actions and observations are not one-to-one. ReAct’s paper assumes each action returns exactly one observation; reality differs. Some actions change external state but return almost nothing (sending an email yields only an ack); some keep returning observations over time (running a long task or subscribing to a data stream).

3. One class of action targets the context itself. Todo lists, memory writes, compaction, and loading Skills on demand do not change the external world — they rewrite what the Agent will see on its next turn. In other words, the Agent does not just passively receive context; it actively manages its own working set. How to write, organize, and — as it grows — trim that context is itself an engineering discipline: the subject of context engineering.

Was this page helpful?