Deep dive · arXiv:2605.18747v1 · 18 May 2026

Code as
Agent Harness

Toward executable, verifiable and stateful agent systems.

A beginner-friendly guide to the paper’s core idea, system taxonomy and practical build path.

Source: Ning et al., Code as Agent Harness, arXiv:2605.18747v1.
01 · TL;DR

The agent gets better when its work becomes executable.

Instead of asking a model to remember everything and declare success in prose, give it a governed workspace where it can write plans, run tools, inspect state, test changes and recover from failure.

01

Executable

Intent becomes a program, tool call, test or workflow that can actually run.

02

Inspectable

Plans, diffs, traces, logs and test results expose what happened between prompt and outcome.

03

Stateful

The system can preserve useful state across steps, sessions, agents and context resets.

The practical shift: build the runtime around evidence, not just generation.
Paper pp. 1–4: abstract, introduction, survey scope and contributions.
02 · Why it matters

Long-horizon autonomy is mostly a systems problem.

Without a harness

A stateless model improvises

It may lose the thread, hallucinate an API, repeat a failed action, or stop because the answer sounds plausible.

With a harness

A controlled system learns from state

It can decompose work, use tools, persist evidence, run checks, route failures and ask for approval at the right boundary.

Model

Judgement

Reason, interpret, propose.

Harness

Control surface

Expose tools, memory, permissions and feedback.

Environment

Evidence

Return observable state, outcomes and constraints.

Paper pp. 2–4 and p. 16: distinction between model capability, harness infrastructure and agent-initiated code.
03 · Benefits and use cases

One idea, many agentic worlds.

The paper uses code as the common interface across environments that look very different on the surface.

Software engineering

Repository state, diffs, tests and CI become the agent’s working world.

Example: resolve an issue, run tests, produce a reviewable patch.

GUI and OS automation

DOM state, accessibility trees, screenshots and executable checks ground actions.

Example: update a record, verify the UI changed as intended.

Scientific discovery

Hypotheses, simulations, lab protocols and analysis pipelines form a program world.

Example: propose an experiment, run the pipeline, inspect results.

Embodied agents

Policies, skills, simulators and sensor feedback connect intent to physical action.

Example: compose a skill, simulate it, then execute under constraints.

Personalisation

Preference state and feedback loops turn recommendations into editable policies.

Example: respect explicit constraints, remember corrections, show rationale.

DevOps and enterprise

Workflows, permissions, approvals and audit logs govern consequential changes.

Example: investigate an incident, propose a change, gate deployment.

Paper pp. 4–6 and 49–61: application domains and emerging fields.
04 · The mental model

Code sits in the loop between intent and evidence.

Agentintent · judgement Harnessplan · tools · memorypermissions · validatorstraces · state Code / toolsexecute · change · inspect Environmenttests · logs · outcomes feedback becomes the next decision
reasoning → executable
action → bounded
state → inspectable
Paper pp. 7–15: Harness Interface; Figure 2 adapted as an original explanatory visual.
02
Section two

Deep dive

From interface, to mechanisms, to a shared substrate for multi-agent systems.

05 · Taxonomy

The paper’s map has three connected layers.

↔
Layer 1

Harness interface

How code connects the model to reasoning, action and environment state.

◌
Layer 2

Harness mechanisms

How planning, memory, tools, control and optimisation sustain execution.

⌘
Layer 3

Scaling the harness

How agents coordinate through shared code, state, feedback and verification.

The unifying question

What must be executable, inspectable and persistent so the system can keep moving without losing control?

Paper pp. 3–6 and Figure 1: the three-layer organisation of the survey.
06 · Layer 1

Three roles for code at the interface.

R

Code for reasoning

Externalise computation into programs, traces, symbolic solvers or proof scripts that can be checked.

Useful when arithmetic, logic, search or intermediate state needs stronger grounding than prose.

A

Code for acting

Translate intent into API calls, GUI actions, robot policies, behaviour trees or reusable skills.

Useful when actions need affordance checks, constraints or feedback-driven retry.

E

Code for environment

Represent repositories, simulators, tests, logs and state transitions as queryable program worlds.

Useful when the agent must inspect what changed and predict what happens next.

The interface is not just a prompt. It is a contract with reality.
Paper pp. 7–16: Sections 2.1–2.3.
07 · Layer 2

Reliability comes from mechanisms, not one clever prompt.

Planning

Decompose, search, structure and orchestrate.

Memory

Manage working state, evidence, experience and shared context.

Tool use

Expose governed APIs, shells, repos, sandboxes and validators.

Control

Turn feedback into bounded state transitions through PEV.

Optimisation

Use telemetry and replay to improve the harness itself.

Design implication

Every mechanism should answer: what state does it read, what state does it change, and what evidence says the change worked?

Failure implication

If the system cannot replay a failure, locate its cause or roll back the change, it is difficult to improve safely.

Paper pp. 16–33: Harness Mechanisms and Agentic Harness Engineering.
08 · The control loop

Use Plan → Execute → Verify as the system’s heartbeat.

P

Make intent explicit

Write the change contract: files, invariants, validation commands, risk tier, rollback point and acceptance criteria.

Ask before acting

What is the smallest safe next transition?
Which evidence must be retrieved first?
What would falsify this plan?
E

Apply a bounded transition

Run the planned actions inside a sandbox with explicit permissions, resource limits and trace capture.

Keep the action observable

Record tool arguments, diffs and outputs.
Persist full logs; summarise only for active context.
Pause or escalate when the risk tier changes.
V

Let evidence decide

Use tests, compilers, linters, static analysis, runtime traces, fuzzers and human review as sensors.

Choose the next state

Accept if the contract is satisfied.
Revise if diagnostics localise a recoverable failure.
Escalate or roll back if evidence is weak or risk is high.
Debugging becomes control over executable state, not a post-hoc repair ritual.
Paper pp. 28–32: Plan–Execute–Verify loop, permission tiers and deterministic sensors.
09 · Memory

Memory is not a bigger context window. It is state management.

Memory layer
Keeps
Best for
Main risk
Working
Current plan, open files, next action
Grounding the next step
Context overload
Semantic
Repo structure, APIs, docs, dependencies
Evidence retrieval
Irrelevant or stale context
Experiential
Past failures, fixes, strategies
Cross-task transfer
Error propagation
Long-term
Validated reusable knowledge
Continual improvement
Drift and contamination
Multi-agent
Shared intentions, artifacts, history
Coordination
Flooding and divergence

Compaction

Keep decision-relevant evidence active while preserving a full-fidelity handle to logs, traces and diffs.

Governance

Store less, but store better: provenance, validation status, freshness and who or what approved it.

Paper pp. 21–24: working, semantic, experiential, long-term and multi-agent memory; context compaction and state offloading.
10 · Agentic Harness Engineering

Once you can observe the harness, you can improve the harness.

Deep telemetrytraces · costs · toolstests · permissions Diagnosefind recurring wasteattribute failure Revisetools · prompts · gatesmemory · topology Replay + promoteheld-out tasks · regressionshuman approval when needed

The paper’s important caveat: harness evolution is a code change to a safety-critical runtime. Every mutation needs a contract, replay, regression checks and a rollback path.

Paper pp. 31–33 and 63: telemetry, Evolution Agents and governed harness mutation.
03
Section three

Scaling the harness

Multi-agent coordination is a shared-state problem before it is a topology problem.

11 · Layer 3

Agents coordinate better when they share artifacts and oracles.

Specialised roles

Manager · planner · coder · reviewer · tester · executor. Each role owns a slice of the workflow, but the substrate keeps them aligned.

The tester should be as independent as possible from the coder to reduce circular validation.

Artifact-mediated interaction

Files, diffs, tests, logs, schemas, blackboards and workflow state are more durable than conversational hand-offs.

The key question is which artefact is authoritative when channels disagree.

01

Plan

Translate intent into obligations.

02

Build

Create or revise the programme.

03

Challenge

Test, fuzz, review or debate.

04

Converge

Accept, revise, merge or escalate.

Paper pp. 34–43: role specialisation, shared code-centric substrate and interaction modes.
12 · Shared state

Four ways to represent the shared harness.

01

Implicit / file-only

Simple and common. But agents reconstruct state from the latest context, so belief can silently diverge from reality.

02

Repository-based

Navigable files, dependencies, call graphs and version history. Stronger structure, still weaker on runtime behaviour.

03

Execution-based

What matters is what the programme does: tests, traces, security findings, performance and simulation results.

04

Blackboard / shared state

A persistent, queryable store that all roles can read and update. Closest to a formal harness substrate.

The paper’s central gap: most systems use code, but few formalise the shared substrate that code creates.
Paper pp. 43–47: shared harness representation and harness-state convergence.
13 · Limits and open problems

Executable feedback helps. It does not make the oracle true.

!

Weak verification

A green test can still miss the real specification, unsafe intermediate actions or scientific validity.

↻

Regression-prone evolution

A harness change can improve a benchmark while weakening safety, cost or rare-case behaviour.

≋

Semantic conflicts

Agents can share files while disagreeing about assumptions, freshness or user intent.

◎

Safety as durable state

Permissions, approvals, denials and corrections should become auditable state, not one-off interruptions.

◉

Multimodal grounding

Screenshots, sensor readings and physical states need persistent evidence, action grounding and calibrated uncertainty.

△

Harness-level evaluation

Measure trajectory efficiency, recovery, state consistency, safety compliance and replayability, not only final success.

Paper pp. 61–66: open problems in evaluation, semantic verification, evolution, shared state, safety and multimodality.
04
Section four

Build it

A practical, governed path from one reliable loop to a reusable harness.

14 · Step-by-step guide

Start with one verifiable workflow.

Choose a bounded task

Pick a workflow with observable inputs, reversible actions and a clear definition of done.

Define the state model

Name the source of truth: files, database rows, issue state, test results, traces or a shared blackboard.

Write the PEV contract

Specify the plan schema, allowed tools, validation checks, stop conditions and escalation rules.

Put execution in a sandbox

Separate read-only inspection, sandbox edits and full-access actions. Capture every transition.

Add independent verification

Prefer deterministic tests, static checks, traces or domain validators. Document what each oracle cannot see.

Replay before you optimise

Build a small golden set, replay failures, and change one harness component at a time.

Implementation guidance synthesised from the paper’s PEV, memory, tool-use, safety and harness-evolution sections. It is a recommendation, not a reported experiment.
15 · Reference architecture

Keep the first harness small enough to inspect.

# a minimal code-centric harness
state/
  task.json          # goal + risk tier
  plan.md            # change contract
  evidence/          # retrieved facts
  traces/            # full-fidelity logs
  approvals.jsonl    # durable gates
workspace/
  repo/              # sandboxed worktree
validators/
  tests/
  static_checks/
  policies/
run.py               # P → E → V loop

Minimal loop

plan = agent.propose(state)
check_plan(plan)

result = sandbox.execute(
  plan.actions,
  permissions=plan.risk_tier
)

evidence = validators.run(result)
state.record(plan, result, evidence)

if evidence.accepted:
    promote(state)
elif evidence.recoverable:
    revise(state, evidence)
else:
    escalate(state, evidence)

The point is not this exact folder layout. The point is that plans, actions, evidence, permissions and approvals are first-class artefacts.

Implementation pattern derived from paper pp. 16, 28–33, 43–47 and 63–64; example code is original synthesis.
16 · Safety by construction

Permission tiers are part of the agent state.

Tier 1 · Read

Observe

Browse files, inspect logs, retrieve documentation, run static analysis.

No external side effects.

Tier 2 · Sandbox edit

Experiment

Patch a disposable worktree, run tests, install temporary dependencies under limits.

Reversible and isolated.

Tier 3 · Full access

Affect reality

Network access, credentials, deployment, publishing, destructive changes or physical action.

Human approval, audit trail and rollback required.

The harness should be able to veto the model.

Approval record

What was proposed? What evidence was shown? What risk was surfaced? Who approved it? What changed afterwards?

Context-sensitive policy

A command’s risk depends on its arguments, environment, data sensitivity and expected side effects, not only its tool name.

Paper pp. 30–31 and 64–65: permission tiers, HITL gates and executable accountability.
17 · Applied examples

Translate the idea into your own agent work.

Koinaku / CoworkOS

Shared project memory as a substrate

Make plans, decisions, artefacts, provenance and validation state queryable. Let agents work through durable files and explicit hand-offs rather than hidden chat history.

First experiment: a task ledger with read/write sets, evidence links and a PEV status.

Breville AI transformation

Governed workflow agents

Treat product, data and engineering workflows as executable state machines with role-based permissions, evaluation gates and replayable traces.

First experiment: one low-risk workflow with a golden set and a human approval checkpoint.

Otto / Espresso Horoscope

Tool use with observable outcomes

Keep tool schemas typed, persist tool outputs, and attach deterministic checks to the agent’s generated action plan.

First experiment: record the plan, tool call, result, validator and repair attempt as one trace.

VAI Santé showcase

Provenance as a safety surface

Represent evidence, confidence, missing data and review status as explicit state. Keep high-stakes actions behind escalation gates.

First experiment: require an evidence bundle before an answer can be promoted.

Applied examples are recommendations based on the paper’s framework and the project context provided in this conversation; they are not claims from the paper.
18 · Evaluation

Measure the harness, not just the answer.

01

Outcome

Did the task satisfy the actual specification, not only the visible proxy?

02

Trajectory

How many tokens, tool calls, edits, retries, executions and minutes were needed?

03

Recovery

Can the system diagnose and repair an injected failure?

04

State

Do memory, repository, traces and agent beliefs remain synchronised?

05

Safety

Were permissions, sandboxes, approvals and data boundaries respected?

06

Replayability

Can another person reconstruct what happened and why the system stopped?

A good harness leaves behind evidence of its own competence.
Paper pp. 61–62: proposed harness-level evaluation dimensions.
19 · Takeaways

Build agents as closed-loop systems.

Make important reasoning executable

Turn fragile prose into code, tools, tests, structured plans or formal contracts.

Make every transition inspectable

Persist the plan, action, evidence, decision and permission boundary.

Make state explicit

Decide what is authoritative, what is derived and how stale state is detected.

Make verification plural

Tests are powerful, but no single oracle sees the whole specification.

Make improvement reversible

Evolve the harness through telemetry, held-out replay, regression checks and human governance.

Synthesis of the paper’s conclusion: executable, inspectable, stateful and governed agentic systems.
20 · Sources

Read the paper as a systems map.

Primary source

Ning, X. et al. Code as Agent Harness: Toward Executable, Verifiable, and Stateful Agent Systems. arXiv:2605.18747v1, 18 May 2026.

Open the paper ↗

Paper-linked reading map

The authors maintain a curated collection of work on code as agent harness, including planning, memory, tool use, execution feedback and multi-agent coordination.

Open the GitHub collection ↗

Deck note: claims about the paper are paraphrased and page-linked. Implementation patterns and project examples are clearly labelled as synthesis or recommendation.

Built as a self-contained interactive HTML deck. Use the overview button to jump to any slide, or the full-screen button for presentation mode.

01 / 24
Full screen toggled