Methodology · Agent Constructionemergingverified

SPAR Agent Loop Design

also known as Sense-Plan-Act-Reflect, SPAR framework

Applies to: agentcoding-agentbrowser-agentvoice-agent

Tags: agent-loopsparsense-plan-act-reflectagent-anatomy

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.

Methodology process overview

Intent. 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.

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.

Inputs

  • Environment interfaceThe channels the agent reads from: APIs, user turns, the file system, and other observers.
  • Task goalThe goal the agent is chasing, written so the Plan phase can break it into steps.
  • Action repertoireThe tools, effectors, or sub-agents the Act phase can use.

Outputs

  • Four-phase agent loopClear Sense, Plan, Act, and Reflect steps joined by typed transitions. You can test and watch each step on its own.
  • Phase trace schemaStructured trace events from each phase that your tooling can group, search, and replay.

Steps (6)

  1. Build the Sense phase

    Decide what the agent observes each tick: user input, tool outputs, memory recall, and environment state. Sense gathers the situation, it does not judge it. Surface anything unclear instead of papering over it.

    usesAugmented LLMScratchpad

  2. Build the Plan phase

    Turn the sensed situation into an intended next move or plan. Use chain-of-thought, tree-of-thoughts, or plan-and-execute when the task calls for it. The output is a plan, not a free monologue.

    usesChain of ThoughtPlan-and-ExecuteTree of Thoughts

  3. Build the Act phase

    Run the plan through tool calls, sub-agents, or outside effectors. Act is the only phase that may change anything. Sense, Plan, and Reflect stay read-only.

    usesTool UseReAct

  4. Build the Reflect phase

    Check the outcome of Act against what the plan intended. Update beliefs, note lessons, and decide whether to loop, replan, escalate, or stop. Reflect is what makes the agent more than a script.

    usesReflectionSelf-Refine

  5. Wire phase transitions and termination

    Define the typed moves between phases: Sense to Plan to Act to Reflect, then back to Sense or stop. Add a step budget and clear stop conditions so the loop always ends.

    usesStep BudgetComposable Termination Conditions

  6. Instrument each phase as a first-class trace event

    Emit a structured trace event tagged with its phase. Your observability tools can then group, filter, and replay by phase, so failures stay easy to find.

Framework-specific instructions

Pick a framework and generate a framework-targeted rewrite of this methodology's steps.

Choose framework

AI-generated for Agent Development Kit (ADK) (Google) — verify against official docs.

Principles

  • Every agent has the same four phases. Make them visible, do not hide them.
  • Only Act changes things. The other three observe, decide, and learn.
  • Reflect is required. An agent that never reflects is just a script.
  • Phase boundaries are contracts you can test, not nice-sounding labels.

Known failure modes (3)

Related patterns (5)

Related compositions (3)

Related methodologies (2)

Sources (2)

Provenance

  • Added to catalog:
  • Last updated:
  • Verification status: verified