From Generation to Execution: The Architecture and Practice of AI Agent Systems

    This article explains why AI agents go beyond one-shot generation and how to architect them for real execution. It covers a five-layer reference architecture, three orchestration patterns, context engineering practices, reliability and cost control, interaction design, and a staged evaluation and rollout path. The goal is to show how to turn a model from a content generator into a system that reliably delivers results.

    1. The Starting Point: Why “Able to Generate” Is Not “Able to Execute”

    Over the past two years, the default interaction mode of large models has been a single question and a single answer: the user submits a prompt, and the model returns text, code, or an image. The boundary of this mode is clear—it delivers content, not results.

    The gap becomes obvious as soon as developers, creators, and everyday consumers put models into real business workflows. A real task usually involves multiple stages: reading context, retrieving information, calling external systems, validating intermediate results, retrying after failures, and delivering the final output. A single generation cannot cover this chain, so the industry has converged on one answer: wrap the model in an execution system, commonly known as an agent.

    It is worth emphasizing that an agent is not “a longer prompt.” Its essence is a shift in engineering paradigm: from a stateless function to a stateful process control system. Understanding this is the prerequisite for every architecture decision that follows.

    2. Two Metaphors: Electricity and Light, Two Classes of Engineering Metrics

    Two images help clarify what these systems involve.

    Electricity (Flash-class capability) answers “will it run at all.” It maps to a set of hard metrics: time to first token, output tokens per second, concurrency capacity, and cost per task. These metrics determine the feasibility of an agent—if a tool call takes several seconds to return feedback, or if a multi-step task costs more than the gross margin of the business, then even the smartest planning capability cannot reach production. In engineering terms, this class of requirement is usually addressed with a combination of “small-parameter/high-throughput models + streaming responses + cache reuse.”

    Light (Spark-class capability) answers “can you see what is happening.” It maps to explainability and participation at the interaction layer: whether the task plan is visible, whether each step produces feedback, and whether the user can adjust the goal midway. This determines the usability of the agent. Even with a high success rate, users will not hand important tasks to a black-box system that executes automatically.

    In one sentence: electricity sets the floor, light sets the ceiling. A mature agent platform must have both.

    3. Reference Architecture: A Five-Layer Split

    For a deployable agent system, it is advisable to split responsibilities into five layers instead of piling all logic into the prompt.

    1. Model layer: handles reasoning, planning, and content generation. In practice, two kinds of models usually work together—one with low latency and high throughput for “light work” such as intent recognition, parameter extraction, and format conversion; one with stronger reasoning for multi-step planning and difficult decisions.
    2. Orchestration layer: handles task decomposition, state machine transitions, tool selection, retries, and rollbacks. This is the real “control center” of the whole system.
    3. Tool layer: standardizes external capabilities into callable interfaces, including retrieval, database queries, code execution sandboxes, file and object storage reads and writes, and message notifications.
    4. Context and memory layer: short-term context manages the window and compression strategy; long-term memory relies on vector retrieval combined with structured storage.
    5. Interaction and observability layer: streaming output, execution trace display, human confirmation points, plus logs, metrics, distributed tracing, and alerts.

    4. Three Mainstream Orchestration Patterns

    The choice of orchestration pattern directly determines how controllable the system is.

    Fixed workflow: the path is defined in advance, and the model only fills in node parameters. This offers the highest controllability and suits stable business processes, such as ticket classification and report generation.

    Autonomous planning: the model decomposes the task and selects tools on its own. It is flexible but risky, and must be paired with step limits, budget caps, and an allowlist for dangerous operations.

    Hybrid mode: an outer workflow constrains the boundaries, while autonomous planning is opened at specific inner nodes. This is currently the most cost-effective compromise in engineering practice.

    Illustrative orchestration pseudocode:

    1. def run_task(goal, ctx):
    2. plan = planner.plan(goal, ctx) # generate a list of steps
    3. for step in plan: # steps are capped by a limit
    4. if step.needs_human:
    5. ctx = wait_for_confirm(step, ctx) # human confirmation point
    6. result = tool_registry.call( # unified entry for tool calls
    7. step.tool, step.args, timeout=step.timeout
    8. )
    9. ctx = ctx.append(step, result) # accumulate state
    10. if verifier.failed(result):
    11. ctx = retry_with_feedback(ctx) # retry with feedback, not blindly
    12. return ctx.summarize()

    The key design point is that the verifier must be an independent component and cannot be the generator grading itself. Letting the same model both generate and score will systematically overestimate the success rate.

    5. Context Engineering: The Invisible Variable That Decides Success

    In practice, agents rarely fail because “the model is not smart enough”; most failures come from giving the wrong context. Three lessons:

    • Load on demand: do not stuff every document into the window; retrieve first, then inject. Noise significantly degrades instruction following.
    • Compression and summarization: long tasks need periodic compression of history into a structured summary that keeps decisions and constraints and discards redundant source text.
    • Explicit state: write completed items, pending items, and failure reasons as structured objects instead of relying on the model to “remember.”

    6. Reliability and Cost Control

    An execution system must assume that tools will fail. Engineering should implement timeouts and idempotency design (to avoid side effects such as duplicate orders), exponential backoff retries, circuit breaking and fallback paths, and full-chain tracing. On the cost side, it relies on tiered model routing, result caching, batching, and context trimming. In these scenarios, Baidu AI Cloud typically provides general-purpose capabilities, such as a container platform to host orchestration services, object storage to keep intermediate artifacts, a message queue for asynchronous decoupling, and logging and monitoring services with alerting for observability. The specific selection should be decided after load testing against your own workload.

    7. The Interaction Layer: Lighting Up the Execution Process

    For products aimed at everyday users, the backend process needs to be translated into perceivable feedback: a task list, a progress bar, the tool currently being called, and clickable entry points for modifications. Creator scenarios should also support multi-version comparison and partial redo. The principle is automatic by default, interruptible at key points, which preserves both efficiency and control.

    8. Evaluation System and Rollout Path

    Without evaluation there is no iteration. It is advisable to build three levels of evaluation: component level (tool call accuracy), task level (end-to-end success rate and number of steps), and business level (human adoption rate and time saved). The recommended path to launch: first get a closed loop running with a fixed workflow → add observability and human confirmation → then gradually open up autonomy. Skipping the first two steps and chasing full automation directly is the most common way such projects fail.

    9. Conclusion

    Going from generation to execution is essentially placing the model inside a constrained control system. Make the “electricity” solid, and the system can run; make the “light” thorough, and users will dare to use it. Combined with rigorous orchestration, context management, and an evaluation loop, AI can truly move from “outputting content” to “delivering results.”