1
---
2
name: harness-engineering
3
description: "This skill should be used when designing autonomous agent harnesses: research loops, evaluation scaffolds, locked and editable surfaces, durable logs, novelty gates, pruning, rollback, PR preparation, and human approval boundaries."
4
---
5
6
# Harness Engineering
7
8
Harness engineering designs the control system around an agent: what it may edit, how it receives feedback, where it writes state, how failures recover, and who can approve irreversible actions. The harness is the difference between a helpful agent session and an autonomous loop that can run for days without corrupting its objective.
9
10
## When to Activate
11
12
Activate this skill when:
13
14
- Building autonomous research or experimentation loops
15
- Designing an agent environment with locked metrics and editable code or content
16
- Creating PR-producing or background agents
17
- Evaluating whether an agent can safely run without frequent human prompts
18
- Adding novelty, ablation, pruning, rollback, or durable logging to an agent workflow
19
- Preventing agents from gaming benchmarks, weakening rubrics, or losing state across compaction
20
21
Do not activate this skill for adjacent work owned by other skills:
22
- General quality gates, regression suites, or outcome metrics without autonomous control surfaces: `evaluation`.
23
- Tool schemas, response formats, and recovery errors for harness tools: `tool-design`.
24
- Project-level task-model fit, pipeline shape, and cost planning: `project-development`.
25
- Remote sandbox, warm-pool, and hosted session infrastructure: `hosted-agents`.
26
27
## Core Concepts
28
29
### Harness Boundary
30
31
Separate the agent from the environment it operates inside. The agent proposes actions; the harness defines allowed surfaces, feedback, persistence, and promotion rules.
32
33
Use four surface classes:
34
35
| Surface | Examples | Rule |
36
| --- | --- | --- |
37
| Locked | Eval metric, rubric, validation script, merge policy | Agent may read and propose changes, but cannot score itself with modified rules |
38
| Editable | Skill draft, experiment file, prompt, config under test | Agent may mutate during the loop |
39
| Append-only | Results log, research thread, rejected ideas | Agent may append, not rewrite |
40
| Human-controlled | Merge, production deploy, credentials, destructive operations | Requires explicit human approval |
41
42
### Tight Feedback Loops
43
44
Autonomy works when feedback is fast, unambiguous, and hard to game. Karpathy's `autoresearch` is the minimal pattern: one editable file, one locked evaluation file, fixed wall-clock budget, one scalar metric, git rollback, and a durable results log. The lesson is not that every harness needs one metric; it is that ambiguous feedback creates ambiguous autonomy.
45
46
For open-ended research-to-skill work, replace the scalar metric with locked rubrics, deterministic structure checks, source traceability, and human review thresholds.
47
48
### Durable State
49
50
Long-running agents must externalize state. Store plans, source queues, results, failures, and handoffs in files so future agents can resume without relying on chat history. Prime Intellect's autonomous nanoGPT work showed the value of durable scratchpads and `THREAD.md`-style logs for recovery, monitoring, and audit.
51
52
Use append-only logs for:
53
54
- What was tried
55
- What improved or failed
56
- Why a candidate was kept, discarded, or routed to review
57
- Which upstream sources were checked
58
- What the next agent should do
59
60
### Search Discipline
61
62
Agents tend to exploit the nearest surface, stack complexity, and under-run pruning. Add explicit search rules:
63
64
1. Refresh upstream sources on a schedule.
65
2. Require novelty checks before spending large budgets.
66
3. Preserve rejected attempts to avoid rediscovery.
67
4. Run leave-one-out pruning when a stack has multiple additions.
68
5. Reward simplification when quality is equal.
69
6. Use separate verification before promotion.
70
71
### Mechanism Registry
72
73
For research-to-skill systems, track accepted mechanisms separately from prose. A mechanism record should include a stable `mechanism_id`, `owning_skill`, `status`, activation scenario, behavior change, evidence, and failure modes. Novelty gates should compare against this registry before using broader corpus overlap, because keyword overlap catches stale phrasing while mechanism comparison catches real duplication.
74
75
### Governance
76
77
Autonomous agents may prepare PRs, but governance must be explicit. They can draft changes, run checks, and write PR summaries. They should not merge, deploy, or push without human approval unless the user has explicitly granted that permission for the specific action.
78
79
## Detailed Topics
80
81
### Autoresearch-Style Loop
82
83
Use this pattern when optimizing an artifact against a stable evaluator:
84
85
```text
86
read locked context -> choose hypothesis -> edit allowed surface -> commit/checkpoint
87
-> run evaluator -> log result -> keep if better -> discard or rollback if worse
88
-> repeat
89
```
90
91
Required properties:
92
93
- The evaluator is outside the editable surface.
94
- The feedback cadence is fixed enough to compare attempts.
95
- Failed attempts leave an audit trail.
96
- Rollback is cheap.
97
- The agent has a policy for crashes and timeouts.
98
99
### Research-To-Skill Loop
100
101
Use this pattern when sources become skill changes:
102
103
```text
104
discover -> retrieve -> gate -> score -> extract mechanism
105
-> map to existing or new skill -> draft proposal -> validate structure
106
-> prepare PR -> human review
107
```
108
109
The locked evaluator is a combination of source rubrics, skill-change rubrics, structure checks, and reviewer approval. The editable artifact is the proposed skill delta.
110
111
### Metric Gaming Resistance
112
113
Assume an optimizing agent will learn the harness. Guard against:
114
115
- Editing evaluation code or rubrics and then using the new version for self-approval
116
- Adding verbose content that pleases a judge but harms skill activation
117
- Citing unretrieved sources
118
- Optimizing aggregate scores while failing a critical dimension
119
- Avoiding failed results in the log
120
121
Mitigation: lock rubrics per run, report per-dimension scores, require source retrieval evidence, preserve rejected attempts, and route governance changes to human review.
122
123
### Monitoring Agents
124
125
Use monitoring agents for long runs, but restrict them to read-only reporting unless explicitly tasked otherwise. Monitoring output should report:
126
127
- Best current candidate
128
- Active jobs or drafts
129
- Last upstream refresh
130
- Failed or stale loops
131
- Disagreements between logs and claimed state
132
- Next action and blocker
133
134
## Practical Guidance
135
136
### Harness Design Checklist
137
138
1. Define the objective in one sentence.
139
2. Identify locked, editable, append-only, and human-controlled surfaces.
140
3. Choose the feedback mechanism: scalar metric, rubric, deterministic tests, human review, or combination.
141
4. Define keep, discard, crash, timeout, and review states.
142
5. Create a durable thread log before the loop starts.
143
6. Add source refresh, mechanism-registry novelty, and pruning rules for long-running loops.
144
7. Define what the agent may do without asking and what requires approval.
145
8. Validate the harness on one known good and one known bad artifact.
146
147
### File Layout
148
149
```text
150
research-run/
151
THREAD.md
152
sources/
153
queue.md
154
evaluations/
155
proposals/
156
logs/
157
results.tsv
158
rejected.md
159
drafts/
160
```
161
162
Use TSV or JSONL for append-only machine-readable logs. Use Markdown for handoffs and reviewer-facing summaries.
163
164
## Examples
165
166
**Example 1: Locked metric**
167
168
An agent optimizes `train.py`, but `prepare.py` owns data loading and evaluation. The agent can edit the model but cannot change the metric. Failed experiments are logged and rolled back.
169
170
**Example 2: Locked rubric**
171
172
An agent evaluates a new Anthropic or OpenAI engineering post, but the source curation rubric is locked for the run. If the source passes, the agent drafts a skill proposal. It cannot lower the rubric threshold to admit the source.
173
174
**Example 3: Auto-PR without auto-merge**
175
176
An agent prepares a branch and PR body after passing source, skill, and structure checks. The PR states unresolved risks and waits for human merge approval.
177
178
## Guidelines
179
180
1. Lock evaluators before starting the loop.
181
2. Keep editable surfaces narrow enough for reliable diffs.
182
3. Write durable logs before context compaction can erase state.
183
4. Report per-dimension scores instead of only aggregate scores.
184
5. Require source retrieval before citation.
185
6. Add novelty gates for broad search and pruning gates for complex stacks.
186
7. Prefer simplification when quality is equal.
187
8. Separate PR preparation from merge authority.
188
9. Revalidate harness changes with old and new evaluators.
189
10. Treat stopped autonomous loops as harness failures, not agent personality quirks.
190
191
## Gotchas
192
193
1. **Mutable evaluator**: If the agent can edit the metric, it may optimize the benchmark instead of the task. Keep rubrics and eval code locked during the run.
194
2. **Chat-only memory**: Long runs fail after compaction when plans live only in conversation history. Write thread logs and result files from the start.
195
3. **No discard record**: Without rejected-attempt logs, agents repeat failed ideas. Preserve failures with enough detail to avoid rediscovery.
196
4. **Complexity accretion**: Agents stack changes and rarely remove them. Require pruning rounds and reward equal-quality simplification.
197
5. **Premature novelty claims**: Agents label recombinations as novel. Compare against existing repo skills, source queue, and rejected logs before claiming novelty.
198
6. **Monitor misreporting**: Monitoring agents can summarize stale or inconsistent state. Require them to cite the files or logs behind claims.
199
7. **Human approval ambiguity**: "Prepare a PR" is not "merge a PR." Make approval boundaries explicit in the harness.
200
8. **Volatile source drift**: Fast-moving lab claims age quickly. Put dated evidence in references and schedule revalidation.
201
202
## Integration
203
204
This skill connects to:
205
206
- evaluation - Rubrics and quality gates provide the locked feedback surface
207
- advanced-evaluation - Pairwise comparison and bias mitigation improve proposal review
208
- filesystem-context - Durable logs, scratchpads, and thread files preserve state
209
- multi-agent-patterns - Researcher, verifier, monitor, and writer agents need isolated contexts
210
- tool-design - Harness tools must expose clear contracts and recovery errors
211
- project-development - File-based pipelines and task-model fit analysis keep loops simple
212
- hosted-agents - Background execution needs sandbox, snapshot, and approval boundaries
213
214
## References
215
216
Internal references:
217
- `researcher/README.md` - Read when implementing the repo-native research-to-skill operating system
218
- `researcher/rubrics/harness-change.md` - Read when evaluating changes to an agent harness
219
- `researcher/runbooks/autonomous-research-loop.md` - Read when running a source-to-skill loop
220
221
External resources:
222
- Karpathy `autoresearch` - Constrained autonomous experiment loop with locked evaluation
223
- Prime Intellect autonomous nanoGPT speedrun - Durable scratchpads, handoffs, monitoring, and autonomy failure modes
224
- AlphaEvolve and FunSearch - LLM-generated candidates paired with systematic evaluators
225
- HELM and LM Evaluation Harness - Transparent, reproducible evaluation infrastructure
226
227
---
228
229
## Skill Metadata
230
231
**Created**: 2026-05-14
232
**Last Updated**: 2026-05-15
233
**Author**: Agent Skills for Context Engineering Contributors
234
**Version**: 1.1.0
235