Agent Architecture Explained: Model and Harness Engineering Practices

    This article breaks down the core architecture of AI agents as the combination of a Model and a Harness. It explains the Harness's four key responsibilities—context management, tool calling, task planning, and file I/O with state persistence—and shows why model capability sets the ceiling while the Harness determines reliability. Readers will find practical patterns for layered context compression, contract-based tool execution, verifiable planning loops with guardrails, versioned delivery workflows, fast base model selection, cluster parallelism, and three-tier evaluation with observability.

    1. Agent Fundamentals: Why Model + Harness

    In current agent engineering practice, a usable agent is not a natural extension of a single model’s capabilities. It is the result of a model and a harness working together. The model handles understanding, reasoning, and generation, while the harness places the model in an executable, observable, and constrained runtime environment. This can be expressed with an abstract formula:

    1. Agent = Model + Harness

    The harness typically takes on four key responsibilities:

    • Context management: deciding what the model “sees,” and how to compress, retrieve, and replay information during long tasks;
    • Tool calling: defining tool contracts, parameter validation, execution orchestration, and result backfilling;
    • Task planning: breaking vague goals into verifiable subgoals and driving the execution loop;
    • File I/O and state persistence: giving the agent continuous working capability across turns and sessions.

    It is important to emphasize that model capability sets the ceiling, while the harness determines the floor and stability. The same base model can show order-of-magnitude differences in task success rate and latency under harnesses of different quality.

    2. Context Management: Engineering the Agent’s “Working Memory”

    Context is the scarcest resource for an agent. In engineering, context is usually divided into three layers:

    1. System layer: role constraints, safety policies, output formats;
    2. Task layer: goals, plans, completed steps, hypotheses to be verified;
    3. Evidence layer: tool returns, retrieval snippets, file contents, logs.

    In practice, a strategy of “structured summary plus retention of key source text” is recommended: apply rolling summaries to historical steps, retain source text for evidence strongly related to the current subgoal, and attach source identifiers and timestamps for traceability. An illustrative structure is shown below:

    1. {
    2. "goal": "Generate a quarterly data brief",
    3. "plan": ["fetch data", "validate", "analyze", "draft"],
    4. "summary": "Data fetching and null handling are done; two metric definition inconsistencies were found",
    5. "evidence": [{"src": "table_03", "ts": "2026-06-01", "snippet": "..."}]
    6. }

    When the context approaches the window limit, layered compression can be used: first compress low-value logs, then compress duplicate retrieval results, and only then make minimal rewrites to plans and constraints. Indiscriminate truncation should be avoided, as it easily causes goal drift.

    3. Tool Calling: From “Able to Call” to “Controllable and Callable”

    Tool calling is the bridge between the agent and real systems. A robust tool layer includes at least four things:

    • Contract-based description: name, purpose, input/output schema, error codes;
    • Parameter validation and normalization: types, ranges, enums, default values;
    • Permissions and sandboxing: least privilege, read-only first, secondary confirmation for dangerous operations;
    • Result backfilling standards: structured returns, truncation policies, human-readable failure reasons.

    Pseudocode example:

    1. def call_tool(name, args, ctx):
    2. schema = registry[name].schema
    3. args = validate_and_normalize(schema, args)
    4. if registry[name].risk == "high" and not ctx.approved:
    5. return {"ok": False, "reason": "need_confirmation"}
    6. try:
    7. out = executor.run(name, args, timeout=ctx.timeout)
    8. return {"ok": True, "data": truncate(out, ctx.max_bytes)}
    9. except Exception as e:
    10. return {"ok": False, "reason": str(e)}

    The key design principle is “explainable, retryable, and rollback-able failures.” A tool failure should not directly terminate the task; instead, it should enter the next planning round as evidence.

    4. Task Planning and Execution Loop: Verifiable Small, Fast Steps

    The goal of the planning module is not to produce a perfect solution in one shot, but to continuously produce “the minimal verifiable next step.” A “plan-execute-verify-revise” loop is recommended:

    1. while not done:
    2. step = planner.next(goal, state)
    3. result = executor.run(step)
    4. state = verifier.update(state, result)
    5. if verifier.failed(state): planner.revise(state)

    Engineering should set three types of guardrails: maximum steps, per-step timeout, and repeated action detection. For long tasks, it is recommended to introduce checkpoints so the agent can recover from the most recent stable state after an abnormal interruption, rather than starting over.

    5. File I/O and Delivery: Making Results Actionable

    An agent’s value is ultimately reflected in its deliverables. File I/O capability needs to distinguish between “intermediate state” and “delivery state”: intermediate state emphasizes rollback capability and versioning, while delivery state emphasizes format standards and consistency validation. Common practices include:

    • Using temporary directories and atomic writes to avoid partial products overwriting official files;
    • Generating a version identifier for each write and keeping diffs for auditing;
    • Validating structure and style for deliverables such as spreadsheets, documents, and presentations before publishing.

    Illustrative flow:

    1. draft -> validate(schema/style) -> publish -> archive(version)

    6. Base Model Selection: Low Latency and Cost Efficiency Take the Lead

    A clear recent industry trend is the “fast model” approach for production-grade agents: emphasizing inference speed, unit cost efficiency, and multi-turn stability, suited to high-frequency, multi-turn, low-wait interaction scenarios. Four metrics are recommended for selection: time to first token, per-turn latency variance, long-context degradation, and tool call success rate. Engineering can adopt “fast-slow tiering”: fast models handle high-frequency small-step decisions, while slow models are involved only in complex reasoning or conflict arbitration, balancing experience and cost.

    7. Cluster Parallelism and Integrated Desktop Delivery

    When tasks can be decomposed, agent cluster parallelism can significantly reduce end-to-end latency. The key implementation points are the “independence” of task splitting and the “determinism” of result merging: each subtask should have a clear input/output contract, and the merging stage needs to handle conflicts and deduplication. Integrated desktop delivery emphasizes the coordination of local files, system capabilities, and cloud computing power, with the core still being permission boundaries and data minimization.

    8. Evaluation and Observability: Turning “Feels Usable” into “Metrics Usable”

    It is recommended to establish three-tier evaluation: unit level (tool contracts and validation), task level (end-to-end success rate and steps), and experience level (wait time and human takeover rate). Observability should cover at least: per-step input summary, tool call chain, failure reason distribution, and context compression count. Only when metrics are quantifiable can harness optimization have direction.

    9. Conclusion

    The engineering essence of an agent is to use the harness to constrain model capabilities into deliverable productivity. By doing solid work around the four main lines of context, tools, planning, and files, combined with low-latency base models and tiered scheduling, one can obtain a stable, controllable, and scalable agent system in real business.