Agent Harness Architecture: From a Single Loop to a Composable Runtime

    This article examines the agent harness as a distinct architectural layer separate from the user-facing client. It reviews the classic single-loop agent design, identifies its engineering limitations, and outlines a newer approach based on a small kernel and replaceable plugins, covering pluginization, lifecycle management, runtime introspection, homoiconic representation and reflection, and the boundaries of runtime self-modification.

    1. Introduction: Why the Agent Harness Deserves Its Own Discussion

    A large language model can only generate text from its input. To make it read and write files, execute commands, query information, and complete multi-step tasks, an external mechanism is needed to turn model output into real actions and then feed action results back to the model. This mechanism is commonly called an agent harness, and sometimes a runtime.

    For a long time, most people have encountered a combined product: the harness plus the interaction interface. Because the two are bound together, it is difficult for users to distinguish which capabilities are general-purpose and which are merely the product shell. This article separates the two and discusses the structure, evolution direction, and engineering trade-offs of the harness itself.

    2. Conceptual Layers: Model, Client, and Harness

    A metaphor can help explain the relationship among the three. The large model is like a horse, responsible for reasoning and decisions. The user-facing agent client is like a carriage, carrying the user and providing the interface, conversation display, file browsing, and other functions. The harness is like the saddle, reins, and related tack, transferring the horse’s power to the carriage and constraining the direction of travel.

    At the technical level, the system can be divided into three layers:

    • Model layer: understands context and outputs text or structured tool-call requests.
    • Harness layer: handles tool registration and scheduling, context assembly, permission checks, result reinjection, loop control, and error handling.
    • Client layer: handles user interaction, session management, interface rendering, and the connection method to the harness.

    The harness sits in the system much like a hardware abstraction layer (HAL) in an operating system. It hides low-level differences and provides a unified interface to the layers above. As long as the interface remains stable, the model can be replaced, tools can be added or removed, and upper-layer logic does not need to be rewritten.

    Mainstream clients usually already ship with a fairly complete harness built in. Therefore, when discussing a new architecture, the point is not to build another interface, but to determine whether the harness itself can be abstracted, reused, and replaced.

    3. Classic Implementation: The Single-Loop Agent Loop

    The most common approach today is a fixed loop structure. Developers set a role in the system prompt, declare a set of tools, and give the model a parameter description for each tool, usually in JSON Schema. Each loop iteration proceeds as follows:

    1. Assemble the system prompt, historical messages, and tool descriptions into a request and send it to the model.
    2. The model returns text or a tool call containing a tool name and arguments.
    3. The client parses the call and executes the corresponding local function.
    4. The execution result is converted to text and appended to the message list.
    5. Return to step 1 until the model no longer requests tools or a termination condition is reached.

    The pseudocode looks roughly like this:

    1. def agent_loop(model, tools, messages):
    2. while True:
    3. reply = model.generate(
    4. messages,
    5. tool_schemas=[t.schema for t in tools.values()],
    6. )
    7. messages.append(reply)
    8. if not reply.tool_calls:
    9. return reply.text
    10. for call in reply.tool_calls:
    11. result = tools[call.name].run(**call.arguments)
    12. messages.append(tool_result_message(call.id, result))

    This structure is simple and reliable enough for many practical tasks. Its limitations appear mainly in the following areas:

    • Hard-coded behavior: loop logic, retry strategy, and termination conditions are all written in one place, and changes require a release.
    • Static tool set: tools are determined at startup and cannot be loaded or unloaded on demand at runtime.
    • Context bloat: full tool output must be reinjected each round, and long tasks quickly exceed the context window.
    • Coarse permissions: tools are either all available or all unavailable, making it difficult to refine access by scenario.
    • Weak observability: internal state is scattered across the message list, and troubleshooting requires reading entries one by one.

    These issues can be mitigated, but each mitigation makes the loop code more complex and eventually produces a new monolith. This is the immediate reason new architectures have emerged.

    4. Key Capabilities of the New Generation of Architectures

    In response to these limitations, newer design approaches split the harness into a small kernel plus a set of replaceable plugins. The core capabilities can be grouped as follows.

    4.1 Pluginization

    Tools, memory, retrieval, policies, logging, and other capabilities are all treated as plugins that follow a unified lifecycle interface. The kernel does not care what a plugin specifically does. It only loads, registers, invokes, and unloads plugins. Adding a new capability requires no change to the loop code.

    4.2 Lifecycle Management

    Each plugin goes through stages such as initialization, ready, running, paused, and unloaded. The kernel schedules plugins in dependency order and isolates the impact of a plugin failure to avoid a full interruption.

    4.3 Runtime Introspection

    The system can query its own state, such as which plugins are currently mounted, which interfaces each plugin exposes, and the parameters and results of the most recent call. Introspection is a prerequisite for sound model decisions. The model can select a suitable tool only when it knows which capabilities are available.

    4.4 Homoiconic Representation and Reflection

    Homoiconicity means that programs and data use the same representation; Lisp-family languages are the classic example. In agent scenarios, plugin descriptions, tool definitions, and execution plans can all be represented as structured data. The harness can therefore read, inspect, and generate these structures without an additional parsing layer. Reflection lets a program inspect its own structure at runtime and adjust behavior accordingly.

    4.5 Boundaries of Runtime Self-Modification

    Allowing the model to modify its own plugin structure is a powerful capability, and also the riskiest one. Without constraints, the model could load unreviewed code or remove critical capabilities. Self-modification should therefore satisfy at least the following restrictions:

    • Modification operations are submitted as declarative change requests and fully logged.
    • New plugins run in a restricted sandbox with no file system or network access by default.