Harness Engineering · Episode 03

Three Small Changes, Dramatic Outcomes

Add information. Reduce possible outputs. Narrow visible actions.

Arc · The patterns Episode · 3 of 8 Next · Episode 04 — Five Paradoxes Every PM Must Hold
After this you will know
  • RetryWhy a retry needs new evidence, not another attempt.
  • SchemaWhat a shape contract can prove and what it cannot.
  • ToolsHow to reduce tool confusion without removing useful capability.
  • LearningHow one failed run becomes a test that protects the next release.

01Where Episode 02 left us

Inside a Production Agent Harness gave us five decisions around every model call.

Identity sets the operating contract. Memory policy chooses what the model sees. Orchestration decides what happens next. Interception checks the crossings. Observability and evals record and judge the run.

The reconciliation team can now draw its system. The map shows where the holes are.

The next question is practical: what can the team change this sprint?

02The sprint that changed no model

The team has spent a quarter comparing models. The invoice agent still fails in three familiar ways.

It repeats a malformed request without learning from the error. It returns fields the downstream system cannot use. It picks the wrong tool when several names sound alike.

On Monday, the team freezes the model.

Validation errors now return to the next attempt. Outputs must follow an agreed shape. The agent sees only the tools needed for the current step.

By Friday, the lesson is not that three tricks worked. It is why they worked.

Each change removed a decision the model kept getting wrong.

Reliability improves when the system replaces a vague choice with a specific signal or constraint.

03The whole pattern in one table

No code is required to understand the production loop.

StepWhat happensWhat the harness decides
Prepare Gather current state and relevant tools What the model may see and choose
Propose The model returns an answer or tool request Whether the proposal has an acceptable shape
Act A tool performs the approved operation Whether the action is permitted
Verify The system checks the real effect Whether the step moved the task forward
Continue The run advances, retries, escalates, or stops Whether external completion has passed
Learn The trace is stored and judged Whether this failure becomes a regression test

The model proposes. Reliability comes from the decisions before and after that proposal.

Figure 01 · Concept
Four ambiguity reducers
VAGUE CHOICE SPECIFIC SIGNAL 1 · RETRY “Try again.” Return the exact violation Field, observed value, rule, correction scope 2 · OUTPUT Any text the model can express One versioned shape Required fields, typed values, agreed labels 3 · TOOLS Forty names, several overlapping Only this step’s tools Exact names, stated boundaries, hidden specialists 4 · COMPLETION The model says it is done External evidence passes Coverage, exceptions, quality, authority
Read it as Add evidence. Bound the shape. Narrow the choices. Verify the outcome. Each door removes a decision the model kept improvising.

04Pattern 1: retry with evidence

A naive retry says, “Try again.”

The model receives the same task, context, and uncertainty. A different answer may appear, but the second attempt has no better reason to succeed.

A useful retry explains what failed.

Weak feedbackUseful feedback
“Validation failed” amount_cents must be a whole number
“Try again” You returned $42.50; return 4250
“Wrong format” Change this field only; keep the other values

The second version supplies the missing information: field, observed value, expected rule, and correction scope.

A retry must change one thing

If none changes, the retry is repetition.

Three failures often blurred together
FailureWhat it meansExampleWhat repairs it
Syntax The output is malformed or breaks an agreed structure Invalid JSON, a missing required field, an unsupported status label Provider-enforced structure, then validation at your boundary
Semantic The shape is valid but the business value is wrong The amount is a whole number, but it belongs to another invoice Business rules, source reconciliation, tests, or an eval
Goal Every individual output is valid, but the job remains unfinished 847 invoices passed validation while 1,500 were never processed An external completion rule tied to the real workflow

One validator cannot do all three jobs.

PM requirementA retry ticket should state the failure the retry can repair, the new evidence supplied, maximum attempts, the progress signal, the escalation path, and the recovery metric.

The key metric is not retry count. It is the percentage of failed first attempts that recover without creating a wrong business outcome.

05Pattern 2: constrain the output space

Teams often treat structured output as a developer convenience. The product value is a smaller failure space.

Free text lets the model return anything it can express. A schema, which is an agreed description of allowed fields and values, limits output to shapes the program knows how to handle.

Consider the invoice output.

FieldWeak contractStronger contract
VendorAny textNon-empty text
AmountAny textWhole number in cents, zero or more
Due dateAny textYYYY-MM-DD
StatusAny textPaid, pending, overdue, or disputed
Extra fieldsAllowed silentlyRejected unless added to the versioned contract

A weak instruction such as “return JSON” may still produce:

The response looks sensible to a human. The next system may fail or silently discard information.

What strict output proves — and what it does not
ProvesDoes not prove
Required fields existThe amount belongs to the right invoice
Values use supported typesThe status matches the ledger
Finite business states use agreed labelsThe source data is current
Unagreed fields are rejectedThe whole job is finished
A schema checks shape. An eval checks meaning. A completion rule checks the job.

OpenAI’s current documentation makes a useful distinction. JSON mode returns valid JSON. Structured Outputs with strict mode follow a supported supplied schema. Your application should still validate semantic rules and handle refusals, empty results, timeouts, and unsupported schema features.

Treat the schema as an API

A schema is a contract with every downstream consumer, not only the model. When it changes:

  1. Version the new shape.
  2. Identify affected consumers.
  3. Test old and new cases.
  4. Plan compatibility or migration.
  5. Monitor empty, refused, and semantically invalid outputs.

A field added casually today becomes a silent mismatch three systems later.

PM requirementA structured-output ticket should state the business consumer, required fields, allowed values, semantic checks after parsing, the failure experience when no valid result exists, the migration rule, and primary and counter-metrics.

Track schema-valid output and semantic correctness separately. A perfect shape can carry a wrong answer.

06Pattern 3: narrow the decision surface

Give an agent forty tools and it must distinguish forty operations before every action.

Some tools are irrelevant. Some overlap. Some use broad names such as query_data or update_record. The model must infer what they mean and whether the consequence is read, draft, or execute.

The solution is not always fewer total capabilities. It is fewer visible choices for this step.

Make the jobs explicit
Vague toolBetter toolDecision removed
query_dataget_invoice_by_idWhich dataset and query shape?
run_analysislist_overdue_invoicesWhich analysis and output?
update_recorddraft_payment_adjustmentDraft or execute? Which record?
refunddraft_refund and issue_refundProposal or irreversible action?

A precise name is part of the control surface.

Three operations improve the catalogue
  1. Delete tools with no distinct job.
  2. Rename vague tools to exact actions.
  3. Reveal specialist tools only when the task needs them.

The third uses progressive disclosure: the system keeps broad capability but shows the model a small, relevant set now.

A reconciliation skill may expose invoice lookup, payment lookup, exception drafting, and completion checks. A supplier-onboarding skill exposes another set.

Do not cut by frequency alone

A rare escalation tool may be essential. Review each tool on four dimensions.

DimensionQuestion
UsageHow often is it selected?
ContributionDoes it help complete the task?
OverlapDoes another tool do the same job?
ConsequenceWhat happens if the model picks it incorrectly?

The decision may be keep, rename, tighten, hide behind a skill, require approval, merge, or remove. The goal is not the shortest list. It is the clearest set that covers the workflow.

Say when not to use it

Near-neighbor tools fail at their boundary. Descriptions should include negative examples.

Use get_invoice_by_id when an exact invoice ID is known. Do not use it for vendor search or status lists.

The model now knows the operation and its edge.

PM requirementA tool audit should produce a named job per tool, a side-effect class (read, reversible write, irreversible action), selection success rate, a negative boundary, an approval policy, and an owner with a removal decision.

Track correct-tool selection and steps per validated completion. Fewer calls are useful only when completion stays correct.

07Pattern 4: verify before exit

The invoice failure in Episode 01 did not involve malformed output or the wrong tool. The run stopped before the workflow ended.

Replace model confidence with an external checklist.

Completion checkRequired evidence
CoverageProcessed count equals eligible source count
ExceptionsEvery unmatched record has an assigned state
QualityReconciliation checks pass
AuthorityNo prohibited action occurred

The model may propose completion. The harness checks the business state.

This is feedback at the job level:

Anthropic’s long-running-agent work uses feature inventories, progress files, startup scripts, and version history so new sessions can reconstruct what remains. LangChain’s Deep Agents work uses self-verification and pre-completion checks before exit.

Continuation needs limits

A completion gate can create a loop. Define:

“Continue until done” is not a policy unless both done and stop are defined.

08The measured receipt

LangChain held the model fixed and changed the system prompt, tools, and middleware, its term for hooks around model and tool calls.

The work included trace-based error analysis, self-verification, pre-completion checks, environment context, and loop detection. Terminal Bench 2.0 performance moved from 52.8% to 66.5%, a 13.7-point increase.

The result does not prove every harness change helps every workflow. It supports a narrower claim: changing the control system can materially change measured behavior while the model stays fixed.

The method is more reusable than the benchmark:

  1. Run a defined test set.
  2. Read the failed traces.
  3. Group failures by behavior.
  4. Change one system surface.
  5. Keep the change only if evaluation improves.

09The feedback loop

A production trace is a record of what happened. It becomes an eval only after the team states what should have happened.

StageInvoice example
TraceAgent used list_invoices_by_status despite an exact ID
Failure labelWrong tool selected when invoice_id is explicit
EvalExact-ID cases must choose get_invoice_by_id
ChangeAdd a negative boundary to the list tool
HoldoutTest new exact-ID and ambiguous cases not used to design the fix
ShipRelease if selection improves without harming ambiguous search

A holdout set is a group of test cases the team does not use while designing the change. It checks whether the improvement works beyond the examples that inspired it.

Twenty well-labeled cases from real failures may be worth more than a thousand synthetic cases no user has produced.

Figure 02 · Practice
Trace to eval, and back
01 · TRACE What the run actually did 02 · LABEL What should have happened 03 · EVAL The rule, written as a test case 04 · CHANGE One surface: prompt, tool, hook 05 · HOLDOUT Cases the fix never saw 06 · SHIP Release only if evaluation improves THE NEXT RELEASE INHERITS THE TEST A failure compounds only after it becomes a test.
Read it as A trace is evidence, not learning. Learning starts at the label and is only banked when the holdout passes.

10In practice: one sprint

Pick one high-volume model decision.

MoveActionMetric
RetryReturn the exact violation and correction scopeRecovery after first failure
OutputEnforce one versioned shapeSchema-valid and semantically correct outcomes
ToolsShow only relevant tools; rename one vague operationCorrect-tool selection
CompletionAdd one external business check before exitValid completed workflows
LearningTurn the next failed trace into an evalTime from failure to regression coverage

Do not ship all five changes at once if you cannot attribute the result. Start with the failure that appears most often or carries the largest consequence.

11Connecting the dots

The four patterns share one design principle. Let the model reason over the uncertain part. Do not make it improvise the contract around the uncertain part.

That principle connects reliability, cost, and autonomy.

A precise error reduces wasted retries. A schema protects downstream systems. A narrow tool set reduces wrong actions. A completion check lets the organization trust longer work. Each constraint may also add latency, cost, or blocked edge cases.

That trade-off is the bridge to Episode 04. The question is no longer whether constraints work. It is when they buy enough reliability, when they limit useful autonomy, and when a better model makes them unnecessary.

You now hold
Patterns 03 Four ambiguity reducers — evidence in the retry, a versioned output shape, a narrowed tool surface, and an external completion check — plus the loop that turns one failed trace into a regression test.
The next question
When does a constraint buy reliability, and when does it quietly cost you autonomy, latency, or a legitimate edge case?
Continue
Harness 04 Five Paradoxes Every PM Must Hold — when a constraint buys reliability, and when it quietly costs autonomy.
Read alongside
Environment 02 Construct the Task World — where the completion evidence in Pattern 4 actually comes from.
Sources
  1. OpenAI — structured model outputs: JSON mode, strict schemas, refusals, and unsupported features.
    developers.openai.com/api/docs/guides/structured-outputs
  2. LangChain — improving Deep Agents with harness engineering: fixed model, changed prompt, tools, and middleware; Terminal Bench 2.0 from 52.8% to 66.5%.
    langchain.com/blog/improving-deep-agents-with-harness-engineering
  3. Anthropic — effective harnesses for long-running agents: feature inventories, progress files, startup scripts, and version history.
    anthropic.com/engineering/effective-harnesses-for-long-running-agents