AI Agent Harness Design: A Breakdown of the Four Core Framework Patterns

    This article breaks down the concept of an agent harness and explains why it matters as much as the underlying model. It compares four common open-source framework patterns—minimalist educational, shared-service, memory-enhanced, and multi-channel—then details the four core modules of any harness: prompt assembly, tool execution, state persistence, and safety guardrails. It closes with practical guidance on choosing a framework by working backward from your constraints.

    AI Agent Harness Design: A Breakdown of the Four Core Framework Patterns

    1. Why the Same Model Produces Four Different Agents

    Put the same large language model into four different agent frameworks and you get four agents with completely different behavior. One takes a minimalist path, doing only the core reasoning and tool calls. One uses a shared service to connect multiple clients at once. One writes newly learned skills back into long-term memory. And one plugs into more than thirty chat channels.

    This is not a question of model capability. It is a question of the harness.

    A large model is essentially a machine that takes text in and puts text out: it reads tokens and generates tokens. It is stateless by itself, does not self-update, and cannot remember what happened in the previous session. To make it actually do work, you have to add memory, tools, session management, permission constraints, and other capabilities around it so it can interact with the world beyond tokens.

    As a result, any agent can be split into two layers:

    • Model layer (model weights): responsible for reasoning and generation, with a capability ceiling set by the weights.
    • Harness layer (agent harness): responsible for assembling prompts, executing tools, saving sessions, setting safety guardrails, and translating the tokens the model emits into real actions.

    The word “harness” originally refers to a horse’s tack. A horse needs a harness to pull a cart; a model needs a harness to do work. Throughout this article, “harness” and “framework” refer to the same kind of thing.

    One often-underestimated fact: the harness affects the final result as much as the model itself, and in some scenarios even more. Two teams using the same base model can end up with one building a stable, production-grade agent and the other building a demo-only toy—and the difference lies almost entirely in the harness.

    2. Four Abstract Patterns of Harness Design

    Setting aside specific implementations, the open-source agent frameworks on the market can be roughly grouped into four design orientations. They differ enormously in code size, number of dependencies, and level of abstraction. The most intuitive comparison is lines of code: an educational framework has only a few hundred lines because it needs to fit inside a book explaining the principles, while a production-oriented framework often has tens of thousands of lines—and most of that code is not about “reasoning” but about connectivity, state, and governance.

    1. Minimalist Educational: Exposing the Skeleton of the Harness

    The goal of this kind of framework is not to be handy but to be readable. It usually keeps only a single loop:

    1. messages = [system_prompt]
    2. while True:
    3. reply = model.generate(messages) # model reasoning
    4. if reply.tool_calls:
    5. results = [run_tool(c) for c in reply.tool_calls]
    6. messages += [reply, *results] # feed tool results back
    7. continue
    8. return reply.text # end when there are no tool calls

    Its value is that it makes one thing clear: an agent is essentially a “reason—call—feed back” loop, and everything else is engineering hardening.

    2. Shared-Service: One Server, Multiple Clients

    The second pattern splits the harness into a persistent server plus lightweight clients. The server holds session state, the tool registry, and the scheduling queue, while the client is only responsible for rendering and input. The direct benefit is that multiple terminals can share the same context and skill configuration, sessions do not break when a client closes, and permissions and auditing can be centralized. The cost is that you must handle concurrency, state consistency, and failure recovery.

    3. Memory-Enhanced: Writing Experience Back into the System

    The key design of the third pattern is skill accumulation. When the model works out a viable solution during a task, the framework saves that workflow in a structured form, and later retrieves and reuses it when it encounters a similar task instead of reasoning from scratch. It helps to distinguish three kinds of “memory”:

    • Short-term memory: the message window of the current session.
    • Working memory: intermediate artifacts and plans produced during a task.
    • Long-term memory: cross-session preferences, facts, and reusable skills.

    The difficulty has never been “storing” but what to write, when to write, and how to avoid pollution. Writing the wrong experience makes an agent fail consistently.

    4. Multi-Channel Access: Turning the Agent into a Service Entry Point

    The fourth pattern focuses on “reach.” A unified message abstraction layer smooths over the differences between chat channels, so the agent only needs to implement its logic once to work across multiple channels. The engineering focus therefore shifts to message deduplication, session routing, rate limiting, and identity mapping.

    3. The Four Core Modules of a Harness

    Regardless of the pattern, a harness is built from four blocks.

    Prompt assembly: how the system prompt, tool descriptions, message history, and retrieved snippets are ordered and trimmed directly determines how the model allocates attention. In practice, put stable rules first and volatile data last, and summarize and compress history rather than hard-truncating it.

    Tool execution: this includes tool description quality, parameter validation, timeouts and retries, and idempotent design. If a tool description is vague, the model will pick the wrong tool; without a timeout, a single hang can stall the entire loop.

    State persistence: session and task state are externalized to reliable storage so the service can resume after a restart. Production environments typically rely on general cloud capabilities such as object storage, message queues, and logging services rather than keeping everything in process memory.

    Safety guardrails: on the input side, detect intent and injection; on the output side, block sensitive information and dangerous actions; on the tool side, enforce least privilege and human confirmation. Guardrails should be “configurable and observable,” not hard-coded.

    4. How to Choose: Work Backward from Constraints

    Do not start by asking “which framework is the strongest.” Instead, work backward in this order:

    1. Interaction model: single-turn tasks, multi-turn conversation, or multi-channel service?
    2. State requirements: can sessions be lost? Is cross-session memory needed?
    3. Tool risk: does it involve write operations, money, or production changes? The higher the risk, the more weight guardrails and auditing carry.
    4. Team maintenance cost: fewer dependencies mean more control; thicker abstractions are easier to use but harder to debug.

    A sound approach is: first use the minimalist pattern to get the loop working end to end, validate your prompt and tool design, then gradually introduce shared services, memory, and multi-channel capabilities. Choosing a heavy framework first, the other way around, often means spending a lot of time adapting to the framework instead of polishing results.

    5. Conclusion

    The model sets the capability ceiling; the harness determines how much of that ceiling is actually realized. Understanding the main thread of “reasoning—tools—memory—guardrails” is more valuable in the long run than memorizing how to use any specific framework. When building agent applications on platforms such as Baidu AI Cloud, it is likewise advisable to treat the harness as a first-class design concern: externalize state, apply least privilege to tools, and make guardrails observable—only then can an agent move from demo to production.