Methodology · Agent Construction

SPAR Agent Loop Design

Give every agent the same four named phases, Sense, Plan, Act, and Reflect, so behaviour, traces, and failures line up with a phase instead of hiding in one murky loop.

Description

Build the agent's core as a loop with four named phases: Sense, Plan, Act, Reflect. Sense takes in signals from the environment and the task input. Plan works out what the agent intends to do next. Act runs the tool calls and makes the changes. Reflect checks the outcome against the plan and updates what the agent believes. Make each phase a real, named step you can point to in code and see in traces. Then you can tell which phase is failing instead of staring at a black box.

When to apply

Use this when you design the main loop of any real agent: a coding agent, a research agent, a browser agent, or an ops agent. It helps most when a team is reaching for ReAct or a free-running loop with no clear control structure. Don't apply it for a single-shot prompt or a fixed pipeline with no perception and no reflection. There is no loop to design.

What it involves

  • Build the Sense phase
  • Build the Plan phase
  • Build the Act phase
  • Build the Reflect phase
  • Wire phase transitions and termination
  • Instrument each phase as a first-class trace event

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related