Lesson 10.4: Traces, change receipts and the harness flywheel
Learn how a harness records what happened and what changed, turns every failure into a lasting fix, and avoids decay as rules pile up and models improve.
By the end of this lesson you will be able to extend traces to record the harness's own decisions, issue a change receipt for every change an agent makes to the world so that it can be explained and undone, run a flywheel that turns each failure into a lasting harness improvement with a regression test, recognise the signs that a harness is decaying, and prune it using tests. You will work out that 60 harness rules of 80 tokens each add 48,000 tokens to a ten-call run, and that pruning to the 24 that still earn their place cuts that to 19,200 and saves ₹1,728 a day on 2,000 runs, that change receipts cut the time lost to undoing bad changes from about 36 to about 4 minutes a day, and that proving a rule is worth keeping by removing it needs 431 test cases to see a 5-point effect but 13,477 to see a 1-point effect. You should have read Lessons 7.4, 8.2, 9.4 and 10.1 to 10.3. No code is needed. The mathematics is multiplication and a sample-size formula.
The first three lessons of this module built the parts of a harness: the contract and map, the gateway and policy, the ledger and verification. This one closes the module with the habits that keep the harness useful over time. A harness is not built once. Agents fail in new ways, models change and the work shifts. A harness that is not looked after either lets failures repeat or grows into a heap of rules that nobody understands. The two ideas that look after it are records, so that you can see what happened and undo it, and the flywheel, so that each failure leaves the harness a little stronger.
Traces for the harness
Lesson 8.2 described traces of model calls and tool calls. A harness adds a layer of decisions that a trace should also show.
Policy decisions. For each tool call, which rules were checked and what the decision was: allowed, denied or asked, and why.
Approvals. Who was asked, what they were shown, the answer and the time taken.
Completion checks. What the harness checked and the result, item by item.
Verifier findings. What the verifier looked at, what it flagged and what happened next.
Recovery steps. Which rung of the ladder was used, and for what failure.
Contract and map versions. Which version of the task contract template, context map and policy was in force.
Two things make this useful. First, link everything by the task ID and trace ID, so that you can open a failed task and see, in one view, the contract, the plan, each action, each policy decision, the evidence, the verifier and the outcome. Second, record the reason with the decision. "Denied: refundoverlimit rule, amount 7,200 above limit 5,000" can be searched and counted. "Denied" alone cannot.
With this record you can answer harness questions that a model trace cannot. Which rules fire most? Which approvals are always granted? Which checks never catch anything? Where does recovery get used most? Those answers are what drive the flywheel.
Change receipts
A change receipt is a record, created for every change an agent makes to the world, that says exactly what was changed, why, under whose authority and how to undo it. It is the harness's equivalent of the receipt you get for a payment: proof that it happened, in a form that someone else can read later.
What a receipt holds
Field · What it records · ExampleReceipt ID and time · A unique reference and when it was made · R-20261115-0412, 14:07
Task and trace · The task and run that made the change · Task T-8841, trace 9f3a
What was changed · The object and the action · Customer record 5521, field address
Before and after · The old value and the new value · "12 Park Rd" to "14 Park Rd"
Why · The contract item or instruction that called for it · Contract item 3: update address on customer request
Authority · The identity it acted under, and any approval · Agent support-2, approved by S. Rao
Evidence · What supported the decision · Customer message M-771
How to undo · The step that reverses it, or a note that it cannot be reversed · Restore the previous value
Status · Applied, confirmed, undone or superseded · Applied
Most of this is available at the gateway: the call, the arguments, the identity and the approval. The before value is the part that needs care. The gateway should read the current state before a write and store it, so that undoing is possible. For changes that cannot be reversed, such as an email sent, the receipt records that fact, which is itself a warning to the policy: such actions deserve approval.
What receipts are for
Explaining. When someone asks "why did the address change?", the answer is a receipt, not a search through traces.
Undoing. When a change turns out to be wrong, the receipt gives the before value and the steps to reverse it. Rolling back a batch of changes made by one faulty run becomes a query: "all receipts from task T-8841".
Auditing. A regulator or a manager can review what the agents changed, in one place, in a form that does not require understanding the model.
Detecting. Patterns in receipts reveal trouble: a burst of changes, changes to unusual fields or many changes undone.
Limiting blast radius. Counting receipts per task enforces the blast-radius limits of Lesson 10.2.
What receipts save
Receipts shorten the time to put things right. Suppose agents make 40 changes a day, and 2 per cent are wrong, so 0.8 a day. Without receipts, finding the old value and the cause of each wrong change takes about 45 minutes, searching traces and logs. With receipts it takes 5 minutes. The time lost a day is 0.8 × 45 = 36 minutes without receipts and 0.8 × 5 = 4 minutes with. That seems small until the number of changes is larger or the damage spreads: an agent that made 4,000 wrong changes in a faulty run would, without receipts, leave a team trying to reconstruct 4,000 old values from scattered sources, a task of days. With receipts, reversing the batch is one operation.
Predict first: agents make 40 changes a day and 2 per cent are wrong. Finding and reversing a wrong change takes 45 minutes without receipts and 5 minutes with them. About how many minutes a day does a team spend on this in each case? Work it out before reading on.
Without receipts, about 36 minutes a day. With receipts, about 4.
The harness flywheel
The most valuable property of a good harness is that it learns. The harness flywheel is the loop that turns each failure into a permanent improvement, so that the same failure does not recur. It resembles the improvement loop of Lesson 9.4, applied to the harness and not to the prompt.
The steps:
1. Capture the failure. A bad outcome, an approval rejected, a verifier finding, a rollback, a complaint. The trace and the receipts say what happened.
2. Find the missing control. Ask: which part of the harness should have prevented or caught this? The question is not "how do we tell the agent to be more careful" but "what was missing around it?" Candidates:
a contract field that was vague or absent: add a scope line or an evidence requirement,
a context map line: the agent did not know where something was,
a policy rule: an action that should have been denied or asked about,
a limit: a missing cap or quota,
a completion check: evidence that should have been required,
a verifier instruction: something it should have looked for,
a tool fix: a confusing result or error message.
3. Make the smallest fix. Add the lightest control that prevents this failure.
4. Add a regression test. Turn the failure into a test case in the evaluation set and, for policy, a policy test, so that it can never return unnoticed.
5. Record the rule's provenance: the failure that motivated it, the date, the owner and the test.
6. Release as a change. Through the evaluation gate and a staged rollout, as in Lesson 8.4.
7. Measure. Did that kind of failure fall? Did the fix cause new ones?
Run this loop weekly, on the failures you actually saw, and the harness steadily becomes fitted to your work. Each cycle is small. After a year, the harness holds a record of every hard lesson the system has learned.
Why the flywheel needs provenance
Every rule should carry its reason. "Refunds above ₹5,000 need approval" is a rule. "Refunds above ₹5,000 need approval, added 12 March after the duplicate refund incident I-204, owner R. Gupta, test P-17" is a rule with a history. Without the history, nobody can tell, a year later, whether the rule is still needed, and it becomes impossible to remove.
Harness decay
A harness that only grows will eventually hurt. Harness decay is the gradual loss of value, and the growth of cost and confusion, as rules accumulate and the world changes. Several causes combine.
Models improve. A rule written to work round a weakness in last year's model may be unnecessary for this year's, and may even get in the way. An instruction telling the model to "think step by step and double check every figure three times" helped an older model and now only adds tokens and delay.
The environment changes. A map line pointing to a folder that was renamed. A policy threshold set for an old price list. A check that tests a field that no longer exists.
Rules conflict. Two rules added months apart, by different people, give contradictory guidance. The agent obeys one, or neither.
Rules multiply. Each failure adds a rule and nothing removes any. The context fills with warnings, and the model's attention thins.
Nobody remembers why. The rule's author has moved on, and nobody dares delete it.
What decay costs
The cost shows first in tokens. Suppose a harness has grown 60 rules that are injected into the context on every call, each of about 80 tokens. That is 4,800 tokens a call. On a ten-call run it is 48,000 tokens. At an example price of ₹30 per million tokens, that is ₹1.44 a run. On 2,000 runs a day it is ₹2,880 a day. If testing shows that only 24 of the 60 rules, 40 per cent, still earn their place, then pruning leaves 1,920 tokens a call, 19,200 a run, ₹0.58 a run and ₹1,152 a day. The saving is ₹1,728 a day, about 60 per cent, and the model reads a clearer set of instructions.
The token cost is the smaller loss. The larger one is behaviour. A bloated context can reduce accuracy, as Lesson 9.1 explained, and a conflicting rule set makes behaviour unpredictable. A decayed harness can perform worse than a smaller one.
Signs of decay
Watch for:
Rising token overhead from rules with no matching rise in quality.
Rules that never fire, or checks that never catch anything.
Approvals that are always granted, for months, with no edits.
Conflicts found in traces: the agent hesitating between two rules.
A model upgrade that did not improve results as much as expected, because old rules constrain it.
Nobody able to explain a rule.
Slowing releases: changing the harness feels risky because it is not understood.
Testing whether a rule earns its place
The method is ablation: remove the rule and see whether results get worse. If the failure the rule prevents does not return, the rule may not be needed. Each rule should have a regression test from its provenance, which makes this possible. The steps:
1. Pick a rule, and the test cases that relate to the failure it was written for.
2. Run the evaluation suite with and without the rule, on the same cases and several runs each.
3. Compare the results in that category and overall, including cost and speed.
4. If removing it makes no measurable difference, retire it, or move it to a lighter form such as an on-demand note.
5. If it does matter, keep it and record the finding.
The difficulty is the sample size, the same issue as in Lesson 9.4. To see whether removing a rule changes a pass rate from 90 per cent by a given amount takes this many cases per version, at 95 per cent confidence and 80 per cent power:
A 5-point change: 7.84 × (0.09 + 0.0475) ÷ 0.0025 ≈ 431 cases.
A 3-point change: 7.84 × (0.09 + 0.0651) ÷ 0.0009 ≈ 1,351 cases.
A 1-point change: 7.84 × (0.09 + 0.0819) ÷ 0.0001 ≈ 13,477 cases.
So you can prove that removing a rule makes a big difference with a few hundred cases, and you cannot prove that it makes none for a small one without thousands. The practical answer is to test rules against the specific failures they were written for, using targeted cases where the failure is common, and to use paired comparisons on the same cases. For rules that cannot be tested cheaply, a more cautious approach is to retire them in stages: remove a few at a time at each model upgrade, watch the metrics and keep the removals that cause no harm.
Keeping the harness healthy
Habits that slow decay:
Give every rule provenance: reason, date, owner, test.
Review on a schedule, and at every model upgrade, with a standing question: which rules were for the old model's weaknesses?
Set a budget. For example, no more than 2,000 tokens of rules in the always-on context. A new rule must fit, so an old one goes. This forces trade-offs.
Keep rules in layers. Put always-needed rules in the core and situational ones in on-demand files, as skills do in Lesson 9.3.
Prefer code to prose. A policy rule in the gateway or a check in the completion test costs no tokens and cannot be ignored. Move rules out of the prompt where you can.
Delete with the same ease as adding. If adding a rule takes five minutes and removing one takes a committee, the harness will only grow.
Run on the smallest harness that works, and add only for failures you see. This is the minimum viable harness of Lesson 10.1, kept alive.
Three worked examples
Example 1: a receipt that saved a day
An agent updating supplier contact details made a mapping error that overwrote the phone number with the email address for 340 suppliers in one run. The harness flagged an unusual burst of changes to one field and paused the agent after 340. Because every change had a receipt with a before value, the team reversed all 340 by querying the receipts of that task and replaying the before values, in under an hour. The incident review found that the agent's contract had a vague output field, which became a contract fix and a test.
Example 2: a flywheel in action
Over a quarter, a support harness's failure log showed three repeat causes. Agents refunded to a card that was not the one used for the order, the context map did not say which of two policy folders was current and the verifier never checked that promised delivery times matched the policy. The team added one policy rule, two lines in the map and one item in the verifier's checklist, each with a test and a provenance note. In the next quarter, the three failures fell from 38 occurrences to 4. Total harness size grew by 210 tokens.
Example 3: pruning at a model upgrade
When the team moved to a newer model, they ran ablations on 41 prompt rules, each against its regression cases. For 19 of them, removing the rule changed nothing measurable in 500 targeted cases. They retired those, along with a three-times-verify instruction that had added 30 per cent to the response time. Pass rate rose from 91.2 to 91.9 per cent, within noise, cost per run fell 22 per cent and median time fell 18 per cent. The retired rules were archived with their provenance, in case an old failure returned.
A checklist for traces, receipts and the flywheel
1. Extend traces to record policy decisions with reasons, approvals, completion checks, verifier findings, recoveries and the versions of contract, map and policy in force.
2. Link everything by task and trace ID.
3. Issue a change receipt for every change to the world: what, before and after, why, authority, evidence, how to undo and status. Have the gateway read the before value.
4. Use receipts to explain, undo, audit, detect trouble and enforce blast-radius limits.
5. Run the flywheel weekly: capture the failure, find the missing control, make the smallest fix, add a test, record provenance, release as a change and measure.
6. Give every rule a reason, date, owner and test.
7. Watch for decay: rising token overhead, rules that never fire, always-approved gates, conflicts and unexplained rules.
8. Test rules by ablation against their regression cases, and retire those that do nothing, in stages if need be.
9. Set a budget for always-on rules, and move rules into code, layers or on-demand notes where you can.
10. Review the harness at every model upgrade.
Common mistakes
Tracing the model but not the harness. You cannot tell which rule fired.
Decisions without reasons. "Denied" cannot be searched or counted.
No before values in receipts. You cannot undo.
Fixing a failure by telling the agent to try harder. Find the missing control.
Rules without provenance. Nobody dares delete them.
Only adding, never removing. The harness grows heavy and contradictory.
Keeping rules for last year's model. They may now do harm.
Judging ablations on tiny samples. Small effects need thousands of cases.
Always-on rules that could be code. Code costs no tokens and cannot be ignored.
No review at model upgrades. That is when decay shows.
Key takeaways
A harness should trace its own decisions, with reasons, and link them by task and trace ID to the model's trace.
A change receipt records, for every change to the world, what changed, before and after, why, under whose authority, with what evidence and how to undo it. Receipts explain, undo, audit and detect. In the example they cut the time spent putting wrong changes right from 36 to 4 minutes a day, and make reversing a faulty batch one query.
The flywheel turns each failure into a lasting fix: find the missing control, make the smallest change, add a test, record provenance, release and measure.
Harnesses decay as models improve, environments change and rules multiply and conflict. In the example, 60 rules cost 48,000 tokens per run and pruning to the 24 useful ones saved ₹1,728 a day.
Test rules by ablation. A 5-point effect needs about 431 cases, a 3-point effect about 1,351 and a 1-point effect about 13,477, so use targeted cases and staged removals.
Keep a budget for always-on rules, prefer code to prose and review at every model upgrade.
Check yourself
1. Name four fields of a change receipt.
Any four of: receipt ID and time, task and trace, what was changed, before and after values, why, authority, evidence, how to undo and status.
2. Why must the gateway read the current value before a write?
So the receipt can hold the before value, which makes undoing the change possible.
3. Agents make 100 changes a day, 3 per cent wrong. Finding and reversing each takes 30 minutes without receipts and 4 with. How many minutes a day in each case?
3 wrong changes. Without receipts 90 minutes, with receipts 12 minutes.
4. What is the first question to ask when a failure occurs in the flywheel?
Which part of the harness should have prevented or caught it? That is, what control was missing around the agent.
5. Name three signs of harness decay.
Any three of: rising token overhead, rules that never fire, approvals always granted, conflicting rules, a model upgrade that gives less than expected and rules nobody can explain.
6. What is ablation, and why is it hard for small effects?
Removing a rule and seeing whether results get worse. Detecting a small change in a pass rate needs thousands of cases per version.
Try this
Set aside ninety minutes.
1. List the decisions your harness makes, such as policy, approvals, completion checks, verifier findings and recoveries. For each, write the fields a trace should hold, including the reason.
2. Design the change receipt for one kind of change an agent makes. Include the before value and the undo step.
3. Use the receipt simulator with your numbers to see what receipts would save, including a faulty-run case.
4. Take the last five failures you know of. For each, name the missing control and the smallest fix, and write the regression test.
5. Write the provenance line for each new rule: reason, date, owner and test.
6. Count the rules injected into every call, and their tokens. Use the pruning simulator to see what you might save if 40 per cent were still useful.
7. Plan an ablation for three rules: the cases you would use, the comparison and the sample size from the chart.
A good result is a record and improvement plan: the harness trace fields, a change receipt design, a weekly flywheel routine and a pruning plan. That completes Module 10. You now have the parts of a harness, from contract to gateway to verification to the practice of keeping it sound. The next module is a different kind: a monthly review of what is new in agentic AI.
Tags: Agentic AI Harness engineering Change receipts Observability Harness maintenance