Agent Harness Architecture Explained: How Open-Source Agent Infrastructure Turns Model Capability into a Runnable Execution Loop

    This article breaks down the architecture of an open-source AI agent harness and explains why the discussion around coding agents is shifting from models to the runtime systems that surround them. It clarifies the boundaries between models, protocols, application frameworks, and execution environments, then walks through a plugin-based kernel design, the core execution loop, tool registry, context governance, and state persistence. It also covers sandbox modes, approval policies, credential isolation, and a practical adoption strategy for preview-stage infrastructure. Readers will come away with a clear view of how composability, recoverability, and auditability determine long-running agent performance.

    1. Why the Focus Is Shifting from Models to Runtime Systems

    Over the past two years, most public discussion about AI coding tools has centered on the model: whether code comprehension is more accurate, whether the context window is larger, whether reasoning chains go deeper, and whether the cost per call is lower. These metrics matter, but once you put a model inside a repository with tens of thousands of files and let it run continuously for tens of minutes or even hours, the quality of the final delivery often depends less on the model itself.

    The reason is that a real repository is a stateful environment. The model needs to know what is in the current working directory, read files accurately, modify code precisely, run build and test commands, observe the output, and correct course based on what it sees. At the same time, it must retain critical facts as the context keeps growing, so it does not “forget” the original constraints. On top of that, there is a set of engineering constraints: high-risk commands cannot be executed directly, a single failed tool call must not take down the entire session, and an interrupted task must be resumable from where it stopped.

    The model decides “what to do next,” while the runtime system wrapped around the model is responsible for making those decisions land safely, reliably, and traceably. This runtime system is commonly referred to as an agent harness.

    2. Concept Boundaries: Model, Protocol, Framework, and Execution Environment

    To understand this kind of infrastructure, start by separating four concepts that are easy to confuse.

    • A model is not an agent. A model receives messages and generates the next piece of text or tool call. It does not inherently know where the working directory is, and it does not come with a terminal, editor, version control, browser, or database capabilities. A model outputting an intent to “read a file” does not mean the file has been reliably read.
    • A protocol is not an agent. Standards such as the Model Context Protocol define how tools, resources, and prompts are exposed and discovered in a unified way, but they do not automatically provide a complete task loop, session recovery, context compaction, permission decisions, or execution state management.
    • An application framework is not the same as an execution environment. Frameworks that lean toward workflow orchestration focus more on how nodes connect and how state flows through a graph structure, and they mainly target developers building business logic.
    • An execution environment is a complete runtime that can run an agent directly. It not only describes how components are composed but also takes on model requests, tool dispatch, process execution, log persistence, user approval, and the interaction interface.

    In one sentence: the first three provide “capabilities” and “orchestration paradigms,” while the execution environment provides a closed loop that is runnable, recoverable, and auditable.

    3. Plugin-Based Kernel: Decomposing an Agent into a Recombinable Tree

    A recently open-sourced agent harness project (command name omitted) takes these ideas quite far. Its core premise is “everything is a plugin,” driven at the bottom by a dependency-injection-style plugin kernel. The project labels itself as being in a developer preview stage and explicitly warns that breaking changes will follow.

    Its key design is not “a tool that looks like a terminal coding assistant.” Instead, it breaks the following elements into plugins: model adapters, the agent main loop, the tool registry, session logs, sandbox, approval policies, context compaction, sub-agents, and even the graphical interface. The whole thing is not a closed program but a plugin tree that can be recombined at startup and replaced or unloaded at runtime.

    This design brings three direct benefits:

    1. Replaceability. Switching model providers only requires replacing the adapter plugin; the main loop and tool layer stay unchanged.
    2. Composability. Approval policies, log persistence methods, and sandbox modes can be assembled freely according to the environment (local development / team-shared / automated pipeline).
    3. Observability. Logs and tracing are themselves plugins, making it easy to connect execution traces to general-purpose logging services and monitoring and alerting systems.

    A schematic plugin declaration can be abstracted as:

    1. plugin(tool_registry):
    2. provide: [file.read, file.write, shell.exec, git.diff]
    3. require: [sandbox, approval, logger]
    4. plugin(agent_loop):
    5. require: [model_adapter, tool_registry, context_compactor]
    6. policy: max_steps=200, on_tool_error=continue

    4. The Execution Loop: Main Loop, Tool Registry, and Context Governance

    A mature execution environment typically contains four cooperating subsystems.

    The main loop handles the “request-parse-dispatch-observe” iteration and defines termination conditions (task complete, step limit, budget limit, user interruption). In engineering terms, both step and time limits must be set to avoid infinite loops consuming resources.

    The tool registry exposes capabilities to the model as structured descriptions, including name, purpose, parameter schema, and return structure. The registry is also a permission boundary: unregistered capabilities cannot be called, and the parameter schema is the validation contract.

    Context governance determines success or failure in long tasks. Common practices include summarizing and compressing historical tool outputs, turning large logs into structured summaries, and writing key facts to an external memory file that can be read back when needed. Compaction must preserve “constraint-type information” (directories that must not be modified, tests that must pass) with priority over “process-type information.”

    State persistence makes sessions recoverable. Session logs, tool call records, and the list of modified files need to be written to disk so that the working context can be rebuilt after a restart instead of starting from zero.

    5. Security Boundaries: Sandbox Modes, Approval, and Credential Isolation

    One point must be clear: a dynamically loaded plugin sandbox is a means of fault isolation and permission convergence, not a strong security boundary. It cannot defend against privilege-escalation attempts from malicious code. Therefore, before using this kind of infrastructure in important production repositories, it is recommended to implement the following measures:

    • Pin versions. Lock the exact versions of the execution environment, plugins, and dependencies, disable automatic upgrades, and route changes through review.
    • Restrict plugin sources. Allow only plugins from trusted sources, verify integrity, and prohibit installing unknown plugins arbitrarily at runtime.
    • Choose the appropriate sandbox mode. Select among “local read/write only,” “restricted process execution,” and “containerized execution” based on risk level, preferring containerization for automated scenarios.
    • Isolate credentials. Use short-lived credentials or a proxy service to issue least-privilege tokens, and prohibit placing long-term keys in the working directory or in plaintext environment variables.
    • Isolate the network. Deny outbound access by default, allow by domain and port allowlists, and route dependency pulls and model calls through separate channels.
    • Isolate persistent directories. Put logs, caches, and memory files in dedicated volumes or directories, and set quotas and cleanup policies.
    • Command-level approval. Force manual confirmation for high-risk operations such as deletion, force push, permission changes, and global package manager installs.

    A minimal policy expression can be referenced as:

    1. sandbox:
    2. mode: container
    3. network: deny
    4. allow_hosts: [model_gateway, package_mirror]
    5. approval:
    6. require_for: [shell.rm, git.push.force, chmod, global_install]
    7. credentials:
    8. type: short_lived
    9. scope: read_write_repo_only
    10. paths:
    11. persist: /var/lib/agent/session
    12. quota: 5GiB

    6. Adoption Strategy During the Preview Period

    The core tension in the preview stage is that “high architectural completeness” does not equal “stable interfaces.” A practical approach is to treat the execution environment as a replaceable component rather than a platform dependency; run it in a task-oriented manner on a container platform, store session artifacts in object storage, and rely on logging services and monitoring and alerting for observability needs. Start with pilots in non-core repositories, establish a tool allowlist and an audit baseline, and then gradually expand the scope.

    7. Conclusion

    The competitiveness of next-generation agent infrastructure lies not in whether it embeds yet another stronger model, but in whether it can turn model capability into a composable, recoverable, and auditable execution loop. The plugin-based kernel provides compositional freedom, the execution loop and context governance determine the success of long tasks, and the sandbox and approval system define the risk boundary. Understanding these three layers is what enables sound engineering trade-offs during the preview period.