What Is an Agent Harness? From Fixed Loops to Runtime Introspection

    An agent harness is the runtime layer that determines how model decisions become tool calls, state changes, and recoverable execution. This article contrasts fixed-loop designs with plugin-based runtimes, clarifies reflection versus homoiconicity, and outlines practical risks, safeguards, ecosystem considerations, and evaluation criteria for choosing a harness.

    What Is a Harness?

    A harness can be understood as the runtime environment layer for an agent. It manages the context used during model calls, tool registration, task execution order, and the saving and restoration of intermediate state. Higher-level policy code decides what the model should do; the harness decides the environment in which those actions occur and the interfaces through which they execute.

    This analogy has limits. An operating system’s hardware abstraction layer deals with hardware whose behavior is deterministic, while model output is probabilistic. A harness must handle uncertain decisions and tool calls that may fail. The two can be compared, but they should not be treated as equivalent.

    Common Forms of Fixed Loops

    Many clients and simple frameworks use the same structure: a system prompt, a set of pre-registered tools such as file read/write, command execution, and web search, a fixed parameter schema, and a loop of “model reasoning, tool call, result injection, model reasoning again.”

    This structure is simple, predictable, and easy to debug. Its limitations mainly appear when extending it. Adding a tool usually requires changing configuration or code and then restarting. The model can only plan within the existing tool set. When a task requires installing a dependency temporarily or splitting a subtask on the fly, the model can only work around the restriction through prompting.

    Not all fixed-loop frameworks lack dynamic planning. Many implementations allow the model to generate subtasks or call sub-agents. However, these capabilities are usually specified at design time, and the model cannot change their structure at runtime.

    To determine whether a framework is a fixed loop, check three points: whether the tool set can grow or shrink mid-session, whether the model can read and modify tool definitions, and whether task decomposition is determined by runtime data. If none of these is possible, it can be considered a fixed loop.

    Homoiconicity and Reflection: Two Easily Confused Concepts

    Homoiconicity originally means that a program’s code and data use the same representation. Lisp S-expressions are a typical example. A program can generate, transform, and execute code as if it were data. Applying this concept to agents requires that tool-call logic be representable as a transformable structure and evaluable in a controlled environment. Few systems meet this condition. Most frameworks simply provide tool definitions to the model as data formats such as JSON Schema.

    Reflection refers to a program’s ability to query and modify its own structure or state at runtime. For an agent, reflection can include querying the remaining context window, viewing completed steps, reading metadata for currently available tools, and adjusting subsequent plans within authorized limits.

    The difference is that reflection focuses on reading and modifying state, while homoiconicity focuses on whether code itself can be treated as data. When a model can access tool schemas and task state, that is metadata access or reflection and should not be directly called homoiconicity. Keeping the two separate helps accurately judge the capability boundaries of a system.

    Plugin-Based Runtime

    A plugin-based design splits the execution environment into replaceable components, such as context management, tool registry, memory storage, and task queue. Each component implements a unified lifecycle interface: initialization, run, and disposal. Components communicate through explicit interfaces or messages. When one component is replaced, the other parts do not need to change.

    The following is a conceptual interface sketch. It does not correspond to any specific project; it only illustrates the design approach:

    1. interface Plugin {
    2. name: string
    3. inputSchema: JSONSchema
    4. outputSchema: JSONSchema
    5. init(ctx): Promise<void>
    6. run(input): Promise<Result>
    7. dispose(): Promise<void>
    8. }

    Schemas allow the runtime to validate inputs before a call and let the model see the input and output structure of each plugin.

    Consider an example: “analyze a CSV and generate a visualization report.” A fixed loop usually provides two tools in advance, “read CSV” and “plot,” and the model can only call them in a predetermined order. A plugin-based runtime allows the model to first register a CSV parsing plugin that declares field types and missing-value handling rules, then register a chart plugin that declares its input format, and finally connect the two into a pipeline. If the parsing stage finds that a column is largely empty, the model can adjust parsing parameters in the next round without rerunning the entire task from the beginning.

    This capability also has engineering costs. Every plugin definition consumes context window space, and the more plugins there are, the less space remains for task data. Failure handling also needs to be agreed upon at the interface layer. When a timeout, abnormal output, or missing dependency occurs, the runtime should define in advance whether to retry, skip, or abort.

    Risks of Runtime Self-Modification

    Allowing a model to modify its own tool set during execution introduces several concrete risks:

    1. Infinite recursion: The model may keep generating plugins that call themselves. The runtime should set a maximum call depth.
    2. Resource exhaustion: Plugins may consume large amounts of memory, disk, or network resources. Each plugin needs quotas.
    3. Privilege escalation: New plugins may obtain file or command permissions beyond what the task requires. Use least privilege, deny by default, and grant permissions on demand.
    4. Untraceable behavior: If plugin creation and modification are not recorded, it is difficult to locate the cause when problems occur. Every registration, modification, and unload should record its source, parameters, and time.
    5. State corruption: If a plugin does not release resources when unloaded, it leaves dirty state behind. dispose must execute reliably.

    Basic safeguards include: executing plugin code in a sandbox; assigning permission levels; requiring human confirmation for operations such as deleting files, sending external requests, and changing permissions; retaining audit logs; and saving a snapshot before each self-modification so it can be rolled back.

    Ecosystem Status

    Plugin standards are not currently unified across projects. A tool definition in one framework may not be directly usable in another. Terminal interfaces, web interfaces, and desktop clients wrapped around such runtimes have already appeared in the community, but their maturity varies widely. Before choosing one, review the project’s maintenance record, release frequency, and documentation completeness.

    For developers, a safer short-term approach is to write general capabilities as independent plugins, keep inputs and outputs serializable, and avoid binding business logic to a framework’s internal APIs. This lowers migration costs even if the underlying runtime changes.

    How to Evaluate a Harness Project

    When selecting a harness, check the following questions one by one:

    • Can the tool set change dynamically during a session, and are changes recorded?
    • Do plugins have explicit input/output schemas and lifecycles?
    • Are permission tiers and human confirmation supported?
    • Can the system roll back to a previous state on failure?
    • How is context usage calculated, and do plugin definitions crowd out task data?
    • Are documentation, tests, and version releases updated continuously?

    If the answer to most of these questions is no, a fixed loop with a small number of extensions is usually safer. Only when a task truly requires runtime planning and tool combinations change frequently is it worth accepting the complexity of a plugin-based runtime.

    Summary

    The core change from fixed loops to runtime introspection is that tools and plans are no longer determined only at startup; they can be adjusted during execution. This allows agents to handle more unforeseen tasks while placing higher demands on stability and security. Understanding reflection, plugin lifecycles, and permission boundaries is more useful than memorizing the name of a particular framework.