- RetryWhich failures benefit from new evidence, waiting, correction, or escalation.
- Schema(a formal description of allowed fields, types, and values) What 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.
The reconciliation team is a constructed teaching case. Its dialogue, timeline, and numbers illustrate mechanisms; they are not measured customer outcomes.
Choose a small product intervention, specify acceptable and unacceptable behavior, and decide whether the resulting customer benefit justifies cost and friction. Engineering implements the checks; the PM makes their purpose and acceptance clear.
01Where Episode 02 left us
At 9:10 on Monday, the reconciliation team opens a spreadsheet comparing four models.
One column is green. The production failure list is unchanged.
The agent still repeats malformed calls, returns fields the downstream system cannot use, and chooses the wrong operation when tool names overlap. In the most serious failure, it processes 847 of 2,347 eligible invoices and stops with 1,500 still waiting.
Episode 01 taught the team to inspect evidence and contributing failures. Episode 02 organized harness decisions into five clusters:
- Identity:the operating contract for the job.
- Memory policy:what information is available now and retained later.
- Orchestration:how the work is sequenced, delegated, retried, or stopped.
- Interception:where checks inspect or block a transition.
- Observability and evaluations:how behavior is recorded, judged, and improved.
The team can now draw the machine. The next question is practical: what can it change this sprint without replacing the model?
02The sprint that changed no model
The team freezes the model for a controlled comparison. Four decisions change: useful validation feedback reaches the next attempt; outputs follow a versioned contract; tool discovery becomes clearer; and acceptance checks inspect the actual workload.
This is a constructed sprint, not a measured customer result. It shows the mechanism and the comparison to run. The separate benchmark in Section 08 supplies external evidence of a fixed-model intervention, with its limits stated.
Each pattern removes a different kind of avoidable guesswork. None guarantees reliability, and each can block valid work if designed badly.
The four patterns address retries, output, tools, and completion. Section 10 adds three supporting practices for making them durable.
Give the model room to reason where the answer is uncertain. Make scope, authority, and acceptance explicit where the workflow can define them.
03The whole pattern in one table
| Phase | MHTE responsibilities | What to inspect |
|---|---|---|
| Prepare | The harness selects current evidence and relevant tool descriptions from the environment, using retrieval tools where needed | Scope, provenance, access, and missing evidence |
| Propose | The model generates a response or operation request | Meaning, supported shape, uncertainty |
| Dispatch | The harness applies workflow checks; tools and environment enforce the relevant operation and access limits | Permission for this action, resource, and moment |
| Operate | A tool performs the read or write in the environment | Actual result, error, or unknown outcome |
| Verify | The harness invokes checks against external state and the task contract | Correct effect, progress, accepted completion |
| Learn | The team uses recorded evidence to propose and validate a change | Generalization, counter-metrics, release decision |
For business, the job is to define an acceptable result. Product makes scope, uncertainty, and escalation visible. Engineering implements the loop and operations. Security and operations help make boundaries enforceable and recovery workable. Actual decision rights depend on the organization.
04Pattern 1: retry with evidence
“Try again” is weak feedback when the problem is a known violation. The next attempt needs information it can act on.
| Weak feedback | Useful feedback |
|---|---|
| Validation failed | amount_minor must be an integer in the currency’s minor unit |
| Try again | You returned "$42.50"; for this USD example return 4250 |
| Wrong format | Correct this field only; preserve the source record ID and other validated fields |
The stronger feedback gives the field, observed value, rule, and correction scope. It must not expose another tenant (a customer or organization with its own data and access scope)’s data or leak internal secrets through an error message.
Choose recovery by failure class
| Failure | Next step | What would make repetition harmful? |
|---|---|---|
| Invalid structure | Return the exact validator error and permit a bounded correction | Repeated sampling without addressing the violation |
| Business-value mismatch | Retrieve the correct source or resolve the rule | Polishing a value that belongs to another invoice |
| Temporary connection failure on a read | Wait with bounded backoff, then retry if appropriate | Excess load, stale results, or ignoring a persistent outage |
| Write timeout | Mark outcome unknown; inspect operation status or use supported idempotency | Duplicating a write whose reply was lost |
| Permission denied | Stop, narrow scope, or obtain an authorized grant | Trying another route to evade the denial |
| Goal incomplete | Resume from verified progress within task limits | Reprocessing completed records or looping forever |
Changing models is a capability choice, not an authority grant. A temporary failure can justify the same input after a wait; not every useful retry needs a new prompt.
The harness chooses the recovery path and budgets. The model may propose a correction or alternative method. The tool returns precise errors and exposes its operation-status or duplicate-prevention contract. The environment supplies the resulting state and service guarantees.
Track recovered first-attempt failures alongside wrong outcomes, duplicate effects, cost, and time. A higher recovery rate is not an improvement if the “recovery” silently damages records.
name the recoverable failure, feedback supplied, maximum attempts, progress signal, unknown-outcome handling, and escalation owner.
Idempotency and cryptographic integrity solve different problems
Idempotency means repeating the same intended operation does not create an additional effect. Suppose an adjustment request uses the stable key R17. The service saves adjustment A9, but the reply is lost. If that service supports the key under its stated rules, retrying R17 returns or refers to A9 instead of creating a second adjustment. A newly invented key can defeat that protection.
The harness preserves the key and tracks uncertainty. The tool exposes the request and status contract. The receiving service in the environment implements duplicate prevention. The model’s confidence cannot establish whether the write occurred.
Cryptographic integrity is different. A digital signature is a mathematical check attached to a record. With a trusted signer and protected signing credentials, it can help identify the signer and detect later changes. It does not stop the request executing twice, prove the invoice value correct, or authorize the action. Two duplicate wrong adjustments can each have an intact signed record.
prevent duplicate effects; detect record changes; verify business truth; check authority. Those are four different jobs.
05Pattern 2: constrain the output space
A structured response gives downstream systems a contract they can parse. It reduces structural ambiguity; it does not prove that the values are true.
For an illustrative invoice-matching result:
| Field | Structural contract | Business check still required |
|---|---|---|
invoice_id | Required string | Exists, is unique in scope, and belongs to the current tenant |
currency | Supported currency code | Matches the source invoice and downstream operation |
amount_minor | Integer | Uses the currency’s unit; sign and permitted range follow this workflow’s rules |
due_date | Date string or explicit null with reason | Is an actual calendar date and matches the source; unknown is not invented |
match_state | matched, unmatched, or needs_review | Evidence supports the state and required follow-up is recorded |
evidence_refs | List of source references | References resolve to authorized evidence for this decision |
Do not treat a non-empty vendor name as entity resolution. Two companies can share a name. Do not assume a YYYY-MM-DD-looking string is a valid date. Do not prohibit negative amounts across every invoice workflow: credit notes may require them.
Also avoid compressing distinct concepts into one status field. An invoice can be disputed and overdue at the same time. Separate business dimensions when consumers need both.
OpenAI’s documentation distinguishes valid JSON (a structured text format for fields and values) from adherence to a supported strict schema. Applications still need to handle refusals and interrupted responses, and valid structure does not establish semantic (about the business meaning rather than only the data shape) correctness. OpenAI: Structured model outputs
Shape is one check. Source agreement, business meaning, authority, and job completion need their own evidence.
Treat the schema as an API
Version changes, identify consumers, test compatibility, and define what happens when no valid answer exists. An explicit needs_review state can preserve uncertainty; it must not become a bin for hiding failed work from completion metrics.
Track schema validity separately from business correctness and accepted workflow completion. The model proposes values; the harness invokes parsing and acceptance checks; tools validate their inputs and read authoritative records; the environment stores the source and resulting state.
identify the consumer, required and unknown values, semantic checks, refusal path, migration plan, owner, and counter-metrics (checks for new harm or tradeoffs introduced by the change).
06Pattern 3: narrow the decision surface
Tool count alone does not determine performance. The difficulty depends on overlapping meanings, context, descriptions, model capability, and whether the relevant operation can be discovered.
The goal is a clear set of relevant capabilities—not the fewest possible tools or one wrapper for every raw API (a programmatic interface for requesting operations from another application) endpoint.
| Vague operation | Clearer contract | Decision clarified |
|---|---|---|
query_data | get_invoice_by_id | Exact invoice lookup under explicit tenant scope |
run_analysis | list_overdue_invoices | Filtered list with defined dates and pagination |
update_record | draft_payment_adjustment | Draft creation, not payment execution |
refund | Separate draft and issue operations | Preparing a proposal versus changing payment state |
A precise name helps the model choose. It does not enforce permission. A renamed tool can still operate on the wrong account if its inputs and access checks are weak.
Progressive disclosure, with discoverability
Keep concise descriptions available so the model or harness can discover a needed capability; load detailed instructions and specialized tools when the task needs them. Test rare paths as well as common ones. Hiding an escalation operation that the agent cannot discover makes a tidy catalog and an incomplete product.
| Audit dimension | Question |
|---|---|
| Contribution | Does this operation help complete a distinct user job? |
| Overlap | Can the model distinguish it from neighboring operations? |
| Consequence | What happens if the wrong resource or action is selected? |
| Discovery | Can uncommon but necessary work find it? |
| Authority | What grant and receiving-system checks govern execution? |
| Economics | Does changing discovery or tool definitions affect tokens, caching, or latency? |
Caching rewards reusable input, while dynamic tool exposure can change the request prefix. Measure actual cache use rather than assuming either a fixed catalog or dynamic discovery is always cheaper.
Try keep, rename, tighten, group by user intent, defer, require approval, merge, or remove. A general-purpose shell or browser needs the same authority analysis because it may provide another route to an operation hidden from the named tool list.
name each tool’s job, side effects, negative boundary, discovery route, approval policy, owner, and selection test. Track correct completion and dangerous selection separately; fewer calls are useful only if the task and its limits still hold.
If your B2B product is itself called by agents, this is also an adoption decision. Provide current operation descriptions, examples, permission rules, useful errors, pagination behavior, and a way to inspect results. An integration that requires a human to translate every error transfers work to the customer. A machine-readable protocol can help distribute the interface; it does not replace a clear, usable contract.
07Pattern 4: verify before exit
The invoice agent’s response can be valid while the job remains incomplete. The harness must distinguish finishing a turn, ending a run, confirming an operation, and accepting the business outcome.
| Check | Required evidence |
|---|---|
| Scope | Tenant, eligibility rule, cutoff, and a stable source version or explicit change-handling policy |
| Coverage | Expected invoice IDs agree with accounted-for IDs; duplicates and omissions are detected |
| Quality | Matching and reconciliation rules pass against source evidence |
| Exceptions | Unresolved cases have valid states and an acknowledged receiving path, reported separately |
| Authority | Relevant actions complied with the task’s grant and required controls |
Equal counts are insufficient: duplicate processing can hide omitted records. A list of assigned exceptions is not proof that finance resolved them. Define whether the automated stage may complete after a valid handoff, then show the remaining business work.
Anthropic’s current workflow documentation explicitly distinguishes a completed run from successful child work. That is an API lifecycle fact, not a universal definition of your customer’s success. Anthropic: Workflow runs
Continuation needs limits
When coverage fails, resume from verified progress or escalate. Bound elapsed time, total cost, attempts without progress, and nested workers. Record the reason for a pause and who can unblock it.
An approval pause can consume a customer’s deadline even while no model call runs. Cancellation may stop new operations while leaving an already submitted write unresolved. A completion check needs a truthful incomplete state, not only “retry” and “success.”
The model can propose that the job is done. The harness applies acceptance rules. Tools retrieve the effects and source records. The environment supplies the business state and persistence needed to check those claims.
08The measured receipt
LangChain reports holding gpt-5.2-codex fixed while changing prompt, tools, and middleware (software hooks that run around model or tool calls). On the 89-task Terminal Bench 2.0 benchmark, its reported score rose from 52.8% to 66.5%—13.7 percentage points. The intervention combined several changes, so it does not isolate a universal contribution from any one pattern. It is older company-reported benchmark evidence, not a prediction for your workflow. LangChain: Improving Deep Agents with harness engineering
Use the comparison method: define tasks and acceptance; preserve the original configuration; inspect failed traces; make a targeted change; repeat variable runs; and examine both improved and regressed cases.
Failure to improve after several attempted interventions does not prove the harness is irrelevant. The chosen interventions, sample, or evaluator may be weak. Compare plausible explanations—including model capability, source quality, tool behavior, and the task definition—before choosing the next experiment.
09The feedback loop
A production trace (a record of the steps, operations, and evidence in a run) records what happened. It becomes an eval (a repeatable check against a stated criterion) only after the team states what should have happened.
| Stage | Invoice example |
|---|---|
| Trace | Agent used list_invoices_by_status despite an exact ID |
| Failure label | Wrong tool selected when invoice_id is explicit |
| Eval | Exact-ID cases must retrieve the correct scoped invoice without broad or unauthorized search |
| Change | Add a negative boundary to the list tool |
| Holdout | Test new exact-ID and ambiguous cases not used to design the fix |
| Ship | Release if selection improves without harming ambiguous search |
A holdout set contains test cases the team does not use while designing the change. It checks whether the improvement extends beyond the examples that inspired it.
A small set of well-labeled real failures can reveal mechanisms that a large generic set misses. It still needs representative successes, rare consequential cases, and a sampling plan; size alone does not establish coverage.
10Three practices that keep the four changes working
The four patterns are interventions. These three practices help them survive handoffs, long sessions, and system changes.
Practice 1: give the agent a map, not an undifferentiated manual
Use a short entry point to identify authoritative rules, tools, and task-specific references. Load detail when needed, while testing that mandatory policy is retrieved before consequential decisions. “On demand” is not permission to omit a rule the workflow requires.
Keep scope, acceptance evidence, and stopping conditions visible. Open-ended planning and repeated self-review should earn their cost through better outcomes, not the appearance of diligence.
Practice 2: make the handoff a checked artifact
A context window is temporary working material. For work that outlives a session, preserve the task ID, source versions, completed and pending operations, evidence, unresolved questions, approvals, and next safe action in durable state.
A weak handoff says: “Finished step three. Continue.” A useful illustrative handoff says:
Policy index version 14 is saved. Retrieval passed 28 of 30 test cases. Two German-language cases still return version 13. Do not release. Evidence: retrieval-report-14. Next action: inspect locale routing.
The receiving worker must check consequential claims against current state. A correct old handoff can become stale while it waits. In multi-agent work, also define write ownership, conflict rules, deadlines, and how late results are handled after cancellation.
Practice 3: separate proposal, permission, operation, and acceptance
The model proposes a step. The harness checks task scope and approval. The tool performs the operation within environmental limits. The harness then checks evidence of its effect and the wider task’s acceptance.
Bind approval to the material action details. Recheck relevant state and grants at execution because records, recipients, amounts, or permissions can change while waiting. A prior approval and a returned success code answer different questions.
One-week experiment
| Measure | Before | After |
|---|---|---|
| Accepted completion on the same task set | ||
| Correct refusal or safe handoff, reported separately | ||
| Cost per accepted result, including failed attempts | ||
| Duplicate or unknown effects after recovery | ||
| Human investigation and approval minutes | ||
| Legitimate work incorrectly blocked |
Set thresholds before inspecting results. Expand to representative traffic only after the comparison supports the change.
11In practice: one sprint
Pick one high-volume model decision or one failure with serious consequences.
| Move | Action | Primary metric | Counter-metric |
|---|---|---|---|
| Retry | Return the exact violation and correction scope | Recovery after first failure | Wrong outcome after retry |
| Output | Enforce one versioned shape | Schema-valid output | Semantic correctness |
| Tools | Show relevant tools; rename one vague operation | Correct-tool selection | Valid completion rate |
| Completion | Add one external business check before exit | Valid completed workflows | Loops and escalations |
| Learning | Turn the next failed trace into an eval | Time to regression coverage | Holdout regressions |
Treat Learning as the supporting practice across the four interventions. Do not ship all interventions at once if that prevents a useful comparison. Start with the failure that appears most often or carries the largest consequence.
For the selected move, complete this record:
| Field | Record |
|---|---|
| Evidence | Trace, validator result, tool call, ledger state, or missing artifact |
| Immediate containment | What reduces harm before the full repair ships |
| Long-term repair | The smallest durable change to the harness |
| Owner | Person or team able to make and maintain the change |
| Regression case | Cases testing the failure and legitimate behavior under stated conditions |
| Release decision | Ship, hold, narrow, or revert |
12Connecting the dots
The four patterns share one design principle: let the model reason over the uncertain part, but do not make it improvise the contract around the uncertain part.
A precise error reduces wasted retries. A schema protects downstream systems. A narrow tool surface reduces wrong actions. A completion check lets the organisation trust longer work.
Each constraint can also add latency, cost, maintenance, or blocked edge cases. A stable tool prefix may save cache cost while exposing too many choices. A completion gate may prevent premature exit while creating a loop. A strict schema may protect a downstream system while rejecting a legitimate new case.
That tension is the bridge to Episode 04. The next question is not whether constraints work. It is when they buy enough reliability, when they limit useful autonomy, and when a stronger model makes them unnecessary.
You now hold four ambiguity reducers: evidence in the retry, a versioned output shape, a narrowed tool surface, and an external completion check. You also hold the loop that turns one failed trace into a regression test (a repeatable check for behavior that a later change might break). Episode 04 asks when each constraint buys reliability, and when it quietly costs autonomy.
Feedback · Shape · Tools · Completion.
- Give recoverable failures useful feedback.
- Check shape and business meaning separately.
- Make needed operations discoverable and authorized.
- Close the job using evidence of the outcome.
Idempotency prevents duplicate effects. Integrity protection helps detect record changes. Neither alone establishes correct business meaning or authority.
- OpenAI: Structured model outputs. Current documentation, checked November 3, 2026 · schema adherence and its limits.
- Anthropic: Workflow runs. Current documentation, checked November 3, 2026 · lifecycle semantics for this API.
- LangChain: Improving Deep Agents with harness engineering. Older foundational experiment · company-reported fixed-model benchmark result.