The AI Agent Architecture Playbook: Prompt, Bot, Loop, Graph, Harness
The AI Agent Architecture Playbook: Prompt, Bot, Loop, Graph, Harness
Introduction
Most AI engineering mistakes happen before the first user ever sends a request. Teams either build an elaborate multi-agent orchestration layer for a problem that needed a single clear prompt, or they try to stretch a basic chatbot into an autonomous workflow and wonder why it drops context halfway through.
Across modern language models—whether you use Claude, GPT, Grok, or open-source weights—software teams keep rediscovering the same five architectural stages: Prompt, Bot, Loop, Graph, and Harness.
The goal is never to reach Stage 5 for its own sake. The goal is to match the architecture to the problem—and recognize the complexity signals that tell you when a system has genuinely outgrown its current stage.
The Big Picture: How the Five Stages Flow Together
Rather than competing approaches, these five stages form a progressive ladder. You start with a single direct instruction (Prompt), wrap it with rules and tools (Bot), let it iterate and self-correct (Loop), split specialized work across connected roles (Graph), and finally surround the whole system with operational safety nets (Harness).
How to read the flow: Each stage builds on the previous one with five core pillars—Clarity (single task), Grounding (context & tools), Autonomy (self-correction), Coordination (multi-agent workflows), and Reliability (production safety). Each arrow represents a jump in autonomy and operational complexity. Most real-world products work best at Stage 3 (Loop) or Stage 4 (Graph)—while Stage 5 (Harness) exists to keep those systems reliable, affordable, and auditable at production scale.
Stage 1: Prompt — One Input, One Output
Definition: A Prompt is a stateless, one-shot interaction where everything the model needs sits inside a single request that produces a single response. No memory, no tools, no retry loops—just clarity.
Concrete Example
A command-line helper that turns a messy code diff into a clean commit message. A background classifier that reads an incoming support email and labels it as billing, bug, or feature request. A batch script that transforms raw CSV data into formatted JSON. Once the response arrives, the transaction is finished.
How It Works
At Stage 1, all your leverage comes from clarity and structure:
- Explicit task definition – exactly what you want done, in one sentence.
- A few worked examples – so the model learns your expected pattern.
- Exact output format – JSON, markdown, structured plain text, whatever you specify.
No conversation history. No tool lookups. No self-correction loops. Just one clean pass.
Complexity Signals (When You Outgrow Stage 1)
You are ready to move up when you notice:
- “I keep copying the same context, rules, and business logic into every request.”
- “The model guesses facts it could easily retrieve from our database or docs.”
- “People ask follow-up questions instead of accepting a single response.”
- “One-shot accuracy drops below 85–90% because the task is genuinely complex.”
Key Takeaway: If your task needs only one pass and one person’s review, stay at Stage 1. Added complexity buys you nothing but latency and operational weight.
Stage 2: Bot — System Rules, Context, and Tools
Definition: A Bot pairs a language model with a persistent set of system instructions, injected domain context, and bounded lookup tools. The key difference from Stage 1: the Bot has a steady persona and knowledge base, but humans still drive every interaction.
Concrete Example
A pull-request review assistant that always checks changes against your team’s engineering standards and flags anti-patterns. An invoice extraction tool that reads PDFs, looks up vendor IDs from your internal database, and presents clean structured fields for human approval. A support triage system that answers common FAQs from your knowledge base before routing complex issues to humans.
How It Works
Instead of treating the model as a blank slate on every request, a Bot establishes three steady pillars:
- System instructions that define its role, tone, boundaries, and what it must never do.
- Relevant context (company policies, project docs, recent data) fed with every request.
- Read-only or tightly scoped tools so the model checks real facts instead of hallucinating.
The human still drives every decision. The Bot reacts to what you ask, gathers information with its tools, and hands control right back. No autonomous retry loops. No working memory across separate conversations.
Complexity Signals (When You Outgrow Stage 2)
You have outgrown Stage 2 when you hear:
- “It gave up after the first API error instead of trying a different approach.”
- “I need the system to remember what it already checked, so it doesn’t repeat work.”
- “The job requires 5 to 15 sequential steps before we review—not every step needs human input.”
- “One assistant role can’t handle both planning and execution cleanly.”
Key Takeaway: A Bot upgrades what the model knows through context and tools—while keeping decision flow, approval, and flow control firmly in human hands.
Stage 3: Loop — Iterative Self-Correction Until Done
Definition: A Loop turns a reactive Bot into a true autonomous agent by giving it working memory, evaluation logic, and permission to retry internally until the goal is met or a safety limit stops it. No human is needed after you launch it.
Concrete Example
A research synthesis agent tasked to compare five cloud vendors’ pricing models and produce a summary table. It drafts an outline, searches each vendor’s docs, extracts pricing details, structures the data, runs a validation check for gaps, discovers that GCP’s pricing is incomplete, searches again, fills in the missing data, and finally delivers the complete table. All without a human asking it to retry.
An automated documentation editor that drafts a user guide, runs a linter to check for broken links and typos, discovers three issues in its own draft, reads the error messages, and rewrites those sections before handing you the final result.
How It Works
At Stage 3, the system gains persistence and self-awareness:
- Initialize: You give the agent a clear goal and a step limit (e.g., “max 20 turns” or “10 minutes”).
- Execute: The agent chooses a tool, calls it, reads the result, and updates its mental model.
- Evaluate: The agent asks itself: “Is the goal actually complete?” If not, loop back with the new evidence. If yes, stop and deliver.
- Terminate: When steps run out or the goal is met, return the final result to the human.
Because a single focused Loop shares one coherent context and a clear exit condition, most real-world AI products live right here at Stage 3. It is the sweet spot between sophistication and operational simplicity.
Complexity Signals (When You Outgrow Stage 3)
Even a great single Loop eventually hits a ceiling:
- “The instructions are trying to handle research AND planning AND coding AND review—the model keeps dropping earlier context.”
- “Independent subtasks are waiting on each other sequentially instead of running in parallel.”
- “This step needs a cheap, fast model (sorting), but that step needs an expensive, powerful model (reasoning).”
- “Research runs on GPT, but final approval has to run on Claude for compliance.”
- “The token usage per job is growing faster than user volume.”
Key Takeaway: Stage 3 is the everyday workhorse of AI engineering. Stay here as long as one clear goal and one focused context can carry the entire task.
Stage 4: Graph — Coordinated Multi-Agent Workflows
Definition: A Graph breaks a complex process into separate, specialized roles (nodes) connected by explicit routing rules (edges) that control branching, parallel work, human approval checkpoints, and conditional logic. Each agent sees only what it needs and does one thing well.
Concrete Example
An end-to-end software delivery workflow:
- A planner agent reads the task and writes a focused plan.
- The flow pauses at a human checkpoint so a lead engineer approves the plan.
- A coding agent implements only the approved plan, with no freedom to change scope.
- A review agent inspects the code for bugs and style violations.
- Another checkpoint requires sign-off before deployment.
Each role is focused, context is minimal, and humans gate risky decisions. This mirrors how real teams actually work.
How It Works
Instead of jamming every instruction into one overloaded Loop, a Graph separates concerns:
- Specialization: Each node (agent) has one clear job: research, planning, execution, review, or approval.
- Routing logic: Conditional branches send work down different paths based on outcomes. If review fails, loop back to the coder. If budget is exceeded, escalate to humans.
- Parallelism: Independent subtasks run side by side—unit tests run while docs are drafted, for example.
- Human-in-the-loop gates: Workflows pause cleanly for human sign-off and resume exactly where they left off, with full context restored.
- Model flexibility: Research might run on a fast, cheap model; final decisions might run on a stronger, more expensive model.
Because Stage 4 mirrors how real teams collaborate, complex enterprise automations and agent swarms naturally gravitate here. It is where coordination overhead is worth the cost.
Complexity Signals (When You Outgrow Stage 4)
Once your Graph works smoothly in test, real-world production traffic exposes operational gaps:
- “Our primary AI provider slowed down for ten minutes—why didn’t traffic fail over automatically?”
- “One unusual request triggered retry storms that burned 10x the expected budget.”
- “Our compliance team needs a complete, cryptographically verifiable audit trail of every decision and tool call.”
- “We can’t distinguish between a cascade failure in the graph and a legitimate slow operation.”
- “Token costs are growing unpredictably because we have no cost visibility per agent per workflow.”
Key Takeaway: Graphs solve coordination and context limits by dividing work across specialized roles. Use them when no single agent can cleanly handle the full problem.
Stage 5: Harness — Production Safety, Fallbacks, and Governance
Definition: A Harness wraps a working Loop or Graph in operational guardrails—monitoring, fallback routing, budget caps, permission controls, and audit logging—so it runs reliably, predictably, and affordably at production scale. The Harness does not change how the agent reasons; it governs the environment around it.
Concrete Example
A 24/7 customer support system handling 50,000 live conversations daily. At this scale, questions change: “Can the agent handle support tickets?” (yes, Stage 3 Loop solves that). The real questions become: “If the LLM provider goes down, do we have a safe fallback queue? Can we cap spending at $5 per ticket so a confused agent doesn’t burn through the entire monthly budget on one pathological case? Can our compliance team audit every routing decision and override for legal disputes?”
An autonomous infrastructure monitoring system watching production health across 100 services. It runs at massive scale. The concern is not capability—it is predictability.
How It Works
A Harness sits outside the reasoning layer and provides four operational pillars:
-
Permissions and guardrails: Restricts which tools an agent can call. Redacts sensitive data before responses leave your network. Enforces role-based access control so a low-risk agent never gets high-risk tools.
-
Fallbacks and circuit breakers: Monitors latency and error rates from your primary LLM provider. If response time exceeds a threshold or error rate spikes, automatically routes traffic to a backup model (Claude → GPT → open-source), or escalates to humans if all fallbacks fail.
-
Cost and latency caps: Sets hard limits on tokens per session, turns per workflow, or dollars per request. If a session approaches its budget, the Harness stops it and returns the best partial result, preventing runaway spend.
-
Observability and audits: Logs every tool call, every routing decision, every human override, and every model response. Tracks quality metrics (accuracy, latency, cost) over time so you can spot degradation, debug production issues, and demonstrate compliance.
The key insight: because the Harness sits outside your agents, you can swap models across Claude, GPT, Grok, or self-hosted open-source without touching your workflow logic. Your agents remain portable.
When You Need Stage 5
Not every system needs it. Invest in a Harness when:
- Your system is handling real production traffic and SLA violations cost real money.
- Uptime or availability is a legal or contractual obligation.
- You need audit trails for compliance (SOC 2, ISO 27001, HIPAA, etc.).
- Cost predictability is critical—you can’t absorb runaway spending.
- You are using expensive external APIs and need overflow/fallback options.
Key Takeaway: Stage 5 is operational infrastructure around your agents. Reserve it for systems where failures genuinely cost money, reputation, or legal exposure.
Matching the Stage to the Problem
One of the easiest ways to waste months of engineering time is jumping straight to Stage 4 or 5 before a simpler stage fails. Use this guide to pick the lightest architecture that solves your actual problem:
| Stage | Best For | Added Complexity | Typical Sweet Spot |
|---|---|---|---|
| 1. Prompt | Fast, single-step transformations | Minimal | CLI helpers, classifiers, quick summaries |
| 2. Bot | Grounded Q&A and assisted tasks | Low | Code review bots, internal doc assistants |
| 3. Loop | Multi-step tasks needing self-correction | Moderate | Research agents, iterative drafting & analysis |
| 4. Graph | Multi-role processes with branching & gates | High | End-to-end workflows, agent teams |
| 5. Harness | High-volume, business-critical systems | Operational | Enterprise support, regulated automation |
Common Mistakes to Avoid
- Over-engineering on day one: Building a multi-agent Graph for a classification problem adds latency, cost, and debugging pain for zero gain.
- Skipping human checkpoints in Loops and Graphs: Giving agents unrestricted write or publish permissions before validating their intermediate plans invites silent mistakes.
- Stuffing too many roles into one Stage 3 Loop: When a single prompt tries to plan, execute, and audit its own work across dozens of turns, accuracy drops sharply—that is your signal to split into a Graph.
- Using a Harness to mask weak fundamentals: Adding retries, fallback models, and dashboards around an unclear prompt only gives you faster, better-documented failures.
Actionable Takeaways
When planning your next AI feature or workflow, keep these principles handy:
-
Start one stage simpler than your instinct: If you think you need a Graph, prototype a solid Loop first. Prove it fails before adding multi-agent complexity. If you think you need a Loop, test a Bot. Most teams skip stages and regret it.
-
Listen for complexity signals, not architecture feelings: You do not need a Graph because it looks impressive in a diagram. You need a Graph when a single agent is genuinely struggling—holding contradictory instructions, forgetting what it already checked, or needing different models for different steps. These are real signals, not premature optimization.
-
Keep deterministic logic outside the model: Validation, formatting, permission checks, and hard limits belong in reliable Python/TypeScript code, not “polite requests” inside a prompt. Teach the model what to output, but enforce whether it is allowed to with code.
-
Stay model-agnostic: Separate your workflow structure from Claude, OpenAI, or any single provider. Build your Loops and Graphs so you can swap Claude for GPT for Grok without rewriting the pipeline. This flexibility saves you during outages and lets you chase cheaper or faster options as the market moves.
-
Add the Harness when scale demands it: Skip it for internal tools and prototypes. Build it when real users and production SLAs depend on your Stage 3 or Stage 4 systems. Invest in monitoring, budgets, and fallback logic only when failures genuinely cost money, reputation, or legal exposure.
Conclusion
Great AI architecture is defined by restraint, not reach. The five stages—Prompt, Bot, Loop, Graph, Harness—give you a shared language for scaling systems thoughtfully: start lean, listen for real complexity signals, and add infrastructure only where it earns its operational overhead.
Most teams get this wrong. They see a Graph example and jump straight to multi-agent architectures for problems that fit in a Prompt. They wrap every Loop in a full Harness before they have users. They add fallbacks and monitoring to systems that are not yet reliable at the core.
The goal is not to reach Stage 5. The goal is to match the architecture to the problem you have right now. A focused Prompt beats an over-engineered Bot. A clean Loop beats a premature Graph. A working Stage 3 beats a broken Stage 5.
Whether your next task calls for a crisp single prompt, a disciplined multi-agent workflow, or a governed production system, matching the stage to the job is what separates fragile demos from dependable products.
Suggested Reading
- Anthropic Engineering: Building Effective Agents – https://www.anthropic.com/engineering/building-effective-agents
- OpenAI API Documentation: Agents & Tool Use – https://platform.openai.com/docs/guides/agents
- LangGraph Documentation: Workflows and Agent Graphs – https://langchain-ai.github.io/langgraph/
- OpenTelemetry Documentation: Observability & Tracing – https://opentelemetry.io/docs/
- NIST AI Risk Management Framework – https://www.nist.gov/itl/ai-risk-management-framework