Deconstructing Open Agent Runtime Architecture: A Practical Guide

    This article breaks down the architecture of an open agent runtime and explains why it should be evaluated as a runtime rather than a ready-made product. It covers seven decoupled capability layers, four access entry points that share one core, default least-privilege configuration, session logs for auditability, and a controlled method for comparing execution traces across models. It also walks through a full-stack task with visual output and offers enterprise deployment guidance, showing that maturity depends on decoupling, a shared core, auditable behavior, and versionable policies.

    1. Clarifying the Positioning: Why Runtime, Not Product

    After an agent-related project is open-sourced, the most common misjudgment in the community is treating “open source” as “a ready-to-use finished tool.” In practice, the opposite is usually true: what is actually delivered is a runtime—the execution foundation that carries the agent lifecycle—rather than a terminal product with fixed features and a single interaction mode.

    The difference can be distinguished along three dimensions:

    • Replaceability: A product binds the model, tools, and interface into a single whole; a runtime defines every layer as a replaceable implementation, so the model provider, tool registry, and UI rendering layer can all be swapped on demand.
    • Composability: A product exposes only one usage path; a runtime provides a graphical interface, a headless CLI mode, multi-language SDKs, and standard protocol interfaces at the same time, allowing upper-layer applications to orchestrate them freely.
    • Governability: A product hides permissions and auditing internally; a runtime explicitly exposes session records, permission policies, and execution sandboxes, making it easier for enterprises to plug in logging services, monitoring alerts, and compliance audits.

    Understanding this is what keeps the following architecture breakdown on track: what we are evaluating is not “how easy it is to use,” but “whether it can be further constructed.”

    2. Overall Layers: Seven Loosely Coupled Capability Surfaces

    Abstracting this kind of runtime yields seven loosely coupled capability surfaces that communicate through clearly defined contracts. Replacing any one layer should not require rewriting the others.

    1. Model provider layer: Routes requests to a specific large model implementation, abstracting away authentication, rate limiting, and context window differences.
    2. Toolset layer: Manages callable capabilities through a registry, including local commands, file operations, retrieval, and external API calls.
    3. Session management layer: Maintains multi-turn context, state snapshots, and resume-from-checkpoint capability.
    4. Permission policy layer: Decides whether an operation is allowed, using a three-state model of “ask—authorize—deny.”
    5. Sandbox execution layer: Provides an isolated filesystem and network boundary for untrusted code.
    6. Agent loop layer: Drives the iterative “perceive—plan—invoke—observe—replan” process and handles termination conditions.
    7. Interface layer: Consumes only the standard event stream and holds no business state.

    A schematic contract description can be written as follows. The emphasis is on dependency inversion—the loop layer is unaware of the interface, and the interface layer is unaware of the model:

    1. AgentLoop -> ModelProvider (generate / stream)
    2. AgentLoop -> ToolRegistry (list / invoke)
    3. AgentLoop -> SessionStore (load / append / checkpoint)
    4. ToolInvoke -> PolicyEngine (allow / ask / deny)
    5. ToolInvoke -> Sandbox (exec with fs+net boundary)
    6. EventStream -> UI / CLI / SDK (read-only consumers)

    3. Four Access Entry Points: Four Projections of One Core

    A mature runtime keeps the “entry points” thin and the “core” thick. The four common entry types and their applicable scenarios are as follows.

    • Graphical interface entry: Aimed at exploratory development, emphasizing visual diffs, artifact previews, and process observability; suitable for stages where requirements have not yet converged.
    • Headless CLI entry: Aimed at pipelines and batch refactoring, emphasizing scriptability, clear exit code semantics, and machine-parseable output; suitable for CI integration.
    • Multi-language SDK entry: Aimed at embedding agents into existing services, emphasizing in-process invocation, type-friendly data structures, and session object reuse.
    • Standard protocol entry: Aimed at cross-tool interoperability, exchanging requests and events through a JSON-RPC-based message convention so that clients and backends from different implementations can replace each other.

    All four entries share the same session and permission configuration, and this is the key criterion for judging “whether it is truly a runtime.” If switching entries loses historical sessions or requires reconfiguring permission policies, the core is not truly decoupled.

    Headless invocation is usually kept minimal for easy embedding in scripts:

    1. agent-runner --headless \
    2. --task-file ./task.md \
    3. --session ./sessions/demo \
    4. --policy ./policy.default \
    5. --output-format jsonl

    4. Default Configuration and the Least-Privilege Principle

    Default configuration sets the security floor. A responsible runtime should ship with defaults that satisfy the following:

    • Write operations are restricted to the workspace directory by default; out-of-bounds access requires explicit authorization;
    • Network access is requested on demand by default, avoiding silent outbound connections during execution;
    • High-risk actions (deletion, bulk rewriting, dependency installation) default to the “ask” state;
    • All tool calls are logged, forming a replayable sequence of operations.

    The policy file is best maintained declaratively for easier review and versioning:

    1. workspace: ./project
    2. network: ask
    3. rules:
    4. - tool: fs.write effect: allow scope: workspace
    5. - tool: fs.delete effect: ask
    6. - tool: net.fetch effect: ask domains: internal
    7. - tool: shell.exec effect: allow timeout: 120s

    5. Session Logs: The Technical Foundation of Auditability

    Session logs are not “chat transcripts” but a complete chain of evidence for agent behavior. A well-designed record typically contains four types of entries: task input, model response (including reasoning summaries and tool call intent), tool calls and returns, and state checkpoints.

    Their value shows in three aspects:

    • Reproducibility: Given the same checkpoint, subsequent steps can be replayed to pinpoint exactly where things went off track;
    • Evaluability: Logs can be turned into structured samples for building regression test sets, measuring the payoff of prompt, tool description, and policy adjustments;
    • Governability: Combined with logging services and monitoring alerts, dashboards can be built for metrics such as call volume, failure rate, and average iteration rounds.

    Field-based storage is recommended over large blocks of free text:

    1. {"ts":"...","type":"tool_call","name":"fs.write","args_digest":"sha256:..","result":"ok","turn":7}
    2. {"ts":"...","type":"checkpoint","session":"demo","turn":7,"tokens":18422}

    6. Cross-Model Comparison Experiments: How to Fairly Compare Execution Traces

    To judge the value of the runtime itself, you need to control variables: fix the task, fix the toolset, fix the policy, and replace only the model implementation, then compare the execution trace rather than the final answer. Observable metrics include effective steps, invalid retries, tool argument accuracy, context growth rate, and the number of human interventions.

    Key points of experimental design:

    1. Tasks need to combine retrieval, coding, and verification actions to avoid distortion from a single dimension;
    2. Record the arguments and return summary of each step to form an alignable trace sequence;
    3. Attribute the same failure mode into categories: model capability issues, tool description ambiguity, overly strict policy, or insufficient context;
    4. Land conclusions at the configuration layer rather than a vague judgment like “a certain model is stronger.”

    A common finding in practice is that trace quality depends more on the clarity of tool descriptions and the granularity of feedback; model differences are often amplified only in the latter half of long-chain tasks.

    7. Delivering Complex Full-Stack Tasks: A Closed Loop with Visual Artifacts

    Take a full-stack task that includes a UI rendering artifact as an example to illustrate the key steps of closed-loop execution:

    1. Requirement structuring: Break a vague description into three parts—data model, API contract, and page state;
    2. Scaffolding and dependencies: Initialize the project inside the sandbox, with dependency installation constrained by network policy;
    3. Implementation and self-verification: Write the API and data layer first, then fill in the view layer, using automated checks as observation signals at each step;
    4. Artifact generation: Output a previewable static build result and render the visual artifact through the interface layer;
    5. Regression and delivery: Write the whole process into the session log to form reusable evaluation samples.

    The key lesson is that the quality of feedback signals determines the convergence speed. Without type checking, unit tests, and build validation, the number of agent iteration rounds rises significantly.

    8. Enterprise Adoption Recommendations

    To build similar capabilities inside an organization, prioritize generic cloud categories over proprietary interfaces: use a container platform to host the sandbox runtime, object storage to archive sessions and artifacts, a message queue to smooth and asynchronously handle peak tasks, and logging services plus monitoring alerts to close the observability loop, while constraining operation boundaries through a unified identity and permission system. Baidu AI Cloud offers a relatively complete combination of such generic capabilities and can serve as a reference direction for architecture selection.

    In summary, the standard for judging whether an agent infrastructure is mature is not “whether it can generate a beautiful result in one shot,” but whether the layers are decoupled, whether the entries share one core, whether behavior is auditable, and whether policies are versionable.