Agent architectures: who gets control between observation and action?
智能体架构
Compare open-loop planning, constant replanning, layered reaction and monitored replanning on the same grid, and trace each failure to an architectural choice.
agent-architecturesThe same robot, four ways to wire it
A delivery robot has a map, a planner, distance sensors and wheels. Halfway along its route a cart is left in the corridor. Whether the robot stops, drives into the cart, wanders in circles or quietly works out a detour is decided less by any single component than by how the components are connected: which part reads which observation, when the plan is recomputed, and which output reaches the wheels when two parts disagree.
That wiring is what we call an agent architecture. The earlier article on intelligent agents defined an agent as a mapping from percept histories to actions. This article asks the next question: given a fixed set of parts, how should control flow between them? The answer matters for language-model agents too. A system that calls a search engine, a calculator and a large model still has to decide which part speaks next and which result is allowed to change the world.
We compare four controllers on one original grid simulation: a planner that plans once and then executes blindly, a planner that replans after every step, a two-behavior reactive controller without any map, and a planner that keeps a cheap safety check running and replans only when that check fires. Nothing here is a real robot or a learned model. The point is to see failures you can predict from the wiring diagram alone.
Decompose by function or by behavior
Any of these controllers can be written in the same outer form. At time t the agent has seen observations and taken actions, and chooses the next action from that context:
This notation follows the general setup stated at the start of the ReAct paper’s method section, which writes the policy as a distribution π(a_t | c_t); our controllers are deterministic, so we write it as a function. Agent context It hides almost everything interesting. An architecture specifies how π is built: what summary of c_t is kept, which module computes what, and how often each runs.
Functional decomposition. Brooks’s 1985 MIT memo draws the traditional design as vertical slices that information passes through in order: perception, modelling, planning, task execution and motor control. Every slice must exist before the robot can move at all, and improving one slice tends to force interface changes in its neighbors. Figure 1 and Section 2.1
Behavioral decomposition. The memo’s alternative slices the problem by desired external behavior. Levels of competence run from avoiding contact with objects (level 0), through wandering (1) and exploring (2), up to building maps and planning routes (3) and beyond. Each level is built as a control layer on top of a working lower system. A higher layer may read data from the lower layer and inject replacement data into its internal connections, suppressing the normal flow, while the lower layer keeps running without knowing about the layer above. The memo names this a subsumption architecture. Section 2.2 and Figure 3
The memo motivates the design with four requirements: multiple, sometimes conflicting goals; multiple noisy sensors; robustness when parts fail; and additivity as capabilities grow. It also describes modules as small asynchronous finite-state machines that exchange messages over wires with no handshaking and no shared global memory, and it notes that messages can be lost. Sections 1.1 and 2.3 These are design claims and engineering descriptions from 1985, not measured guarantees; we use them to name the trade-offs.
A useful abstraction of layered control is an arbitration rule. Suppose layer k either proposes an action or stays silent, and the highest proposing layer wins:
This rule is our own simplification, not a formula from the memo: Brooks’s suppression acts on internal wires rather than a single final vote. Its useful property survives: if the lowest layer always proposes something, the agent never lacks an action even when everything above it is silent or broken.
Routing between modules. Language-model systems revive the same question with different parts. The MRKL proposal from AI21 Labs describes an extendable set of modules, called experts, which may be neural (a general language model, smaller specialized models) or symbolic (a calculator, a currency converter, a database API). A router sends each input to the module best placed to answer; that module’s output can be the final answer or be routed onward. Section 1 Its listed benefits include falling back to the general model when no expert matches and adding experts without retraining existing ones. The paper presents those as properties of the design; it does not give a proof that the router will choose correctly, and it identifies argument extraction for symbolic modules as the costly part. Sections 1 and 3
Where the plan lives. A deliberative controller stores a plan computed from a model of the world. The plan is only as current as the model. If the world changes after planning, executing the stored plan open-loop is a bet that nothing relevant moved. Two repairs are common: recompute the plan every step, or keep executing the stored plan while a cheap monitor checks its next step. Writing E for the number of nodes a planner expands, the planning work over an episode of T steps is
where the monitored controller plans at the start and at R later trigger times. If triggers are rare, the second sum has far fewer terms. The price is that the monitor must detect every situation that invalidates the plan. A monitor that only looks one cell ahead cannot notice that a distant door has closed.
One grid, four controllers
The simulation uses two hand-drawn maps. The open map is a five-by-seven room; the start is in one corner and the goal in the opposite one. The pocket map has a U-shaped wall whose open side faces the start, with the goal behind it. In each episode one obstacle appears at a random free cell at a random time between steps 1 and 4. The obstacle cell is chosen at Manhattan distance greater than four from the start, so it can never appear on top of the robot. Moves are north, south, east, west; entering a wall or obstacle is a collision and ends the episode; forty steps without reaching the goal is a timeout.
The four controllers are:
- plan-once: breadth-first search on the initial map, then execute the move list without sensing. This is the pure functional pipeline run a single time.
- replan-every-step: sense the four neighboring cells, add any blocked one to the believed map, run breadth-first search, take the first move, repeat.
- reactive: no map and no search. The goal-seeking behavior proposes the move that reduces the column difference first, then the row difference. If that cell is blocked, an avoidance behavior overrides it with the first free move in the order north, south, east, west.
- monitor-replan: keep a stored plan; sense neighbors each step; replan only when the next planned cell is known to be blocked.
The reactive controller is a two-behavior priority scheme in the spirit of behavioral decomposition. It is not a reimplementation of Brooks’s layers, which had many more modules and asynchronous messaging. Each controller runs on the same 200 seeds per map; the code uses only the Python standard library and finishes in well under a second.
"""Original grid simulation of four control architectures; no model, robot or network."""
import json
import random
from collections import deque
MAPS = {
'open': ['#########',
'#S......#',
'#.......#',
'#.......#',
'#.......#',
'#......G#',
'#########'],
'pocket': ['###########',
'#.........#',
'#..#####..#',
'#......#..#',
'#S.....#.G#',
'#......#..#',
'#..#####..#',
'#.........#',
'###########'],
}
MOVES = {'N': (-1, 0), 'S': (1, 0), 'E': (0, 1), 'W': (0, -1)}
ORDER = 'NSEW'
LIMIT = 40
def parse(rows):
walls, start, goal = set(), None, None
for r, row in enumerate(rows):
for c, ch in enumerate(row):
if ch == '#':
walls.add((r, c))
elif ch == 'S':
start = (r, c)
elif ch == 'G':
goal = (r, c)
return walls, start, goal
def step(cell, move):
dr, dc = MOVES[move]
return (cell[0] + dr, cell[1] + dc)
def bfs(walls, start, goal):
"""Shortest move list on the believed map and the number of expanded cells."""
parent, queue, expanded = {start: None}, deque([start]), 0
while queue:
cell = queue.popleft()
expanded += 1
if cell == goal:
path = []
while parent[cell] is not None:
cell, move = parent[cell]
path.append(move)
return path[::-1], expanded
for move in ORDER:
nxt = step(cell, move)
if nxt not in walls and nxt not in parent:
parent[nxt] = (cell, move)
queue.append(nxt)
return None, expanded
def greedy_move(cell, goal):
dr, dc = goal[0] - cell[0], goal[1] - cell[1]
if dc:
return 'E' if dc > 0 else 'W'
return 'S' if dr > 0 else 'N'
def obstacle(name, seed):
walls, start, goal = parse(MAPS[name])
rng = random.Random(seed)
free = sorted({(r, c) for r in range(len(MAPS[name])) for c in range(len(MAPS[name][0]))}
- walls - {start, goal})
appear = rng.randint(1, 4)
# Farther than any cell reachable before the obstacle appears.
block = rng.choice([cell for cell in free if abs(cell[0] - start[0]) + abs(cell[1] - start[1]) > 4])
return appear, block
def run(arch, name, seed):
walls, start, goal = parse(MAPS[name])
appear, block = obstacle(name, seed)
belief, cell, plan, expansions, plans = set(walls), start, None, 0, 0
for t in range(LIMIT):
actual = walls | ({block} if t >= appear else set())
if cell == goal:
return dict(outcome='success', steps=t, expansions=expansions, plans=plans)
if arch == 'reactive':
move = greedy_move(cell, goal)
if step(cell, move) in actual:
move = next((m for m in ORDER if step(cell, m) not in actual), None)
else:
if arch != 'plan-once':
belief |= {step(cell, m) for m in ORDER if step(cell, m) in actual}
stale = plan is None or (arch == 'monitor-replan' and step(cell, plan[0]) in belief)
if arch == 'replan-every-step' or stale:
plan, cost = bfs(belief, cell, goal)
expansions += cost
plans += 1
if plan is None:
return dict(outcome='no-path', steps=t, expansions=expansions, plans=plans)
move = plan.pop(0)
if move is None:
return dict(outcome='stuck', steps=t, expansions=expansions, plans=plans)
nxt = step(cell, move)
if nxt in actual:
return dict(outcome='collision', steps=t, expansions=expansions, plans=plans)
cell = nxt
return dict(outcome='success' if cell == goal else 'timeout', steps=LIMIT,
expansions=expansions, plans=plans)
def summary(arch, name, seeds):
runs = [run(arch, name, seed) for seed in seeds]
counts = {}
for item in runs:
counts[item['outcome']] = counts.get(item['outcome'], 0) + 1
wins = [item for item in runs if item['outcome'] == 'success']
return dict(outcomes=dict(sorted(counts.items())),
mean_success_steps=round(sum(i['steps'] for i in wins) / len(wins), 3) if wins else None,
mean_expansions=round(sum(i['expansions'] for i in runs) / len(runs), 3),
mean_plans=round(sum(i['plans'] for i in runs) / len(runs), 3))
if __name__ == '__main__':
seeds = range(200)
archs = ['plan-once', 'replan-every-step', 'reactive', 'monitor-replan']
stuck_at = {}
for seed in seeds:
if run('reactive', 'open', seed)['outcome'] == 'timeout':
key = str(obstacle('open', seed)[1])
stuck_at[key] = stuck_at.get(key, 0) + 1
print(json.dumps({'synthetic': True, 'episodes_per_cell': len(seeds), 'step_limit': LIMIT,
'results': {name: {arch: summary(arch, name, seeds) for arch in archs}
for name in MAPS},
'open_reactive_timeout_obstacles': dict(sorted(stuck_at.items()))}, indent=1))
The program prints outcome counts, mean steps of successful episodes, mean planner node expansions and mean number of planner calls, plus the obstacle cell of every open-map episode in which the reactive controller timed out:
| Map | Controller | Success | Collision | Timeout | Steps when successful | Expansions | Planner calls |
|---|---|---|---|---|---|---|---|
| open | plan-once | 141 | 59 | 0 | 10.0 | 35.0 | 1.0 |
| open | replan-every-step | 200 | 0 | 0 | 10.59 | 250.985 | 10.59 |
| open | reactive | 169 | 0 | 31 | 10.0 | 0 | 0 |
| open | monitor-replan | 200 | 0 | 0 | 10.59 | 42.78 | 1.295 |
| plan-once | 138 | 62 | 0 | 14.0 | 50.0 | 1.0 | |
| replan-every-step | 200 | 0 | 0 | 16.37 | 485.885 | 16.37 | |
| reactive | 0 | 0 | 200 | — | 0 | 0 | |
| monitor-replan | 200 | 0 | 0 | 16.37 | 59.83 | 1.31 |
Each failure has a structural cause:
Plan-once collides whenever the obstacle lands on its stored path. On the open map, breadth-first search with the move order north, south, east, west returns four moves south followed by six moves east. Path cells at distance five through nine from the start are eligible obstacle locations, and the robot reaches cell k only at step k, after every possible appearance time. So the collision probability is the fraction of eligible cells on that stretch, 5/19 ≈ 0.263. The run observed 59/200 = 0.295; the gap is sampling variation over 200 seeds.
Reactive times out in two different ways. On the open map, all 31 timeouts have the obstacle in the goal’s column directly above the goal, at rows 2, 3 or 4 (9, 11 and 11 episodes; the program prints these counts under open_reactive_timeout_obstacles, with cells written as (row, column)). The robot runs east along the top row and turns south, or wants to, and the obstacle blocks that move. The avoidance rule picks the first free alternative, north or west depending on the cell, and on the next step the goal-seeking behavior reverses it. The robot oscillates between two cells until the limit. On the pocket map every episode times out regardless of the obstacle: the goal-seeking behavior drives east into the pocket, and near the closed end the two rules again undo each other’s moves. With no memory, the controller cannot tell that it has been there before.
Replan-every-step never fails here but does about six times the planning work of the monitored controller on the open map (250.985 versus 42.78 expansions) and about eight times on the pocket map (485.885 versus 59.83). Because both use the same deterministic search on the same belief, they follow identical routes; only the compute differs.
Monitor-replan makes 1.295 planner calls on average on the open map. That is exactly 1 + 59/200: it replans once in precisely the episodes where plan-once collided, since those are the episodes where the obstacle sits on the stored path. The same identity holds on the pocket map, 1 + 62/200 = 1.31.
What the toy hides
Sensing here is perfect and local; real range sensors are noisy, and Brooks’s memo stresses that readings can be inconsistent and sometimes outside a sensor’s domain of applicability. Section 1.1 A monitor that trusts a false “blocked” reading replans needlessly; one that misses a true obstacle collides. Our monitor is safe only because the toy guarantees that it sees every adjacent obstacle.
Planner cost is measured in node expansions, not wall-clock time, and the planner runs instantly. If planning took several steps of real time, replanning every step would also mean acting on stale plans, and a fast reactive layer would matter more. The simulation does not model that latency.
There is one obstacle per episode, appearing once, on small maps. Moving obstacles, many obstacles, partial maps and unreachable goals (the code reports “no-path” but it never occurs here) would all change the numbers. The counts above describe this simulation with these 200 seeds and should not be read as rates for any real robot or software agent.
The same caution applies to the language-model analogy. A router that sends questions to a calculator is architecturally similar to a planner choosing a subroutine, but the MRKL paper’s claimed benefits are not measured in this simulation, and nothing here tests whether a learned router picks the right module. Section 1
Predict the failure before running the code
-
Why does the reactive controller succeed on most open-map episodes but fail on every pocket-map episode, even though it has the same rules?
Answer: Its only state is the current cell. On the open map, a single obstacle usually leaves the greedy direction or an alternative open, so the robot makes progress. In the pocket, the greedy direction leads into a dead end, and at the closed end the avoidance rule picks a move that the goal-seeking rule immediately reverses. Without memory of visited cells or a map, nothing breaks the cycle. The failure is a property of the architecture (memoryless local rules) meeting a concave obstacle, not of the specific seed.
-
On the open map, plan-once’s stored path is four steps south then six steps east. Obstacles are drawn uniformly from the 19 free cells at Manhattan distance greater than four from the start (excluding the goal). What collision probability do you predict, and is 59 collisions in 200 episodes consistent with it?
Answer: Path cells at distances 5, 6, 7, 8 and 9 are eligible, giving 5 of 19 cells. Every appearance time (1 to 4) precedes the robot’s arrival at any of them, so the probability is 5/19 ≈ 0.263, or about 52.6 expected collisions in 200 episodes. The binomial standard deviation is about sqrt(200 × 0.263 × 0.737) ≈ 6.2, so 59 is roughly one standard deviation above the expectation: consistent.
-
Someone proposes to save computation by making the monitored controller look only at the cell it is about to enter, instead of all four neighbors. Would it still avoid collisions here? Give a situation where a one-cell monitor is not enough in general.
Answer: In this simulation, yes: an obstacle can only cause a collision if it occupies the next planned cell, and the controller checks that cell before moving. In general it is not enough when the plan can become invalid far ahead, for example when a corridor further along closes. The robot then walks into a dead end and backtracks, wasting more steps than an earlier replan would have. A monitor must check the conditions the plan depends on, and those need not be adjacent.
-
You are designing a language-model assistant with a calculator, a document search tool and a general model. Which of this article’s four controllers resembles each of these designs: (a) generate a full list of tool calls from the question, then run them all; (b) call the model after every tool result to choose the next step; (c) run the stored plan but re-ask the model only when a tool returns an error or empty result?
Answer: (a) resembles plan-once: cheap, but a failed or surprising tool result cannot change later calls. (b) resembles replan-every-step: adaptive but pays for a model call after every observation. (c) resembles monitor-replan: it only adapts when the monitor fires, so its quality depends on whether “error or empty result” catches all the ways a plan can go wrong; a tool that returns a plausible wrong answer would not trigger it.
Reading the sources as design arguments
Brooks’s memo argues for behavioral decomposition from the requirements of a mobile robot that must keep working as sensors fail and capabilities are added. Sections 1–2 We read the first nine physical pages of the scanned memo, through the description of layer structure; the later module specifications and the simulation results were not checked, and the 1986 journal version is a separate publication not consulted here.
The MRKL paper frames large language models as one module among neural and symbolic experts behind a router, and it is candid that passing discrete arguments from text to a symbolic module has a training cost. Sections 1 and 3 The ReAct paper, discussed in its own article, keeps a single model as the controller but lets it alternate between reasoning text and environment actions. Section 2 Read side by side, they offer different answers to the question this article began with: which part decides what happens next, and what information does it have when it does?
Make a prediction, then check
A planner plans once and then executes without sensing. A new obstacle appears on its path. What is the most direct architectural problem?
Learning objectives
- Distinguish functional decomposition, behavioral layering, module routing and monitored replanning by who decides the next action.
- Predict collisions, oscillation and compute cost from the wiring, then check predictions and sampling variation in a small simulation.
Prerequisites & connections
Explore related knowledge →References
- A Robust Layered Control System for a Mobile Robot — MIT AI Memo 864, author-hosted scan
Rodney A. Brooks · 1985 - MRKL Systems: A modular, neuro-symbolic architecture that combines large language models, external knowledge sources and discrete reasoning — arXiv v1
Ehud Karpas; Omri Abend; Yonatan Belinkov; Barak Lenz; Opher Lieber; Nir Ratner; Yoav Shoham; et al. (AI21 Labs) · 2022 - ReAct: Synergizing Reasoning and Acting in Language Models — arXiv v3 (ICLR 2023)
Shunyu Yao; Jeffrey Zhao; Dian Yu; Nan Du; Izhak Shafran; Karthik Narasimhan; Yuan Cao · 2023
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Claude · 2026-12-02 · Independent AI check (Claude subagent, not the author); this is not a human or expert review. Ran example.py with CPython 3.12.4 and compared it byte for byte with example.stdout.txt; confirmed the python block in en.mdx and zh.mdx is byte-identical to example.py and that every number in the table and prose matches the output. In a scratch copy reproduced the reactive open-map timeout breakdown, found the article's ordering wrong (actual counts at rows 2, 3, 4 are 9, 11, 11), and changed the program to print the breakdown. Hand-checked 5/19 ≈ 0.263 (19 eligible cells, 5 on the BFS path S×4 E×6, confirmed by running bfs), 52.6 expected collisions, binomial sd ≈ 6.2, 59/200 = 0.295, the 1 + 59/200 and 1 + 62/200 identities, and the 5.87x and 8.12x compute ratios. Re-rendered Brooks AI Memo 864 physical pages 1–9 at 110 dpi and read Figures 1–3 and Sections 1.1, 2.1–2.3; read MRKL v1 pages 1–5 and ReAct v3 page 3 (Section 2) by text extraction. Compared zh and en section by section (paragraph counts, numbers, equations, exercises). Did not read Brooks pages 10–26, MRKL beyond Section 3.1, or the 1986 journal version.
- Program output matches example.stdout.txt byte for byte; both code blocks equal example.py; all table and prose numbers match the output.
- Hand-checked 5/19 ≈ 0.263, expected 52.6 collisions, sd ≈ 6.2, the monitor planner-call identities and compute ratios.
- Re-read rendered Brooks memo pages 1–9; Figures 1–3 and Sections 1.1, 2.1–2.3 support the article; MRKL and ReAct attributions match the pages read.
- zh and en compared section by section: sections, paragraphs, equations, numbers, exercises and answers align.
Source locations checked:
- A Robust Layered Control System for a Mobile Robot — MIT AI Memo 864, author-hosted scan · 26-page scan without a text layer; viewed rendered physical pages1–9 (cover dated September1985, printed pages1–8): Figures1–2, Sections1.1–1.4, 2.1 levels of competence0–7, 2.2 layering/suppression and the subsumption-architecture name, 2.3 asynchronous finite-state modules, no handshaking, lost messages, no shared memory. Pages10–26 (module details, simulation) unread; not the1986 journal version.
- MRKL Systems: A modular, neuro-symbolic architecture that combines large language models, external knowledge sources and discrete reasoning — arXiv v1 · arXiv v1 submitted2022-05-01, title page dated2022-05-03, 19 pages. Read text of physical pages1–5: abstract, Section1 limitations, modules/router design and six author-claimed benefits, Section2 Jurassic-X note, Section3 and start of3.1 (argument extraction). The design figure extracted only as a letter and was not viewed; rest of Section3 onward unread. Benefits are author claims, not measurements.
- ReAct: Synergizing Reasoning and Acting in Language Models — arXiv v3 (ICLR 2023) · arXiv v3 dated2023-03-10, ICLR2023 header, 33 pages. Read page1 identity and full text extraction of physical pages3–6: Section2 (context, augmented action space, thoughts without observations, dense/sparse), Sections3.1–3.3 (search/lookup/finish, 6/3 exemplars, baselines, 7/5-step back-off and n/2 rule, 3,000 fine-tuning trajectories, Tables1–2). Table1 columns checked against layout extraction. Section4, appendices and prompts unread.
Related topics