Harness Engineering: Designing Runtime Frameworks for Autonomous Agents

Preface

Once models are wired into the toolchain, many teams still operate in a Q&A style: the task ends, context is cleared, and the next round starts from scratch. Once you want an Agent to run research loops in the background, iterate on drafts repeatedly, or prepare PRs automatically, the problem shifts: which files should it modify, who gets to define the score, how failures roll back, and whether execution can resume after state is compacted into context. Single-turn conversations with a human in the loop can work; when runs last hours or days, missing a clear control plane leads to self-serving evaluation, lost logs, or silently executed irreversible actions.

Below we introduce the harness-engineering Skill: it does not teach you how to write prompts; it teaches you how to design the harness around an Agent—the surfaces it is allowed to edit, locked evaluations, persistent logs, novelty gates, and human approval boundaries.

What This Is

harness-engineering is a Skill in the repository Agent Skills for Context Engineering, maintained as part of that open-source collection (muratcankoylan). The official description summarizes it as: a practice for designing autonomous agent harnesses—research loops, evaluation scaffolding, locked vs editable surfaces, persistent logs, novelty gating, pruning, rollbacks, PR preparation, and human approval boundaries.

In the Agent Skills open format, a Skill is typically a directory containing SKILL.md (with name, description, and operating instructions); clients progressively load it via “discover → activate → execute,” reading the full text only when a task matches the description. The positioning of this Skill is: the harness is the dividing line between “a useful one-off session” and “long-running autonomy that doesn’t break the objective.”

Core Capabilities

The following capabilities are drawn from the official Skill text and organized by concept.

Harness Boundary

The Agent proposes actions; the harness defines allowed surfaces, how feedback is delivered, persistence, and promotion rules. The official text names four surface types:

Surface Examples Rules
Locked Evaluation metrics, rubrics, validation scripts, merge policies Readable; modifications can be proposed, but the Agent cannot use altered rules to grade itself
Editable Skill drafts, experimental files, prompts/configs under test Changeable within the loop
Append-only Result logs, research threads, rejected ideas Can only be appended; history cannot be rewritten
Human-controlled Merges, production deployments, credentials, destructive operations Require explicit human approval

Tight Feedback Loops

Autonomy depends on fast feedback, clear semantics, and resistance to gaming. The material cites Karpathy’s autoresearch as a minimal pattern: one editable file, one locked evaluation file, a fixed wall-clock budget, a single scalar metric, git rollback, and a persistent results log. The point is not “only one metric,” but vague feedback leads to vague autonomous behavior. For open-ended research-to-Skill work, you can replace the single scalar with locked rubrics, deterministic structural checks, source traceability, and human review thresholds.

Durable State

Long-running Agents must externalize state to files so they can recover after context compaction. The material references Prime Intellect’s autonomous nanoGPT work, where THREAD.md-style drafts and logs aid recovery, monitoring, and auditing. Append-only logs should record: what was attempted, why it succeeded or failed, reasons for keeping/discarding/escalating candidates, upstream sources consulted, and what the next Agent should do.

Search Discipline

The official text lists six explicit rules: refresh upstream sources on a schedule; run novelty checks before committing large budgets; retain rejected attempts to avoid rediscovering them; apply leave-one-out pruning when stacking multiple components; reward simplification when quality is equal; validate changes in isolation before promotion.

Mechanism Registry

Research-to-Skill systems should track “accepted mechanisms” separately from prose explanations. Mechanism records should include a stable mechanism_id, owning_skill, status, activation scenarios, behavioral changes, evidence, and failure modes. Novelty gating should first compare against this registry, then consider broader corpus overlap—keyword overlap can miss “paraphrased duplication,” whereas mechanism comparison captures true redundancy.

Governance

Autonomous Agents can draft changes, run checks, and write PR summaries, but must not merge, deploy, or push without explicit human authorization (unless the user separately authorizes that action).

Two Typical Loops

Autoresearch style (optimizing artifacts against a stable evaluator):

read locked context -> choose hypothesis -> edit allowed surface -> commit/checkpoint
-> run evaluator -> log result -> keep if better -> discard or rollback if worse
-> repeat

Requirements: the evaluator lives outside the editable surfaces; feedback cadence is comparable; failures leave an audit trail; rollback is low-cost; there are strategies for crashes and timeouts.

Research-To-Skill style (sources become Skill changes):

discover -> retrieve -> gate -> score -> extract mechanism
-> map to existing or new skill -> draft proposal -> validate structure
-> prepare PR -> human review

Locked evaluation = source rubric + Skill-change rubric + structural checks + reviewer approval; editable artifact = the proposed Skill delta.

Metric Gaming Resistance

Optimizing Agents learn the harness. Guard against: self-approval after altering evaluation code/rubrics; padding verbose content to appease a judge while harming activation; citing sources that were never retrieved; maximizing aggregate scores while missing key dimensions; hiding failures in logs. Mitigations: lock rubrics per round, report scores by dimension, require retrieval evidence, retain rejected attempts, and route governance changes through human review.

Monitoring Agent

For long runs, a read-only monitoring Agent can output: the current best candidate, active tasks/drafts, last upstream refresh, failed or stale loops, inconsistencies between logs and claimed state, next steps and blockers—unless explicitly authorized, the monitoring side should not write to editable surfaces.

Design Checklist and Directory Layout

The official eight-step checklist: a one-sentence objective; four surface types; feedback mechanisms (scalar/rubric/deterministic tests/human review or a combination); keep/discard/crash/timeout/escalation states; create a persistent thread log before starting the loop; add source refresh, mechanism registry novelty checks, and pruning for long runs; define what can be done without asking vs what requires approval; validate the harness with one good and one bad artifact.

Recommended directory:

research-run/
  THREAD.md
  sources/
    queue.md
    evaluations/
  proposals/
  logs/
    results.tsv
    rejected.md
  drafts/

Use TSV or JSONL for machine-readable logs; Markdown for handoffs and review summaries.

When to Use It, When Not To

Suitable for activation (official “When to Activate”):

  • Building autonomous research or experimentation loops
  • Designing Agent environments with locked metrics and editable code/content
  • Producing PRs or background Agents
  • Assessing whether an Agent can run safely with minimal human interruption
  • Adding novelty checks, ablations, pruning, rollbacks, or persistent logs to workflows
  • Preventing Agents from gaming benchmarks, weakening rubrics, or losing state after compaction

Do not use it as a replacement for (handled by adjacent Skills):

  • Quality gates, regression suites, or outcome metrics without an autonomous control plane → evaluation
  • Harness tool patterns, response formats, and recovery errors → tool-design
  • Project-level task-model matching, pipeline shapes, and cost → project-development
  • Remote sandboxes, warm pools, and hosted session infrastructure → hosted-agents

Installation and Activation

This Skill ships with the official repository, at skills/harness-engineering/ (containing a SKILL.md that conforms to the Agent Skills specification).

The general mechanism for Agent Skills (agentskills.io) is: at startup, clients load only each Skill’s name and description; when a task matches the description, they read the full instructions and execute. How to mount this directory into Cursor, Codex CLI, or Claude Code depends on each client’s documentation; no unified installation command is provided in the captured material, so no configuration or version numbers are invented here.

In clients that support Skills, ensure the harness-engineering description is discoverable; when a task involves “autonomous harnesses, research loops, locked evaluation surfaces, rollbacks, and approval boundaries,” activation should be triggered and the checklists and loop patterns in SKILL.md should be followed.

Typical Usage (Official Examples)

Example 1: Locked metrics
An Agent optimizes train.py, but prepare.py handles data loading and evaluation. The Agent may change the model, not the metric; failed experiments are logged and rolled back.

Example 2: Locked rubric
An Agent evaluates new engineering articles, but the source curation rubric is locked for the current round. After a source passes, it drafts a Skill proposal; it cannot lower rubric thresholds to force unqualified sources through.

Example 3: Auto PR, no auto-merge
After checks pass, the Agent prepares a branch and PR description; merging remains a Human-controlled surface requiring human approval (the material ends here; the semantics align with the Governance section).

When designing a new harness, start by mapping the four surface types via the checklist, then choose the Autoresearch or Research-To-Skill loop, and set up THREAD.md and logs/results.tsv before starting the loop.

Use Cases and Caveats

This fits teams that need multi-day autonomous operation without ceding evaluation authority to the Agent: experiment automation, research-to-PR pipelines for Skills/docs, and background coding Agents that modify code and prepare PRs. Limitations: harness design itself is engineering; boundaries with evaluation, tool-design, and similar Skills must be kept clear to avoid mixing general evaluation or tool contracts into one Skill.

Beware anti-gaming: any “editable scoring logic” becomes an attack surface; long runs must maintain append-only logs and a mechanism registry, otherwise auditing after compaction is difficult. Human approval boundaries must be hard-coded in the harness, not left to model self-discipline.

Wrapping Up

harness-engineering moves autonomous Agents from the “single-session” paradigm common in conversational products to “long-running loops with a control plane”: what to lock, what to edit, what to record, when to roll back, and who says yes should all be designed in the harness up front. For the full instructions and examples, see the official directory:

https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/harness-engineering

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye