Harness Architecture for Multi-Agent Systems: Design Practices

    This article explains why engineering infrastructure often lags behind rising agent autonomy, and how a four-layer Harness architecture addresses that gap. It breaks down the Knowledge, Orchestration, Gating, and Governance layers, covering trusted memory, explicit collaboration contracts, default-deny access control, and closed-loop governance. Readers will find practical design principles, JSON and pseudocode examples, common anti-patterns, and a suggested rollout sequence for building a controllable agent runtime.

    1. Background: Why Infrastructure Falls Behind as Autonomy Grows

    Over the past two years, agents have shifted from “passive responders” to “active executors.” A typical setup runs in a highly authorized environment: the agent scans information sources on a schedule, organizes a calendar, runs batch jobs overnight, and pushes a summary in the early morning. Through memory and accumulated experience, it continuously adapts to individual preferences, delivering far more perceived value than traditional question-and-answer interaction.

    But greater autonomy means a larger risk surface. The industry has already seen recurring problems: malicious entries mixed into third-party skill and plugin ecosystems, with a significant share of registry entries judged untrusted; platform-side leaks of credentials and contact details affecting hundreds of thousands of email addresses and millions of tokens; and exploit chains that can trigger in milliseconds, where simply visiting a malicious page is enough for an agent to be taken over. These cases point to one conclusion: once an agent becomes an independent execution entity, gaps in engineering governance are amplified sharply.

    The deeper conflict is a difference in pace: model capabilities iterate far faster than the engineering infrastructure built around them. Expanding model capabilities “absorb” functions that once belonged to the engineering layer, such as intent understanding, simple planning, and format conversion, while the traditional software paradigm is being reshaped by an AI-native one. As a result, the engineering side must answer three questions:

    • How to improve adaptability to changing model capabilities, avoiding a full rewrite every time the model changes;
    • How to cushion the impact of model capability leaps so the system stays stable when capability boundaries shift;
    • How to support continuous operation and governance of agents, rather than delivering a one-off demo.

    The answer proposed here is to abstract the “agent runtime” into an independent Harness layer, using a four-layer decoupled design: Knowledge, Orchestration, Gating, and Governance.

    2. How Model Evolution Changes Engineering Constraints

    An agent’s decision core comes from the model, so architecture design must first understand three model-side evolution tracks:

    1. Context and memory: larger context windows and mature retrieval and compression techniques turn “long-term memory” from an engineering patch into a system component, but they also introduce memory pollution and the entrenchment of incorrect experience.
    2. Tool use and structured output: function calling and structured schema output are stabilizing, allowing the engineering side to converge the “action space” into a verifiable set of interfaces rather than free text.
    3. Reasoning and planning: stronger multi-step reasoning makes long-chain tasks feasible, but also lengthens the distance errors propagate, where a single misjudgment can amplify into a systemic incident.

    The conclusion is direct: the stronger the model, the less the engineering side should make “smarter guesses,” and the more it should enforce “stricter constraints and more complete records.” That is the role of the Harness: not to replace model decisions, but to provide boundaries, context, feedback, and auditing for them.

    3. Four-Layer Decoupled Architecture Overview

    The architecture has four layers that communicate through explicit contracts, and any layer can be replaced and rolled out gradually on its own.

    • Knowledge layer: provides “trusted context,” including long-term memory, task knowledge, tool descriptions, historical experience, and policy documents.
    • Orchestration layer: handles task decomposition, role assignment, message routing, concurrency, and retries, deciding “who does what and when.”
    • Gating layer: handles admission and release, including permission checks, action risk classification, human confirmation, output validation, and rollback points.
    • Governance layer: handles observability, evaluation, auditing, cost control, and version evolution, forming a closed loop.

    Key design principles: the Knowledge layer is read-only first, the Orchestration layer is stateless first, the Gating layer defaults to deny, and the Governance layer keeps data immutable.

    4. Knowledge Layer: Making “Trusted” a Computable Property

    The Knowledge layer is the easiest to lose control of, because it carries both memory and experience, and both can be polluted. Implementation recommendations:

    • Layered memory: separate short-term session memory, mid-term task state, and long-term preference profiles; apply different write thresholds and expiration policies to each layer.
    • Source tagging and confidence: each knowledge item carries its source, time, confidence, and applicable scope, and retrieval weights results by confidence.
    • Gated writes: experience cannot be written to the store automatically in full; it must pass validation, deduplication, conflict detection, and gradual trial.
    • Rollback support: knowledge items support versioning and bulk rollback, avoiding “one wrong lesson misleading the system for a long time.”

    Example structure:

    1. {
    2. "id": "kb_1024",
    3. "type": "preference | task_fact | tool_spec | lesson",
    4. "source": "user_confirm | tool_result | offline_eval",
    5. "confidence": 0.82,
    6. "scope": {"user": "u_1", "domain": "inbox_triage"},
    7. "ttl_days": 180,
    8. "revision": 3
    9. }

    5. Orchestration Layer: Stability in Multi-Agent Collaboration Comes from Contracts

    Multi-agent failures usually are not because “the model is not smart enough,” but because collaboration protocols are vague. Make orchestration an explicit state machine with clear contracts:

    • Minimal roles: planner, executor, reviewer, and retriever each have a single responsibility, avoiding overlapping role semantics that lead to buck-passing.
    • Message contracts: messages include the goal, constraints, input references, expected output schema, and deadline; free-form paraphrasing is prohibited.
    • DAG-first: default to DAG orchestration, introducing restricted loops only when necessary, with a maximum iteration count and budget cap.
    • Idempotency and retries: tool calls carry an idempotency key, and retries must be able to determine side effects, avoiding duplicate orders or duplicate sends.

    Example (pseudocode):

    1. plan = planner.submit(goal, constraints, budget=Budget(tokens=80_000, steps=12))
    2. for node in dag.topological(plan):
    3. result = executor.run(node, contract=node.output_schema, idem_key=node.id)
    4. if not gate.allow(node, result):
    5. return gate.escalate(node, result) # human confirmation or termination
    6. memory.commit(node.lesson, confidence=0.6) # commit lessons at low confidence first

    6. Gating Layer: Default Deny Is the Security Baseline

    The Gating layer turns “capability” into “usable capability.” Core mechanisms:

    • Action risk classification: classify actions into read-only, reversible write, irreversible write, outbound send, and credential-related; higher levels require stronger controls.
    • Least privilege and time-bound authorization: scope authorization by task, time window, and resource range, and revoke it when the task ends.
    • Human confirmation points: irreversible and cross-boundary actions require mandatory confirmation, and the confirmation must include a preview of the impact scope.
    • Two-way input and output validation: the input side guards against prompt injection and malicious content, while the output side performs schema validation, sensitive-data masking, and link and attachment allowlisting.
    • Circuit breaking and rollback: define three circuit-breaker conditions based on error rate, abnormal step frequency, and budget consumption, and retain snapshots for rollback.

    It must be emphasized that gating cannot be replaced by “prompt constraints”; it must be deterministic interception at the code level.

    7. Governance Layer: Observable, Evaluable, and Evolvable

    The Governance layer determines whether the system can operate long term, and should cover at least five capabilities:

    • Full-chain tracing: link planning, tool calls, gating decisions, and final output by task ID to form a replayable trace.
    • Evaluation system: an offline evaluation set plus online sampling evaluation, with metrics including task success rate, unauthorized-action interception rate, human intervention rate, per-task cost, and latency.
    • Auditing and compliance: retain records of key decisions, use immutable storage, and define retention policies and access control.
    • Cost governance: set budgets by role and task, and route models by tier (simple tasks to lightweight models, complex tasks to stronger models).
    • Version evolution: roll out the four change types (model, prompt, tool, and knowledge) gradually, supporting A/B testing and fast rollback.

    8. Experience Distillation and the Continuous Governance Loop

    Feed governance results back into the Knowledge layer to form a closed loop:

    1. Collect failure and human-correction samples;
    2. Reproduce them offline and attribute them to a specific layer among Knowledge, Orchestration, Gating, or the model;
    3. Generate candidate experience items, commit them at low confidence, and roll them out gradually;
    4. After online metrics validate them, raise their confidence or roll them back;
    5. Periodically clean up expired and conflicting knowledge to prevent memory bloat.

    9. Common Anti-Patterns

    • Using an overly long prompt to carry all constraints, making the system untestable and unauditable;
    • Letting an agent directly hold long-term, high-privilege credentials;
    • Automatically committing all experience to the store, with no conflict detection or rollback;
    • Too many multi-agent roles and free-text messages, causing cost and latency to spiral;
    • Having only logs but no trace, making incidents impossible to attribute.

    10. Conclusion

    The engineering focus for high-autonomy agents has shifted from “making them more capable” to “making them do things in a manageable and controllable way.” The value of the four-layer decoupling is that the model can be swapped, tools can be added, and knowledge can be revised, while the system’s security boundaries and operational loop stay stable. If an enterprise wants to build its own agent foundation on top of common cloud capabilities such as container platforms, message queues, object storage, logging services, and monitoring and alerting, it can implement the Gating and Governance layers first, then gradually improve Knowledge and Orchestration. This path usually offers the best return on investment.