Agent Harness

The outer execution environment (framework and scaffolding) that runs an LLM as a practical autonomous agent. Manages system prompts, tool invocations (file edits and shell commands), turn loops, and sandbox protection.

General Meaning

A large language model by itself is merely an inference engine that probabilistically predicts the next token from an input string. On its own, it cannot edit files, run test suites, or autonomously drive multi-turn workflows.

An Agent Harness is the outer wrapper program that surrounds an LLM and turns it into an autonomous agent. It injects system prompts, defines tools and mediates their execution results, controls conversation loops, enforces sandbox access boundaries, and records execution logs—represented by tools like Claude Code, Codex CLI, Cursor CLI, OpenClaw, Hermes, and Goose.

Why It Matters

  • Enabling LLMs to operate real-world OS tools: Provides file read/write, code search, compilation, and test execution tools so the LLM can complete end-to-end engineering tasks.
  • Enforcing permissions and safety boundaries: Restricts AI operations to designated working directories or sandboxes rather than granting full OS privileges, preventing accidental damage.
  • Decoupling models from task definitions: Absorbs API and runtime differences across commercial cloud models and local inference engines so the same task can run on different backends.

How the Site Factory Uses It

The Site Factory matches the right harness to each tier: external commercial harnesses (Claude Code claude -p, Codex CLI, Cursor CLI, Antigravity CLI agy) run as KeepAlive workers across machines and fall back to the next provider when quota runs out, while open-source local harnesses (OpenClaw, Hermes, goose) run local models on Studio 1 and Studio 2. In Stage 3 operational comparisons on Studio 2 (96GB), OpenClaw and Hermes are rotated alternately to benchmark real-world task performance.

In ops/watchdog/studio2_runner.py, Mac mini clones the working repository, transfers it to Studio 2, and runs the harness under the measurement exclusion lock (step.lock). The harness itself is never given Git push privileges or secret keys; it only modifies files inside the isolated working copy, and the outer wrapper script creates the draft PR and verification receipt from the returned changes. For routine Tier 1 extraction, the Site Factory skips heavy harnesses altogether and calls the Ollama API directly from lightweight Python scripts to save tokens and memory.

Caveats & Operational Rules

  • Never grant Git push permissions or secret keys directly to a harness: Allowing a harness to push directly to repositories or read secret keys risks severe damage if the agent goes rogue; isolate the harness to a working copy and handle Git and PRs in an outer wrapper.
  • Do not use a heavy multi-turn harness for simple extraction: Applying a 64K-context agent harness to single-shot data extraction wastes tokens on massive system prompts and causes out-of-memory failures on smaller machines (as learned from Hermes failures on Mac mini).

Related Terms

References

  • Book: Chip Huyen, "AI Engineering", Chapter 6 (Agents and Tool Use)

Verified: 2026-11-08