Deconstructing Agent Runtime Architecture and Multi-Entry Practice

    Agent systems are moving from single coding assistants to composable execution runtimes. This article focuses on runtime architecture, local deployment, and multiple entry points, covering layered design, permissions, session logs, evaluation, and risk control so teams can turn model capability into reliable engineering productivity.

    Agent system engineering is shifting from a “single coding assistant” to a “composable execution runtime.” If attention stays only on model capability, it is easy to miss what actually determines production quality: unified entry points, tool registration, permission constraints, session auditing, and artifact validation. This article uses runtime architecture as the main thread, combined with local deployment and multi-entry practice, to discuss the layered design and evaluation methods an agent execution framework should provide.

    1. Positioning: a runtime, not a finished product

    Many teams first expect an agent framework to be an out-of-the-box finished tool. A more reasonable positioning is an open runtime for continuing to construct agents. Finished tools typically freeze interaction style, tool sets, and workflows. A runtime decouples model-provider abstraction, tool sets, session management, permission policy, sandboxed execution, the agent loop, and the UI layer so developers can reassemble them by scenario.

    That positioning yields three direct benefits. First, models are replaceable: the same task orchestration can connect to different model services through configuration rather than code changes. Second, tools are extensible: file I/O, command execution, retrieval, browser actions, test runs, and similar capabilities register as tools and can be enabled or disabled per project. Third, execution is auditable: every model call, tool call, permission decision, and artifact generation can land in structured logs for troubleshooting and effect comparison.

    Therefore, such a framework should not be judged only on whether it can generate code, but on whether it has a stable session model, clear permission boundaries, replayable execution traces, and pluggable model and tool interfaces.

    2. Layered architecture: decoupling from entry to artifacts

    A complete agent runtime can usually be divided into these layers:

    1. Entry layer: package-manager distribution, browser UI, headless CLI, Python SDK, and similar. This layer handles argument parsing, identity and config loading, and session creation; it should not carry complex business logic.
    2. Session orchestration layer: multi-turn dialogue, task planning, context trimming, retries, and interrupt recovery. It decides “what to do next” and turns model output into executable tool calls.
    3. Model-provider abstraction layer: unifies call protocols, timeouts, retries, streaming, and error mapping across services so upper layers are not bound to a specific vendor.
    4. Tools and permissions layer: registers capabilities and defines read/write scope, command allowlists, network policy, and approval rules. Permission decisions should be independent of tool implementations so they can be audited centrally.
    5. Sandbox execution layer: isolates command execution, file operations, and dependency installation, limiting resources and network to reduce accidental damage.
    6. Logging and observability layer: records session logs, tool calls, permission decisions, latency, errors, and artifact references, supporting replay and controlled experiments.
    7. UI and artifact layer: emits code, reports, charts, page screenshots, and other visual artifacts, and provides a human review path.

    The point of layering is not more layers, but clear boundaries. For example, a tool implementation should not decide on its own whether writing a file is allowed; it should request a decision from the permission layer. The entry layer should not call the model while bypassing session logs. Only with stable boundaries can you swap models, add tools, or attach remote execution without cascading changes.

    3. Four entry types: local deployment and when to use them

    Multi-entry design lets the same runtime fit different ways of working. These four entries cover most development and automation scenarios.

    Package-manager distribution is suited to fast install and version management. Deployment should pay attention to dependency locking, executable paths, config directories, and credential injection. Prefer project-level runtime config so secrets are not committed; inject sensitive values via environment variables or an external credential store.

    Browser UI is suited to interactive exploration, human review, and demos. Its value is visualizing session traces, tool calls, and artifact previews, but it should not be the only entry. Production automation should prefer scriptable entries to reduce uncertainty from manual steps.

    Headless CLI is suited to CI, batch jobs, and remote execution. Headless mode should support non-interactive confirmation, structured output, and exit-code conventions. For example, return a non-zero exit code on failure and write the session log path to stdout so pipelines can collect it.

    Python SDK is suited to embedding agent capability in existing services, evaluation scripts, or data pipelines. Keep the SDK thin: session creation, message send, tool registration, event subscription, and log reading—avoid hiding too much implicit behavior inside the SDK.

    For deployment shape, the control plane can run on a local developer machine, or the execution plane can run in a general-purpose container environment such as Baidu AI Cloud, with object storage for artifacts and a log service for session logs. In any shape, keep configuration, credentials, workspace, and log directories isolated from one another.

    4. Default configuration: least privilege and observability first

    Defaults often determine first-use experience and the security floor. Suggested principles:

    • Workspace isolation: by default allow read/write only in the current project directory; forbid the user home directory and sensitive system paths.
    • Network tightened by default: deny outbound by default; open allowlists as the task needs; declare dependency install and remote calls explicitly.
    • Command-execution allowlist: intercept or require confirmation for high-risk commands; record the full command and exit status.
    • Structured session logs: enable logs by default, redact sensitive fields, and store logs separately from artifacts.
    • Controllable timeouts and retries: set timeouts for model calls and tool execution; retry policy should avoid repeating side effects.
    • Model-provider abstraction: config should reference provider IDs and model IDs only, without baking business logic into a specific service.

    Illustrative configuration (field relationships only, not a product API):

    1. runtime:
    2. model_provider: "<provider-id>"
    3. sandbox:
    4. mode: workspace
    5. network: deny_by_default
    6. permissions:
    7. read: workspace
    8. write: workspace
    9. exec: allowlist
    10. session:
    11. log_format: jsonl
    12. redact_secrets: true

    Defaults should be “security first, capabilities opened progressively.” When a user clearly needs networked retrieval or dependency install, open that via a task-level policy temporarily rather than enabling everything globally.

    5. Session logs: the basis for replaying execution traces

    Session logs are the most underestimated part of a runtime. They are not only debug material but also the data foundation for effect comparison, permission audit, and cost analysis. A usable session log should at least record: session ID, turn, entry type, model ID, tool name and argument digest, permission decision, duration, errors, artifact references, and context-trimming status.

    Illustrative log record:

    1. {
    2. "session_id": "s-001",
    3. "turn": 4,
    4. "entry": "headless",
    5. "model": "<model-id>",
    6. "tool": "shell",
    7. "args_digest": "...",
    8. "permission": "allow",
    9. "duration_ms": 842,
    10. "artifact_refs": ["artifacts/page.png"]
    11. }

    Three design notes. First, record decisions, not only results: why a write was allowed, why a context span was trimmed, should be traceable. Second, redact secrets: tokens in commands, environment variables, and user paths should be replaced. Third, logs should support replay and diff: the same task under different runtimes or configs can be compared on tool-call sequences, permission intercepts, and artifact differences.

    6. Comparing toolchains on the same base model

    Evaluating an agent runtime should not rely on subjective feel. Use “same base model, same task set, different runtimes” to keep variables tight. Steps include:

    1. Fix model ID and sampling parameters; turn off randomness unrelated to the task.
    2. Prepare tasks covering read, modify, test, debug, and artifact generation, with acceptance criteria per task.
    3. Run two agent runtimes on the same workspace snapshot and network policy.
    4. Collect completion rate, tool-call count, invalid-call ratio, permission intercepts, human interventions, total latency, and artifact quality.
    5. Analyze failures at trace level to separate insufficient model capability, poor tool design, and permission/sandbox configuration.

    The goal is not to label a product but to locate runtime-design differences. For example, fewer tool calls with lower completion may indicate over-aggressive context compression; more calls with stronger recovery may indicate clearer error feedback. Combining metrics with traces yields reusable engineering conclusions.

    7. Complex full-stack tasks and visual artifact verification

    Consider a full-stack task with visual artifacts: generate a runnable data dashboard including backend APIs, a frontend page, basic data initialization, automated tests, and a page screenshot. The runtime can proceed in stages:

    • Plan: directory structure, dependencies, API contracts, and acceptance items.
    • Implement: backend routes and data models, frontend pages and styles, plus start scripts.
    • Verify: unit and API tests, start a local service, take page screenshots or export charts.
    • Review: check visual artifacts against requirements; record screenshot paths, test results, and session logs.

    Visual artifacts turn “it looks done” into inspectable evidence. Screenshots, charts, static assets, and test reports should be written into logs as artifact references and linked to acceptance criteria. For frontend pages, combine screenshot diffs with key-element assertions; for charts, check data source, axes, and export files. If visual artifacts are missing or wrong, the task should not be considered complete even if code generation succeeded.

    8. Best practices and risk control

    Practical recommendations: treat the runtime as infrastructure—version configs, unify entries, collect logs centrally. Grade permission policy by task: read-only, workspace write, networked, and command-execution tasks use different policies. Keep tools narrow and explicit: single responsibility, structured errors, so the model does not guess outcomes. Maintain a regression task set: after changing model, tools, or permissions, rerun fixed tasks and compare traces and artifacts. Keep human review points: high-risk writes, external network access, and final artifact release should be interruptible and approvable.

    Overall, the core value of an agent runtime is not replacing a finished tool but providing a decoupled, auditable, extensible execution base. Understanding layered architecture, entry differences, the log model, and evaluation methods is what turns model capability into stable engineering productivity.