Skip to content

How Agents Work

From a model response to actions, observations, feedback and bounded execution.

Updated View as Markdown

A model does not perform an action merely by describing it. If it proposes a search, some software must execute the search and return the result. If that result changes what the model does next, we have the beginning of an agent loop. For the model itself, see Transformer foundations.

The central idea is closed feedback: decisions affect an environment, and observations from that environment affect later decisions. ReAct made this relationship explicit by interleaving language reasoning with external actions.1

A fixed workflow follows a path encoded in advance. An agent delegates more path selection to the model. Useful systems can combine both.2 The harness is the software that assembles context, routes actions, records progress and enforces the work loop’s stopping rules. The execution environment is where the tools act.3

A concrete example

Consider an illustrative document investigation: “Do these invoices contain duplicate charges?” A single response might explain a procedure. A fixed workflow might extract every invoice and compare predetermined fields. An agent might notice inconsistent currency labels, choose an additional inspection tool and revise its comparison.

The model chooses within the options exposed by the application. It does not gain a filesystem, a database connection or payment authority simply because it can generate the relevant words. Tool execution and access are runtime responsibilities.3

Figure 1 separates the decision from execution and its feedback.

The next decision depends on observed work
  1. Assemble contextGoal, relevant evidence, instructions and current state.
  2. ChooseThe model proposes an action or an answer.
  3. Execute within scopeThe runtime checks authority and runs the allowed operation.
  4. Observe and verifyRecord results, check completion, then continue or stop.

A denied action produces a denial observation. It does not produce the requested change.

Figure 1. Latent Light synthesis of feedback and harness/environment responsibilities.13

Make the loop precise

A formal view of context, action and observation

The following is a teaching formulation, not an equation reproduced from ReAct. It separates the model’s decision from context assembly and execution:

ct=C(g,ht,st)at∼πθ(⋅∣ct)(ot+1,st+1)=E(at,st)(1)\begin{aligned} c_t &= C(g,h_t,s_t) \\ a_t &\sim \pi_\theta(\cdot\mid c_t) \\ (o_{t+1},s_{t+1}) &= E(a_t,s_t) \end{aligned} \tag{1}

Here gg is the goal, hth_t the recorded interaction history and sts_t relevant environment state. CC assembles the context; πθ\pi_\theta is the model’s decision policy; ata_t is a proposed action; and EE executes it and returns an observation ot+1o_{t+1}. This abstraction combines the feedback idea with the documented separation of harness and environment.13

In a real implementation, the harness must check authority before applying EE. A rejected action produces a denial observation, not the requested change. The next step may be a different allowed action, a request for direction or termination.

The distinction matters when diagnosing failure. Was the model wrong, was important evidence missing from context, was a tool ambiguous, or was the environment unavailable? These are different interventions.

Four foundational ideas

Work Contribution Important boundary
ReAct Interleave reasoning and action with observations.1 A prompting and interaction pattern, not a complete runtime
Toolformer Train a model to select API calls and incorporate results.4 Learned tool use does not establish authorization
Reflexion Carry linguistic feedback into later trials through episodic memory.5 The method does not update model weights
MemGPT Move information between limited active context and external memory.6 External storage is not automatically available to each model call

These are complementary ideas, not stages that every system must implement. A useful agent need not have an explicit planner or reflection module.

Planning is a control choice

A plan can live in the model’s current context, an explicit checklist or a code-defined workflow. The important question is what happens when evidence contradicts it. A checklist helps only if the system can revise it and verify its completed steps. More elaborate control patterns belong in Orchestration.

One useful engineering rule is to keep deterministic work deterministic. Parsing an exact identifier, applying a known validation rule or adding numbers usually does not require another model decision. Reserve flexible control for uncertainty that the task actually contains.

Adaptation is not necessarily training

An agent can improve its next attempt because it receives an error message, retrieves a relevant procedure or remembers earlier feedback. That changes its input, not necessarily its parameters. Reflexion is a concrete example of adaptation through recorded feedback without weight updates.5

Model training is a separate intervention. Toolformer changes the model through training; adding a skill file does not do that. Do not infer that a product trains on every session merely because it can resume or remember it.

The smallest useful implementation

As a proposed starting design, use a loop that assembles relevant context, accepts structured actions, validates them, executes allowed actions, records observations and checks completion. Set explicit budgets for time, calls and cost. Stop when the task is verified, the budget ends or further work needs new authority.

This is an architectural checklist, not a claim that one short loop guarantees reliability. The next pages explain its most consequential parts: tools and skills, persistent state and evaluation.

To see these ideas in a specific implementation, explore the Agent Deep Dives comparison and its five studies.

References

  1. Shunyu Yao et al. ReAct: Synergizing Reasoning and Acting in Language Models, ICLR 2023. ↩ ↩2 ↩3 ↩4

  2. Anthropic. Building effective agents, 2024; workflow and agent distinction. ↩

  3. OpenAI. Agents API architecture, harness, environment and application server. Checked October 10, 2026. ↩ ↩2 ↩3 ↩4

  4. Timo Schick et al. Toolformer: Language Models Can Teach Themselves to Use Tools, 2023. ↩

  5. Noah Shinn et al. Reflexion: Language Agents with Verbal Reinforcement Learning, 2023. ↩ ↩2

  6. Charles Packer et al. MemGPT: Towards LLMs as Operating Systems, 2024 revision. ↩

Navigation

Type to search…

↑↓ navigate↵ selectEsc close