Harness Engineering: Structuring Context and Guardrails for AI Coding Agents in Production

openai · Tech · 2026 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: production coding-agent harnesses

OpenAI needed a way to make AI coding agents productive in real software work even though agents lack human cultural osmosis, durable memory, standup context, and implicit quality norms, while human attention and model context remain scarce.

Constraints:

Architecture

The talk proposes a harness where humans define quality in text, agents.md points agents through planning and grounding steps, documentation and ADRs supply product and codebase context, tests/lints/tool outputs inject just-in-time remediation, static guardrails make repeated failures impossible, reviewer-agent personas judge PRs through specific quality lenses, and feedback from reviews, failed builds, interventions, and production exceptions is captured for later guardrail improvements.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  human_operator["Human operator"] --> agents_md["Agents.md"]
  human_operator --> feedback_capture_loop["Feedback capture loop"]
  agents_md --> coding_agent["Coding agent"]
  documentation_and_adrs["Documentation and ADRs"] --> coding_agent
  review_persona_guardrails["Review persona guardrails"] --> reviewer_agents["Reviewer agents"]
  agents_md --> review_persona_guardrails
  coding_agent --> tool_and_test_outputs["Tool and test outputs"]
  tool_and_test_outputs --> static_guardrails["Static guardrails"]
  static_guardrails --> coding_agent
  static_guardrails --> reviewer_agents
  coding_agent --> pr_review_thread["PR review thread"]
  reviewer_agents --> pr_review_thread
  pr_review_thread --> human_operator
  pr_review_thread --> feedback_capture_loop
  feedback_capture_loop --> sub_agent_distillation["Sub-agent distillation"]
  sub_agent_distillation --> documentation_and_adrs
  sub_agent_distillation --> static_guardrails
  codex_app_automation["Codex app automation"] --> coding_agent
  human_operator --> codex_app_automation
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Human operator Defines standards, accepts or rejects PRs, decides which repeated feedback should become guardrails, and intervenes when agent work lacks context. Agents.md, PR review thread, Feedback capture loop
Coding agent Codex-style execution worker that reads context, uses tools, edits code, runs tests, and proposes PRs. Agents.md, Documentation and ADRs, Tool and test outputs, PR review thread
Agents.md Central operating loop with numbered steps for grounding, documentation review, user-journey awareness, and rollout behavior. Coding agent, Review persona guardrails
Documentation and ADRs Knowledge base, design docs, runbooks, critical user journeys, and product context that make team quality norms legible to agents. Coding agent, Tool and test outputs, Review persona guardrails
Tool and test outputs Tool calls, tests, lints, and descriptive failures that just-in-time prompt-inject remediation context during implementation. Coding agent, Static guardrails
Static guardrails Lints, exhaustive tests, type rules, snapshot checks, and structural checks that make repeated failure classes impossible. Coding agent, Tool and test outputs, Reviewer agents
Review persona guardrails Curated markdown guardrail files for personas such as reliability, performance, product, and critical user journeys. Agents.md, Reviewer agents, Documentation and ADRs
Reviewer agents LLM-as-judge jobs that evaluate diffs through static guardrails and persona-specific standards, then collaborate in the PR thread. Review persona guardrails, PR review thread, Static guardrails
PR review thread Collaboration surface where implementation agents, reviewer agents, and humans exchange review evidence and merge decisions. Coding agent, Reviewer agents, Human operator, Feedback capture loop
Feedback capture loop Nightly or recurring process that collects feedback, failed builds, exceptions, and interventions and turns them into improved guardrails. Human operator, PR review thread, Sub-agent distillation
Sub-agent distillation Sub-agents inspect accumulated feedback to identify missing context, better prompts, or guardrails. Feedback capture loop, Documentation and ADRs, Static guardrails
Codex app automation Practical automation surface used for open-source maintenance tasks and future review-agent integration. Coding agent, Human operator

Data flow

An agent starts from a ticket and agents.md, grounds itself in documentation, ADRs, design docs, and critical user journeys, then enters implementation while tools, tests, lints, and runbook-linked errors inject context at the point of failure. After the diff exists, static guardrails and LLM-as-judge reviewer agents assess reliability, performance, and team standards in the PR thread. Repeated review comments, failed builds, production exceptions, and interruptions are captured as evidence of missing context and distilled into new docs, guardrails, and tests.

3 supporting quotes
“we first want it to ground itself in the documentation knowledge base in the ticket that is proposed.”transcript, stated
“the agent is writing code, running test, exploring the code base, and for that, we exploit the fact that these agents are going to call a bunch of tools”transcript, stated
“every review comment, every time you have had to interrupt the agent, every agent intervention, every failed build, every exception in production.”transcript, stated

Why this architecture

The harness is designed around the fact that agents need text and context, but attention and context windows are scarce. By making team standards explicit, surfacing them at the right moment, and progressively encoding repeated mistakes as static guardrails, the system aims to reduce synchronous human attention while preserving quality.

3 supporting quotes
“agents just do not have that capability. They don't have presence in our stand up. They don't have this durable memory”transcript, stated
“it's not enough to just write things down. We need to make sure that this text is a thing that the agent will look at”transcript, stated
“Harness engineering is making context around what it means to do a good job, legible and then just in time, surface to the agent”transcript, stated

Models used: o3-era reasoning models · Codex CLI · GPT 5.2 · Opus 4.5 · reviewer agents · LLM-as-judge evaluators · sub-agents · Codex app

Scale

Alternatives considered (roads not taken)

Rely on human cultural osmosis and repeated review feedback

Rejected because: Agents do not attend standups or retain battle scars, so teams must make quality rules explicit and retrievable.

“Oh, we'll have people into the office. We'll have meetings through osmosis. People will understand what it means for us as a team to write high quality software”transcript, stated
“agents just do not have that capability. They don't have presence in our stand up.”transcript, stated

Only write requirements in documentation

Rejected because: Documentation has no effect unless the right text enters the agent context at the time the agent needs it.

“it's not enough to just write things down. We need to make sure that this text is a thing that the agent will look at”transcript, stated
“if that text never makes it to the agent.”transcript, stated

Shift every quality intervention as far left as possible

Rejected because: For agent work, the speaker starts with interventions as far right as possible to minimize synchronous human time, then shifts left only when needed.

“I try and put my interventions as far right in the process as I can in order to minimize my own synchronous time”transcript, stated
“Only if, for example, guardrails are commonly required over tasks that span 15 context windows”transcript, stated

Use one-off prompt fixes for bad PRs

Rejected because: Prompt fixes can work locally but do not reliably socialize the improvement to the team or future agents.

“it might just be the case that I'll trash it, change my prompt, and probably get something good out of it.”transcript, stated
“But that's not really a durable thing. It's not reliable.”transcript, stated

Jam many guardrails directly into agents.md

Rejected because: Too many prescriptive rules chop up the model's latent space and make creative codebase exploration harder.

“We don't want to jam a ton of rules in here, because we're going to chop up latent space too much.”transcript, stated
“point to a curated set of review personas that are essentially bulleted list of guardrails.”transcript, stated

Treat local guardrail tooling as production-quality software

Rejected because: For local-only harnesses, rough code is acceptable if it enforces the right invariants and reduces human attention.

“there's a ton of guardrails that only affect my local development process. This code can be gross”transcript, stated
“the thing I care about are invariants, interfaces, whether or not the components that they're producing do what they say”transcript, stated

Patterns

context-engineering (proposed harness discipline)

The talk defines harness engineering as making quality context legible and surfacing it just in time through agents.md, docs, tests, lints, tool outputs, review personas, and auto-compaction-aware guardrail placement.

“Harness engineering is making context around what it means to do a good job, legible and then just in time, surface to the agent”transcript, stated
“we structure the context. We give the model, or continually resurface context to the model”transcript, stated

tool-use-orchestration (coding-agent execution loop)

The agent uses tools, tests, lints, computer/browser capabilities, Codex app automation, and PR collaboration surfaces to execute and prove work.

“these agents are going to call a bunch of tools, run a bunch of tests in order to use them to just in time, prompt inject the agent”transcript, stated
“computer use and browser use, the Codex app is fantastic. Highly recommended.”transcript, stated

eval-driven-development (guardrail and review loop)

Quality control is encoded as tests, lints, snapshot tests, branch coverage, static guardrails, LLM-as-judge review, and reviewer-agent feedback that the implementation agent must satisfy.

“we can absolutely vibe a set of guardrails into place with 100% code coverage and exhaustive table driven tests”transcript, stated
“can use very, very many LM as judge to look at the code”transcript, stated

human-in-the-loop-gate (merge and intervention policy)

Humans retain merge judgment, decide which issues are P2 or higher, ask agents for proof such as logs/screenshots, and shift guardrails left when repeated problems appear.

“What are the P2 and above things that would be necessary for me to accept this code?”transcript, stated
“I'll ask them to show me the logs from the staging deploy or to post a screenshot of them exercising the feature in the app.”transcript, stated

safety-policy-enforcement (static quality enforcement)

The system turns reliability, type-safety, retries/timeouts, snapshot coverage, branch coverage, and other non-functional requirements into static checks that prevent recurrence.

“missing timeout and a retry on a cross service network call”transcript, stated
“we just ban the existence of that type. We require the code base to be 100% typed”transcript, stated

multi-agent-orchestration (feedback distillation)

The future loop points sub-agents at accumulated human feedback, failed builds, and production exceptions to identify better prompts and missing guardrails.

“slurp all this data up and dream over it every night, pointing a bunch of sub agents at it”transcript, stated
“whether there's missing guardrails that should exist in the code base that disallow this behavior”transcript, stated

Tradeoffs

Move quality gates as far right as practical.

Chose Late interventions first, then shift left only when repeated failures require it over Default DevOps shift-left behavior for every concern.

Rationale: The speaker wants to minimize synchronous human time and rely on right-time discovery until a pattern proves it needs stronger earlier enforcement.

“I try and put my interventions as far right in the process as I can in order to minimize my own synchronous time”transcript, stated
“I need to use that as a signal that I need to shift some of these guardrails left”transcript, stated

Keep context timely rather than exhaustive.

Chose Just-in-time prompt injection through tools, tests, lints, and PR review over Large upfront context dumps.

Rationale: Just-in-time context reduces context-window pollution and lets the model reason creatively before receiving targeted constraints.

“And because we don't have to pollute context window up front, and we can exploit the fact that a tool called output is going to be given less weight during an auto compaction.”transcript, stated
“just in time, correct the model and still let it go off and do the complex work”transcript, stated

Make repeated mistakes impossible.

Chose Static guardrails, lints, exhaustive tests, and reviewer agents over Repeated manual review comments.

Rationale: Every repeated feedback item is evidence that context was missing and should be encoded durably.

“We want to make every mistake something that is just not possible.”transcript, stated
“this feedback is actually durably encoded as a static guardrail that we apply to every PR going forward.”transcript, stated

Use review personas instead of one monolithic rule file.

Chose Curated persona-oriented guardrail files referenced by agents.md over Jamming all guardrails directly into the central agent instruction file.

Rationale: Persona files let agents discover relevant guardrails without over-constraining every task.

“point to a curated set of review personas that are essentially bulleted list of guardrails.”transcript, stated
“agents paints a picture of which guardrail files are relevant”transcript, stated

Bias review toward merge with P2+ blockers.

Chose Benefit-of-the-doubt PR acceptance with reviewer agents surfacing P2-and-above issues over Shoulder-surfing every agent-generated change.

Rationale: The process treats agents like teammates and focuses human attention on merge-blocking issues and proof artifacts.

“I'm treating it again like I would my human teammates benefit of the doubt biased toward merge.”transcript, stated
“What are the P2 and above things that would be necessary for me to accept this code?”transcript, stated

Gotchas (what bit them)

Agents lack human team osmosis.

Root cause: They do not attend standups or accumulate durable team memory and battle scars like human engineers.

Resolution: Write down non-functional requirements and make them legible, retrievable, and timely inside the harness.

“They don't have presence in our stand up. They don't have this durable memory that accumulates context and battle scars over time.”transcript, stated
“we have to find ways to make all these nonfunctional requirements of writing good software legible to the agent.”transcript, stated

Documentation alone does not steer an agent.

Root cause: The text must be pulled into context at the moment the agent is making the relevant decision.

Resolution: Use just-in-time context injection through tools, tests, lints, runbooks, and review agents.

“You will write reliable network code by making sure that retries and timeouts are consistently applied if that text never makes it to the agent.”transcript, stated
“have them pulled into context at the right time in ways that don't thrash the agent”transcript, stated

Point-in-time fixes do not compound.

Root cause: Changing a prompt or giving a one-off review comment may solve one PR but does not reliably socialize the improvement to the team.

Resolution: Convert repeated feedback into docs, reviewer agents, lints, guardrails, and tests applied to every future PR.

“It's not enough to do point in time fixes with these models.”transcript, stated
“I never want to give the same review feedback twice”transcript, stated

Too many upfront rules can damage reasoning.

Root cause: Jamming a large rule set into context chops up latent space and makes creative codebase exploration harder.

Resolution: Keep agents.md as a map to relevant guardrails and rely on persona files and auto-discovery when possible.

“We don't want to jam a ton of rules in here, because we're going to chop up latent space too much.”transcript, stated
“the models will just naturally page those sets of persona oriented guardrails into into context”transcript, stated

Auto-compaction can erase guardrail context on long tasks.

Root cause: Tasks spanning many context windows may lose guardrail files that were originally paged in.

Resolution: Use repeated failures across long tasks as a signal to shift those guardrails left into stronger checks.

“tasks that span 15 context windows, and by then the context in those guardrail files has been auto compacted away”transcript, stated
“this is the thing that I need to shift shift left further on.”transcript, stated

Agent claims of testing need proof just like human claims.

Root cause: The reviewer cannot shoulder-surf every agent or teammate, so acceptance depends on artifacts that demonstrate behavior.

Resolution: Ask for logs, screenshots, browser/computer-use evidence, or reproduction videos attached to the PR.

“I'm not shoulder surfing any of my teammates in VS code or vim when they put up a PR”transcript, stated
“we can require these agents to do the same thing.”transcript, stated

Evaluation

The harness is evaluated by observing remaining synchronous human attention, repeated review comments, failed builds, production exceptions, guardrail misses, proof artifacts attached to PRs, and whether agents can run long tasks through multiple context windows without losing necessary quality constraints.

Metrics: three concurrent sessions as the speaker's personal synchronous-attention limit · agent tasks can run six, twelve, or thirty-six hours with auto-compaction · PRs can be one or six from a single prompt · 100% code coverage for generated guardrails in the retry/timeout example · 100% branch coverage for every React component snapshot-test requirement · P2-and-above issues are the review threshold for merge acceptance · fifteen context windows is cited as a signal that a guardrail may need to shift left

3 supporting quotes
“I know I max out probably at three concurrent sessions on my laptop.”transcript, stated
“What are the P2 and above things that would be necessary for me to accept this code?”transcript, stated
“every review comment, every time you have had to interrupt the agent, every agent intervention, every failed build, every exception in production.”transcript, stated

Outcomes

The talk cites June-era o3/Codex CLI experiments, GPT 5.2 and Opus 4.5 in December, three concurrent local sessions, six-to-thirty-six-hour tasks, one-to-six PRs per prompt, 100% code/branch-coverage guardrails, and tasks spanning fifteen context windows.

3 supporting quotes
“I asked the agent to read my alerts channel in slack and triage a page. It would not do that”transcript, stated
“all of your goals are to be how to unblock your execution team, these coding agents”transcript, stated
“exploiting automations in the Codex app to basically take my hands off the wheel for a ton of the maintenance tasks”transcript, stated