Agent Architecture Layers: From Concepts to Production
This guide explains why layered abstraction matters in AI agent development and walks through the three layers: an orchestration runtime built around state graphs, a component-based application framework, and ready-to-use agent harnesses. You will learn what each layer provides, its trade-offs and boundaries, how to choose the right layer with four practical questions, and how to combine them in real projects while keeping reliability and observability in check.
1. Why Agent Development Needs Layered Abstraction
Many developers start their first AI agent as a simple “chat program that can call tools”: they stitch together prompts, parse model output, hand-write the loop, and maintain context themselves. The prototype runs quickly, but once it enters real business scenarios, problems emerge all at once: code becomes hard to maintain as branches multiply, a run that fails halfway cannot resume, there is no entry point for human approval, and when something breaks in production it is impossible to tell which step failed.
The common root cause is mixing “what capabilities to use” with “how to execute the flow” in the same block of code. The value of layered abstraction is separating these two concerns. The industry has gradually converged on a three-layer structure:
- The bottom layer is the orchestration runtime, responsible for actually driving execution, managing state, and supporting interruption and recovery.
- The middle layer is the application framework, providing reusable building blocks such as model access, prompt templates, tool wrapping, retrieval, and output parsing.
- The top layer is the agent harness, which preconfigures the standard structure of common heavy agents so developers can get a runnable, complete skeleton with very little code.
It is worth stressing that these three layers are not competing alternatives to choose one from; they are three altitudes on the same abstraction chain. The higher you go, the faster you move; the lower you go, the more control you have. Once you understand this, the selection question changes from “which one is better” to “how far down does my scenario need to go.”
2. The Bottom Layer: A State-Graph-Centered Orchestration Runtime
The core proposition of the orchestration runtime is to model the flow explicitly as a graph.
2.1 Nodes and Edges: Writing the Flow as a Structure
A node is the smallest execution unit. It can be a single model call, a tool execution, a data validation, or a pure function transformation. An edge defines how execution moves between nodes, including fixed sequences, conditional branches, and loops. Compared with a linear call chain, a graph structure is naturally suited to expressing real logic such as “decide first, then choose a path” and “send the result back for a redo if it does not pass review.”
A schematic pseudocode structure looks like this:
graph = StateGraph(State)graph.add_node("plan", plan_step)graph.add_node("act", tool_step)graph.add_node("review", review_step)graph.add_edge(START, "plan")graph.add_conditional_edges("plan", route_by_intent,{"tool": "act", "answer": "review"})graph.add_edge("act", "review")graph.add_conditional_edges("review", accept_or_retry,{"accept": END, "retry": "plan"})app = graph.compile(checkpointer=store)
2.2 Explicit State: All Intermediate Data Is Auditable
Every intermediate result is written into a structured state object that nodes read from and update. Explicit state brings three direct benefits: you can see the complete data trail when debugging; you can feed a constructed state into a single node when testing; and you only need to restore the state to continue after an interruption. Combined with a checkpointer that persists state to memory, a relational database, or a key-value store, a long-running flow gains the ability to resume from a checkpoint.
2.3 Production Features Are Built In, Not Bolted On
Loops and conditional branches, multi-agent collaboration, human-in-the-loop, streaming output, and execution interruption and recovery are capabilities that usually take considerable extra effort to build in a homegrown solution, but they are natively supported at the orchestration layer. Human-in-the-loop is especially important: high-risk actions (such as those involving money, deletion, or sending messages externally) can be assigned a waiting node in the graph that pauses execution, hands control to a human for confirmation, and then continues, with state guaranteed not to be lost thanks to the checkpointer.
2.4 The Cost and the Boundaries
The cost is the learning curve: you need to design the state structure yourself, decide node granularity, and handle errors and retries. This layer fits scenarios with complex flows, high reliability requirements, multi-agent division of labor, or mandatory human approval. If the requirement is just “one Q&A plus one retrieval,” going down to this layer is over-engineering.
3. The Middle Layer: A Component-Based Application Framework
The application framework solves the “what to use” problem by turning highly repetitive capabilities into standard components:
- Model access layer: unifies how different model providers are called and hides parameter differences.
- Prompts and output: prompt templates, variable injection, and structured output parsing and validation.
- Tool layer: wraps functions and APIs into tool descriptions that models can understand and call.
- Data and retrieval: document splitting, vectorization, retrievers, and reranking, forming a complete retrieval-augmented generation pipeline.
- Memory and sessions: short-term context management and long-term information storage and retrieval.
- Expression-based orchestration: composing linear flows with pipes into concise declarative code, for example
chain = prompt | model | parser.
The relationship between this layer and the bottom layer can be summarized as: the framework provides the building blocks, and the runtime decides in what order and under what conditions those blocks are executed. The typical way to combine them is that a high-level creation function in the framework compiles into a state graph internally. In other words, you write a single high-level call, and what actually runs is a graph that can be inspected and persisted. This design lets developers enjoy high-level simplicity while keeping a path to take over the details when needed.
4. The Top Layer: Ready-to-Use Builders for Heavy Agents
Builders target the need of “I don’t want to assemble the skeleton from scratch.” They preconfigure the common structure of a class of heavy agents as defaults, typically including task planning, subtask decomposition, default access to tools and retrieval, a file-based or structured workspace for recording intermediate artifacts, a sub-agent spawning mechanism, and human confirmation points throughout the process.
Their value lies in turning best practices into defaults. The genuinely hard part of a complex agent is often not calling the model, but how context is organized, where intermediate artifacts are stored, when to split off subtasks, and when to stop and ask a human. Builders hard-code these decisions, so developers only need to swap in their own toolset and prompt strategy to get a structurally complete, runnable system.
The boundary is equally clear: default structure means default trade-offs. When your flow differs substantially from the preset structure, or when you need fine-grained control over every step, piling on more configuration becomes awkward, and it is time to go down a layer.
5. How to Choose Among the Three Layers and Combine Them
Four questions can quickly locate the right layer:
- Does the flow contain conditional branches, loops, or human approval? If yes, you need at least the bottom runtime layer.
- Do you need checkpoint resume and state auditing? If yes, you must use an orchestration layer with checkpointing.
- Are the components highly repetitive and need to be assembled quickly? If yes, use the middle framework layer to reduce boilerplate.
- Is it a heavy agent with a relatively standard structure? If yes, start with the top builder layer and go down as needed.
The recommended path is “start at the top, converge toward the bottom”: first use a builder to validate the effect and feasibility and expose the unstable parts; when you hit a flow the default structure cannot express, switch to the middle framework’s components and build the graph yourself; when hard requirements arise for reliability and observability, define nodes and state directly at the runtime layer.
Engineering support is just as important: use tracing and visual debugging to locate the failing node, use logs and metrics to monitor per-step latency and success rate, externalize checkpoint state to reliable storage services, and manage sensitive data and credentials through a key management service. If the whole system runs on a container platform, elastic scaling and managed storage can carry long-running flows and high-frequency calls.
6. Common Pitfalls
- Treating the three layers as competitors in a horizontal comparison, ignoring that they are the same abstraction chain.
- Hand-writing the full set of loops and state management from the start, spending time reinventing the wheel.
- Designing state without boundaries and stuffing all intermediate data into it, causing storage bloat and slow recovery.
- Overlooking human intervention points and letting high-risk actions run fully automatically.
- Having no observability design, so production issues can only be guessed from log text.
7. Conclusion
The point of layered architecture is not to add more concepts, but to give complexity a place to live. Once you understand the main thread — the runtime handles how it runs, the framework handles what to use, and the builder handles what default structure to provide — you can align from concept to selection in ten minutes and move smoothly from shallow to deep in a real project, preserving both delivery speed and production reliability.
