The ReAct Loop
ReAct (Reason + Act) is an agent execution pattern that interleaves reasoning and action, composed of "reason → act → observe → repeat".
- Reason: the model reasons about the next step from the current context, decomposing the task into subtasks where needed.
- Act: it issues a concrete tool call, such as fetching data, running code, or calling an API.
- Observe: the tool returns a result, which is added to the context for the model to read.
- Repeat: the model reads the updated context and reasons again; the loop continues until the task is complete or a step limit is reached.
Its key property is that the model can adjust its plan based on real feedback rather than executing a fixed script.
Single-Agent vs Multi-Agent
A large language model has a finite context window. When a single agent handles everything, the context fills up quickly, reasoning quality degrades, and a failure at any step can derail the whole task.
A multi-agent architecture splits work across roles: each worker holds a relatively clean context, failures are localized, and some subtasks can run in parallel. The cost is the added complexity of orchestration and communication.
| Dimension | Single-Agent | Multi-Agent |
|---|---|---|
| Context | All tasks share one context and fill it quickly | Each worker has an independent, cleaner context |
| Failure | A single point of failure affects the whole | Failures are locally isolated |
| Parallelism | Hard to parallelize | Subtasks can run in parallel |
| Complexity | Simple to implement | Requires orchestration and communication |
Inter-Agent Communication
Results between agents are typically passed in one of two ways:
- Shared memory: agents read and write a common shared state. Simple to implement, but it scales poorly in distributed settings and the origin of state is hard to trace.
- Message passing: workers return results explicitly to an orchestrator. The path is clearer and easier to trace, and it suits distributed systems better.
Where traceability and cross-node scaling matter, message passing is often preferred.
Context and Memory Management
Long Tool Outputs
When a tool returns a large amount of content, a common approach is to store the full result outside the context and keep only a reference token in the conversation, retrieving it by reference when needed. This controls context size without losing the data.
Memory Compaction
When the context approaches a token limit, older history can be summarized and less important observations dropped. The difficulty is deciding what is safe to discard — removing something needed later can cause the agent to fail silently, without an error.
Skill Discovery
Rather than loading all tools into the prompt at once, skills can register themselves and the agent queries for the capabilities it needs at runtime. This reduces token waste and keeps the context clean, mechanically similar to service discovery in backend systems.
Tool-Call Reliability
Common ways to improve the reliability of tool calls include:
- Validating the model's output before execution, confirming the arguments are valid before running.
- Writing clear tool descriptions. An ambiguous schema makes the model more likely to guess arguments wrong.
- Providing a few examples (few-shot) in the prompt to align the model with the expected call format.
Observability and Debugging
Diagnosing failures in a multi-agent system depends on tracing across all agents, usually linked by a shared trace ID. Without tracing, it is hard to locate which worker failed and why. Observability therefore needs to be built in from the start rather than added afterward.
Non-Determinism and Evaluation
One of the main engineering challenges of agent systems is non-determinism: the same input can produce different behavior across runs, so testing by exact output matching does not work.
A more applicable approach is to build evaluations (evals) that measure performance by metrics such as task completion and failure patterns, rather than comparing output character by character.
Sources and Notes
- This article covers widely discussed general concepts in AI-agent engineering (ReAct, multi-agent design, memory management, evaluation).
- Specific frameworks, APIs, and best practices evolve quickly; implementation should follow the latest official documentation of the relevant projects.
- This article contains no implementation details from any specific project, company, or individual.