Agent Harness Architecture and Practice: From Plugins to Publishing

    This article explains the Agent Harness as a plugin-based runtime framework for AI agents. It covers the plugin-first design philosophy, bundles and configuration trees, common setup errors, build and runtime paths, workspace linkage, publishing and profiles, and the full module-resolution chain. Readers will gain a practical mental model for diagnosing plugin, version, and configuration issues without treating the Harness as a black box.

    Agent Harness Architecture and Practice: From Plugins to Publishing

    1. What Is Harness?

    In the context of agent engineering, Harness can be understood as the runtime scaffold for an agent. It is not a single large model, nor a simple chat interface. Instead, it is a runtime framework that organizes capabilities such as model adaptation, tool invocation, session management, approval sandboxing, and sub-agent scheduling. You can compare it to a server runtime in the web world: the model is the engine, while the Harness is the combination of chassis, transmission, and dashboard.

    The key to understanding Harness is to understand its core design philosophy: everything is a plugin.

    2. Core Philosophy: Everything Is a Plugin

    2.1 No Privileged Core

    Many beginners assume that a framework must contain a “privileged core that needs patching,” and that basic capabilities such as model invocation and the main loop are built in and cannot be replaced. In a typical plugin-based Harness, this assumption does not hold:

    • The model adapter is a plugin.
    • The tool registry is a plugin.
    • Session logging and storage are plugins.
    • The Agent main loop itself is also a plugin.

    These plugins are combined through a configuration tree to form the final runtime instance. The framework base is only an “assembly workshop,” not the “engine.”

    2.2 What a Bundle Really Is

    The most common misunderstanding among beginners is that packages whose names sound like “low-level libraries” are actually not API libraries to be imported. They are bundles. Through the bundle declaration field in package.json and a patch file that inserts plugin rows into an empty configuration tree, a bundle expresses the intent: “I want to mount these plugins.”

    A typical bundle patch file inserts plugin rows covering roughly the following capability domains:

    Plugin row Responsibility
    Timer / hot reload Runtime infrastructure
    LLM + model adapter Large-model invocation and protocol adaptation
    Session Event log and in-memory storage
    Agent interface / main loop Agent driving logic
    Tool registry / prompt assembly Tool and system-prompt management
    Subprocess / Shell execution Command execution capability
    Sandbox / approval Security policy
    Filesystem / policy Controlled file access
    Settings / credentials User configuration and key management
    Sub-agent / workflow Multi-agent orchestration
    Web capability Search and fetching

    This design brings three direct benefits:

    1. Trimmable: Do you not need the sandbox? Remove it from the configuration tree without changing code.
    2. Replaceable: Want to switch model adapters? Replace the corresponding plugin row; the main loop is unaware of the change.
    3. Composable: Multiple bundles can be layered to form runtime shapes for different scenarios, such as a CLI shape or a web shape.

    2.3 Why Design It This Way?

    Making the “framework base” itself a plugin means the framework has no “black box that cannot be reached from the outside.” When troubleshooting, you can expand the configuration tree layer by layer and see where each capability comes from. When extending, you insert plugins that are structurally identical to built-in capabilities instead of calling a limited extension point. This is the essential advantage of a plugin-based architecture over a “core + hooks” architecture.

    3. A Developer’s First Route: Starting with Error Diagnosis

    In practice, the first step is often not writing a plugin, but getting the editor to stop showing red squiggles everywhere. There are three common categories of problems:

    1. Type resolution failures: Source code is referenced through workspace-internal links, and the editor’s language service may not follow the package manager’s linking rules. The solution is to correctly declare path mappings in the project’s tsconfig, or let a language-service plugin recognize the workspace layout.

    2. Conceptual confusion: Several core concepts need to be clarified:

      • Plugin: A module that implements a specific interface and can be mounted to the configuration tree.
      • Bundle: A declarative combination of plugin rows and configuration patches.
      • Runtime instance: The result after a bundle is loaded and plugins are instantiated in dependency order.
    3. Declaration and implementation mismatch: A plugin row exists in the configuration tree, but the corresponding package is not installed or the version does not match. This causes “plugin unresolvable” errors at startup. The troubleshooting order is always: first check whether the package is installed, then check whether the version satisfies the protocol constraints, and finally check whether the configuration row is spelled correctly.

    4. Build System and Two Runtime Paths

    4.1 What Build Commands Do

    A typical build process includes dependency resolution → compilation of each subpackage (type checking + artifact generation) → bundle packaging. Artifacts usually fall into two categories:

    • Plugin packages: Individual plugins that can be referenced by the configuration tree.
    • Bundle packages: A set of plugins and their configuration fixed into an “out-of-the-box” whole.

    4.2 Source Startup vs. Built Artifacts

    Understanding the two runtime paths is a milestone for advanced users:

    • Source startup: Use the repository source code directly as the entry point, together with hot reload. This is suitable for the plugin development stage, where changes take effect immediately.
    • Artifact runtime: Install a published bundle and run it as a stable combination. This is suitable for daily use and deployment verification.

    The debugging principle is: first use the source path to locate the problem, then use the artifact path to verify whether the problem is related to the build or the version. When the two behave differently, first suspect that the build artifact has not been updated or that the cache has not been invalidated.

    5. Workspace Mechanics

    In a monorepo, packages reference each other through the workspace protocol. Two key mechanisms need to be understood:

    1. Linking strategy: Whether the package manager directly symlinks workspace packages to source directories determines whether “changes to source code are immediately visible to referencing packages.”
    2. Workspace protocol: A dependency declaration such as workspace:* means “only accept versions within this repository.” At publish time, it is replaced with a real version number. If a fixed version number is used by mistake, the typical symptom is “local changes do not take effect.”

    6. Publishing and Profiles

    The publishing flow is usually: local build → verify bundle → publish to the package registry. After publishing, the bundle can be installed and mounted by any project.

    The profile mechanism solves the problem of “multiple configurations coexisting.” The profiles directory under the user’s home directory stores different configuration combinations by name, such as a profile for a web scenario. At startup, the profile name selects which configuration tree to load, enabling “one runtime, multiple role shapes.” A profile can be understood as a persisted snapshot of the configuration tree. It is a user-level supplement to bundles: a bundle defines the “factory default,” while a profile defines “personal preference.”

    7. Complete Module Resolution Chain

    Putting all the previous steps together, the complete chain for loading a plugin is:

    1. Entry command → read profile / bundle declaration
    2. → resolve config-tree patch and expand plugin rows
    3. → resolve modules by package name (workspace links first, then installed dependencies)
    4. → instantiate plugins in dependency order and inject services
    5. → main-loop plugin drives the Agent to start work

    Once you understand this chain, any issue such as “the plugin is not taking effect,” “the module cannot be found,” or “version conflict” can be traced to a specific stage.

    8. Summary and Mental Model

    Finally, the mental model can be reduced to three statements:

    1. The configuration tree is the source of truth: Every runtime capability comes from plugin rows declared in the configuration tree. There is no hidden core behavior.
    2. A bundle is a manifest, not a library: The essence of a base package is a “mounting manifest.” Do not treat it as an API to call.
    3. Verify through two paths: Development uses the source path, and verification uses the artifact path. Profiles carry personalized configuration.

    With this model, Harness is no longer a black box. It becomes a clearly expanded plugin topology that can be plugged and unplugged at any time. This is the greatest benefit that the “everything is a plugin” design philosophy gives to users.