Why architecture matters here

Agents fail on the plan, not on the individual step. A step-by-step call to an LLM is straightforward; recognizing that Step 3 needs a different tool because Step 2 returned unexpected data is where good planners earn their keep.

The architecture matters because the loop must be observable. Without a state store, the agent forgets what it decided. Without reflection, it cannot correct. Without replan, it charges ahead when off-course. Without budgets, it never stops.

Build the loop and the agent gets much smaller — the LLM contributes one piece of judgment at a time within a reliable structure.

Advertisement

The architecture: every piece explained

The top strip is the forward path. Goal captures user intent explicitly with acceptance criteria. Planner LLM produces a high-level plan (natural language + structured steps). Decomposer breaks steps into concrete actions with dependencies. Executor invokes tools or delegates to subagents, one step at a time.

The middle row is the control loop. State store holds task board (planned/in-progress/done), facts learned so far, and current beliefs. Reflection evaluates recent progress against the plan — did the step succeed, did we get new information? Replan revises the plan when reflection reveals a gap. Completion check asks whether the goal is satisfied and returns to the user with results.

The lower rows are hygiene. Memory + summarization compacts context so long agents stay within token limits. Guardrails + policy enforce that every action passes safety checks — the governance plane from a separate article. Observability logs the plan, every step, the reflection outputs, and cost.

Agent planner — goal → plan → decompose → execute → reflect → replanthe loop that separates agents from chatbotsGoaluser intentPlanner LLMhigh-level planDecomposersteps + depsExecutortool + subagentState storetask board + factsReflectionevaluate progressReplanrevise planCompletion checkgoal satisfied?Memory + summarizationkeep context boundedGuardrails + policysafe action within limitsObservability — plan trace + step-by-step audit + budget usagerecordcheckadaptfinishcompactverifyverifyobserveobserve
Agent planner loop with reflection and safety.
Advertisement

End-to-end flow

End-to-end: a user asks an agent to "triage this bug report and propose a fix." Planner LLM outputs plan: 1) read the report, 2) find the relevant code, 3) reproduce, 4) diagnose, 5) draft fix. Decomposer maps to concrete tool calls. Executor runs step 1 (read repo); state store records key facts. Step 2 grep — one relevant file. Step 3 reproduce — test fails as expected. Step 4 diagnose — LLM analyzes and identifies a null check missing. Reflection: yes, this matches the report. Step 5 draft fix — LLM outputs a patch. Completion check confirms all steps done and returns the patch to the user. Observability shows total 5 tool calls, 12k tokens, $0.14 cost.