Agent Harness Design Patterns: From Architecture Layers to Framework Selection
The same model can behave very differently once it is wrapped in different Agent frameworks. This article explains why that happens, breaks an Agent Harness into four responsibility layers, compares four common framework design patterns, and outlines four practical dimensions for choosing or building one.
Why the Same Model Can Produce Very Different Agents
A common mistake when building agent applications is to attribute results entirely to the model. In practice, connecting the same large model to agent frameworks built with different design ideas can produce agents with clearly different behavior, capability boundaries, and stability.
The reason is that a model is essentially a machine that takes text in and produces text out: it reads tokens and generates tokens. It is stateless, does not update itself, and does not remember past interactions. What actually determines an agent’s capabilities is the engineering layer wrapped around the model. The industry usually calls this layer a Harness—originally meaning the gear that lets a horse pull a load. A model needs a Harness before it can do useful work.
A complete agent can be abstracted into two parts:
Agent = model weights (inference core) + Agent Harness (capability shell)
The Harness handles everything outside the model: assembling prompts, parsing and executing tool calls, maintaining conversation context, setting safety guardrails, and managing retries and fallbacks. The model handles inference; the Harness connects inference results to the real world.
Core Responsibility Layers of a Harness
A mature Harness usually includes the following layers of responsibility.
1. Context management
- Prompt templates and assembly: combine system instructions, conversation history, tool descriptions, and retrieval results into model input in a defined order.
- Session persistence: save, compress, and truncate multi-turn conversation state so the context window does not overflow.
- Memory: distinguish short-term memory (the current session) from long-term memory (knowledge retained across sessions).
2. Tool execution
- Tool registration and description generation: convert function signatures into schemas the model can understand.
- Parameter validation and error fallback: parameters generated by the model cannot be trusted and must be validated before execution.
- Execution isolation: high-risk actions such as file operations and code execution should run in a sandbox.
3. Control loop
An agent is fundamentally a loop: the model produces output, intent is parsed, a tool is executed, the result is written back, and the model is called again. Termination conditions, a maximum step limit, and infinite-loop detection all belong in this layer. A schematic pseudocode version looks like this:
while step < max_steps:response = llm.generate(context)if response.is_final_answer:return response.textresult = execute_tool(response.tool_call) # validate and run in a sandboxcontext.append(result)
4. Safety guardrails
This layer covers input filtering, output review, human confirmation for sensitive operations, and least-privilege access. How complete the guardrails are directly determines how far the agent can be trusted.
Four Typical Framework Design Patterns
Comparing current mainstream open-source frameworks—based on fixed version snapshots, because these projects change quickly—suggests four representative design orientations.
Pattern 1: Minimal. Some frameworks deliberately keep the codebase very small and retain only the core loop and tool calling, so users can read every line. These frameworks are common in teaching settings and can be small enough to fit in a single book. Their value is not production readiness, but helping developers understand what it actually means to write a Harness. Every agent developer should read at least one minimal implementation carefully. Much of the complexity in production frameworks is layered on top of this base.
Pattern 2: Shared server architecture. One shared service process serves multiple clients. The advantage is centralized state and upgrades that only change the server. The cost is higher deployment complexity, plus extra design for session isolation under concurrent clients. This fits teams that want multiple tools to connect through one shared service.
Pattern 3: Skill memory. While completing tasks, the agent stores verified procedures as reusable skills in a memory system and calls them directly the next time it sees a similar task. This is an engineering way to attach a continuously growing skill library to a stateless model and address the fundamental limit that the model itself does not learn.
Pattern 4: Multi-channel access. The focus is the connector ecosystem: connecting to many messaging channels at once, such as instant messaging, email, and webhooks, and distributing the same agent across many user touchpoints. The design emphasis is channel adaptation and session routing, not inference orchestration.
Four Dimensions for Choosing a Framework
When selecting a framework, do not look only at the feature list. Evaluate it systematically along these dimensions:
- Code size and readability. A smaller codebase is easier to audit and customize. A larger one often means stronger built-in capabilities, but also higher cost when something goes wrong.
- Extension points. Whether tool registration, memory storage, and model integration are decoupled determines the cost of further development.
- Guardrail completeness. Built-in permission control, execution isolation, and audit logs directly affect whether the agent can be deployed safely.
- Context strategy. For long-running tasks, context compression and persistence often affect the final result more than the choice of model.
Closing Thoughts
Beyond model capability, the Harness can influence the final result as much as the model itself, and sometimes more. Teams with customization needs are on firmer ground if they start with a minimal framework to understand the principles, then evaluate or build a Harness using the four dimensions above, rather than simply adopting an existing framework. In enterprise practice, general cloud capabilities such as object storage, message queues, and logging services can also carry the Harness requirements for memory persistence, asynchronous tasks, and observability, so effort can stay focused on the orchestration logic that is actually tied to the business.
