Skip to content
ImagineWorld

Agent Architectures Basics

node_idnode-book_ai-agents-guide_chapter-11-agent-architectures-basics
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num11
chapter_titleAgent Architectures Basics
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

9 examples to get you started with Agent Architectures - 6 basic and 3 intermediate.

These sketches are conceptual and provider-agnostic. They show control flow, not a full production SDK.


Frame architecture as “what decides the next step,” not as a library choice.

# Architecture is a policy, not a package name
policy = "react" # or "plan_execute" or "multi_agent"
assert policy in {"react", "plan_execute", "multi_agent"}
  • Write the decision policy on a whiteboard before picking LangGraph, CrewAI, or a custom loop.
  • The same tools work under any of the three patterns.
  • Most early failures are unbounded loops, not “wrong framework.”

Related: The Three Core Agent Architecture Patterns, Compared - pattern map


One interleaved cycle: reason, act, observe.

def react_step(state, tools, llm):
thought = llm.reason(state) # short plan for THIS step
action = llm.choose_tool(thought, tools)
observation = tools[action.name](**action.args)
state = state + [thought, action, observation]
return state
  • ReAct decides the next tool only after the last observation.
  • Keep thought short; long monologues burn tokens without better control.
  • Stop when the model emits a final answer or you hit max turns.

Related: ReAct: Reasoning and Acting in an Interleaved Loop - full ReAct model


Without caps, adaptive loops can thrash forever.

def run_react(goal, tools, llm, max_turns=8):
state = [goal]
for turn in range(max_turns):
state = react_step(state, tools, llm)
if llm.is_done(state):
return llm.final_answer(state)
return {"status": "max_turns", "state": state}
  • max_turns is architecture, not an afterthought.
  • Prefer both a turn cap and a goal-completion check.
  • Return a structured failure when the cap hits so callers can replan or escalate.

Related: Stopping Conditions: How an Agent Knows When It’s Done - stop rules


Separate “what to do” from “do the next item.”

def plan_and_execute(goal, tools, llm):
plan = llm.make_plan(goal) # list[str] or list[dict]
results = []
for step in plan:
results.append(llm.execute_step(step, tools, results))
return llm.summarize(goal, plan, results)
  • Planning produces an ordered checklist the executor walks.
  • Execution can still call tools; it should not invent a new strategy every turn unless you replan.
  • Plans are easier to log, review, and test than free-form ReAct traces.

Related: Plan-and-Execute: Separating Planning from Execution - phased design


Same goal, different decision timing.

goal = "Summarize three sources about agent evals"
# ReAct: next search depends on last result
# Plan: 1) list sources 2) read each 3) synthesize
react_path = "search -> read -> search -> read -> write"
plan_path = "plan[3 steps] -> execute each -> write"
  • Use ReAct when intermediate findings change the next query.
  • Use Plan-and-Execute when the outline is known and you want fewer exploratory calls.
  • Neither pattern replaces grounding, citations, or evals.

Related: When to Choose ReAct vs Plan-and-Execute vs Multi-Agent - decision table


Route work to a narrower agent, then return.

def handoff(goal, router, specialists):
name = router.pick(goal) # e.g. "researcher"
specialist = specialists[name]
packet = {"goal": goal, "constraints": router.constraints(goal)}
result = specialist.run(packet) # own loop + tools
return router.merge(result)
  • Handoff passes a structured packet, not the entire raw chat dump by default.
  • Specialists should own fewer tools than the router exposes overall.
  • Merge/return must define success, failure, and “needs human” states.

Related: Multi-Agent Handoff: Specialist Agents Passing Work to Each Other - orchestration model


Keep Plan-and-Execute adaptive without collapsing into pure ReAct.

def execute_with_replan(goal, tools, llm, max_replans=2):
plan = llm.make_plan(goal)
replans = 0
results = []
i = 0
while i < len(plan):
out = llm.execute_step(plan[i], tools, results)
if out.get("ok"):
results.append(out)
i += 1
continue
if replans >= max_replans:
return {"status": "failed", "results": results}
plan = llm.replan(goal, plan, results, out)
replans += 1
i = 0 # or resume from a marked step
return llm.summarize(goal, plan, results)
  • Cap replans the same way you cap ReAct turns.
  • Log why a replan fired; silent replans hide broken tools.
  • Prefer resuming from a checkpoint over always restarting at step 0 when safe.

Related: Plan-and-Execute: Separating Planning from Execution - replan policy


8. Hybrid: Plan Outside, ReAct Inside a Step

Section titled “8. Hybrid: Plan Outside, ReAct Inside a Step”

Use structure at the top and flexibility where tools are messy.

def hybrid(goal, tools, llm):
plan = llm.make_plan(goal)
results = []
for step in plan:
# small ReAct budget per planned step
results.append(run_react(step, tools, llm, max_turns=4))
return llm.summarize(goal, plan, results)
  • Top-level plan keeps the audit trail human-readable.
  • Inner ReAct absorbs tool noise without rewriting the whole mission each turn.
  • Budget turns per step so one bad step cannot burn the global budget alone.

Related: Hybrid Architectures: Combining Planning, Reaction, and Delegation - production blends


Before writing production code, answer these in one page.

checklist = {
"pattern": "react | plan_execute | multi_agent | hybrid",
"stop": ["max_turns", "timeout", "goal_check"],
"tools": "least privilege per role",
"context": "what is dropped at handoff or replan",
"observability": "log phase + decision + stop reason",
}
  • If you cannot name the pattern, you will debug symptoms instead of control flow.
  • If you cannot name stop conditions, you have not finished the architecture.
  • If every role has every tool, multi-agent is costume, not design.

Related: Agent Architectures Best Practices - ten guidelines | Common Architecture Anti-Patterns in Early Agent Projects - what to avoid


Stack versions: Pins from the category manifest (verify at build): OpenRouter (~315+ models, July 2026 pricing/fees); LangGraph 1.0+; CrewAI 1.14+; Microsoft Agent Framework 1.0; Vercel AI SDK 6; Pydantic AI (latest); LlamaIndex (latest); OpenAI Agents SDK (latest + MCP); MCP (Linux Foundation governance); A2A (HTTP+SSE+JSON-RPC 2.0); Solana @solana/web3.js + @solana/spl-token.

Reviewed by Chris St. John·Last updated Jul 16, 2026

Was this article helpful?


Source: https://aiagents.codeguides.io/agent-architectures/agent-architectures-basics/