Agent Architecture Layers: A Beginner's Guide and Practical Selection Framework
This guide explains why AI agent frameworks are organized into three layers—a workflow orchestration runtime, a component-based application framework, and an agent harness—and how each layer addresses execution, reuse, and rapid prototyping. You will learn the core graph model of nodes, edges, and state, the production features of the runtime layer, how framework components relate to the runtime, and when to choose a ready-made heavy agent builder. A decision table and an engineering checklist help you pick the right layer based on your requirements.
Agent Architecture Layers: A Beginner’s Guide and Practical Selection Framework
1. The Starting Problem: Why Agent Frameworks Get Layered
When you start building an agent that can actually call tools, you quickly run into three practical problems: how to make a workflow truly execute, how to reuse common capabilities, and how to assemble complex, heavy agents fast. A common approach in the market is to package these three needs into three abstraction layers, forming a bottom-up pyramid:
- Bottom layer: workflow orchestration runtime—responsible for actually “running,” managing nodes, edges, state, and recovery.
- Middle layer: application component framework—provides ready-made building blocks and high-level interfaces such as model access, prompt templates, tool wrapping, retrievers, output parsing, and memory.
- Top layer: agent harness—an out-of-the-box wrapper for heavy tasks, with built-in planning, subtask decomposition, file access, and retrieval capabilities.
The value of this layering is that developers can choose “from shallow to deep” based on their needs. Use the high layer to validate an idea quickly; drop down to the bottom layer when you want fine-grained control over every step. It is worth stressing that the three are not competing alternatives but rather successive layers of encapsulation within the same technical system—the builder and framework entry points at the top ultimately compile down into an executable graph structure in the underlying runtime.
2. The Bottom Layer: A Graph-Based Workflow Orchestration Runtime
2.1 Core Mental Model: Nodes, Edges, and State
The key abstraction of the underlying runtime is the “graph.” A node is the smallest execution unit—it can be a single model call, a single tool execution, or a single data transformation. An edge defines the flow rules, including sequential transitions, conditional branches, and loop-back edges. Unlike a linear chain, a graph structure naturally supports non-linear logic such as “go back to the previous step and retry” or “enter a branch only when a condition is met.”
All intermediate data is consolidated into a structured state object. State serves both as the communication bus between nodes and as the basis for persistence and recovery. In engineering practice, you typically distinguish “persistable fields” from “temporary fields” within the state to avoid writing content that should not be persisted into a checkpoint.
Illustrative pseudocode:
# Pseudocode: illustrates graph structure and state flow only, not a specific product APIgraph = Graph(state_schema=AgentState)graph.add_node("plan", plan_step)graph.add_node("act", tool_step)graph.add_node("observe", observe_step)graph.add_edge(START, "plan")graph.add_conditional_edges("act", route_by_result, {"need_more": "observe", "done": END})graph.add_edge("observe", "plan") # loop-back edgeapp = graph.compile(checkpointer=my_checkpointer)
2.2 Where Production-Grade Features Come From
The underlying runtime is suited to production because it turns several “difficult but correct” things into native capabilities:
- Persistence and resume-from-breakpoint: A checkpoint mechanism writes state to memory, a relational database, or a key-value store, so after a process restart you can continue from the most recent checkpoint.
- Human-in-the-loop: Interrupt before a critical node, wait for human approval or additional information, then continue—suitable for high-risk write operations.
- Streaming output and observability: Produce intermediate results at node granularity, and combine them with tracing and visual debugging to pinpoint “exactly which step failed.”
- Multi-agent collaboration: Describe collaboration topologies such as master-subordinate, parallel, and review using a graph, rather than relying on “verbal agreements” in prompts.
2.3 The Cost and the Applicability Boundary
The cost is the learning curve: you need to divide nodes yourself, define the state schema, and design error handling and retries. Applicable scenarios include: compliance-heavy approval workflows, complex multi-agent systems, long-running tasks, and production systems that require precise cost control and observability.
3. The Middle Layer: A Component-Based Application Framework
3.1 It Solves “Reinventing the Wheel”
The middle-layer framework distills high-frequency capabilities into standard components: prompt templates, model abstractions, tool definitions and invocation protocols, memory, retrievers, output parsers, retrieval-augmented generation pipelines, and more. Developers no longer worry about the differences among each model’s SDK and can focus on the business logic itself.
Linear orchestration can be expressed with a declarative, pipeline-style syntax that reads like an assembly line:
# Pseudocode: linear format—call model—parse outputchain = prompt | model | parserresult = chain.invoke({"question": q, "context": docs})
3.2 High-Level Entry Point: Create a Usable Agent in One Line
Frameworks usually provide a high-level entry point that generates an agent with tool-calling ability using a minimal amount of code. Its return value is essentially the graph compiled by the underlying runtime, so you can enjoy the convenience of the high layer while still being able to drop down to the bottom layer and keep refining when needed.
# Pseudocode: create an agent via the high-level entry pointagent = create_agent(model="...", tools=[search, calc], system_prompt="...")agent.invoke({"messages": [{"role": "user", "content": "Help me compare the two options"}]})
3.3 Relationship to the Bottom Layer: What to Use vs. How to Run
In one sentence: the framework decides “which components to use,” and the runtime decides “how to execute.” Framework components can be used directly as node implementations in the runtime; the high-level entry point simply pre-assembles common topologies.
4. The Top Layer: Out-of-the-Box Heavy Agent Builders
When the task itself is “heavy”—for example, requiring long-horizon planning, task decomposition, parallel sub-agents, reading and writing intermediate artifacts, and retrieving from large volumes of information—building a graph from scratch is costly. The top-layer builder comes with this kind of skeleton built in: a planner, a subtask queue, dedicated file and retrieval tools, context compression strategies, and so on. The developer only needs to provide the model, the toolset, and constraint instructions.
Pseudocode illustration:
# Pseudocode: using a heavy builderheavy = create_deep_agent(tools=[web_search, file_io], instructions="You are a research assistant...")heavy.invoke({"messages": [{"role": "user", "content": "Produce a research report with citations"}]})
Its trade-off is clear: you trade control for speed. When you need to modify the internal loop, swap the state schema, or add a custom approval step, you should drop down a layer.
5. Selection Decisions: Working Backward from Requirements to Layers
| Requirement characteristic | Recommended layer | Reason |
|---|---|---|
| Ship a demo-ready prototype within a day | Top-layer builder | Prebuilt skeleton, minimal code |
| Standard Q&A / retrieval augmentation | Middle-layer framework | Complete components, concise pipelines |
| Strong approvals, resumable long tasks | Bottom-layer runtime | State persistence and resume |
| Complex multi-agent collaboration | Bottom-layer runtime | Explicit topology, observable |
| Fine-grained cost and retry strategies | Bottom-layer runtime | Node-level control |
Practical advice: start from the high layer and drop down only when you hit a control bottleneck, rather than hand-writing every node from the outset.
6. Engineering Implementation Checklist
- Design state first: Clarify which fields need to be persisted and which are valid only for the current run.
- Idempotence and retries: Design tool calls to be re-entrant to avoid duplicate side effects during recovery.
- Observability: Instrument every node, recording input summaries, latency, and error types.
- Cost control: Set a maximum loop count, timeouts, and a token budget to prevent “endless thinking.”
- Human gates: Add interrupt-and-approve steps for write operations, payments, outbound sending, and similar actions.
- Evaluation loop: Build a fixed set of test cases to catch regressions caused by prompt and topology changes.
For deployment, you can rely on general cloud capabilities: a container platform to run stateless executors, object storage to hold intermediate artifacts, a message queue for task distribution, logging and monitoring/alerting services for observability, and a managed database or key-value store to hold checkpoints. Cloud providers such as Baidu AI Cloud typically offer the general capability categories above, which you can combine as needed.
7. Conclusion
The essence of a layered architecture is to decouple the three needs of “execution, reuse, and out-of-the-box use.” Understanding the underlying graph and state is the prerequisite for making good use of middle-layer components and top-layer builders; and the correct selection order always starts from business constraints, not from framework popularity.
