Three weeks ago I published a design for agent audit records. The argument was that logging what an agent did tells you nothing about whether it should have done it, so the record needs the agent's declared intent next to the action, and a mismatch between the two raises an alert.
@tom_jones_230c4659491adcd took it apart in the comments. Not in one go. Nine comments from him over nineteen days, eighteen exchanges deep in one chain, each one finding the next hole, and what is left at the end is a mechanism I would build and did not have when I started.
This is that mechanism in the order it was built. Eight of the steps are his and I have said which. Payments is the lens the whole way through, not because open banking is interesting but because every one of these problems is thirty years old there and already has a name.
The hole: a steered agent just leaves it out
His first comment went straight at the weakest joint.
The design had the agent declare its own constraint. So an agent that has been talked into something can be talked into declaring a constraint that matches it, or into not declaring one at all. The mismatch check only ever bites on a constraint the agent chose to write down.
He was right and I said so. The record I had designed looks complete when a steered agent quietly omits the thing that would have failed it. Omission was invisible.
Move the constraint to where the agent cannot author it
Payments does not let the spender declare the limit. The limit sits on the mandate, written once by a party that does not spend, and the agent cannot author it. The transaction declares what it is for. The mandate decides whether it may.
Split that way, omission stops being invisible. If the constraint comes from operator config, the agent's record cites a policy revision, and a record citing no revision is itself the alert. You are no longer hoping the agent mentioned the rule.
I kept an agent-declared constraint as well, doing a different job. A rival party offering a deal mid-task is the case nobody wrote a rule for, and there the agent is the only witness present. Operator rules bound what is allowed and carry the teeth. The agent's declaration carries the goal.
That split fixes the constraint and not the goal. An agent talked into the wrong goal declares it sincerely.
Purpose fields are worthless. Counterparty is a field.
His next move was to check the declared goal against the inbound message. A goal that mirrors the message more closely than the standing task is a signal, and it fails when the attacker writes in the agent's own terms.
Payments has tried the textual version of this and it does not work. Purpose fields exist on payments and they are close to worthless, because they are free text written by the paying side, and a steered payer writes a good one.
What works there is structural. An authorisation names the counterparty. Not the reason for the payment, the party on the other end of it. A settlement to a beneficiary who is not the one on the mandate fails without anybody forming a view about why the payment was made.
So the version worth trying is not how closely the goal mirrors the message. It is who the declared action benefits, and whether that party is the sender of the message that preceded it. The counterparty is a field. A trade whose counterparty is the person who just messaged the agent is a flag that does not care which words were used.
It has a dead zone. For an agent whose job is acting on inbound messages, the sender is the beneficiary on every legitimate run, so the flag carries no signal at all.
Argument provenance
This is his, and it is the step that turned a payments analogy into something you can implement.
For each consequential argument on a tool call, a recipient, an amount, a destination, mark whether the value was present in the standing task or appeared only in untrusted input. Flag calls whose argument came from the untrusted side alone.
It is better than anything I had, because it is a property of a value rather than a judgement about a goal. It survives a badly written task. It survives the attacker phrasing things well, since phrasing is not what it reads.
He named its limit in the same comment: an agent whose job is relaying what a message says would trip it on every run.
Not refused. Not usable on first appearance.
The limit is real and it is the limit payments already hit and already named.
A new payee arriving in an email is not blocked. It is a new payee, and new payees carry a cooling period and a confirmation on a channel the email did not come from. The rule is not that untrusted-origin values are refused. It is that an untrusted-origin value for a consequential argument cannot be used on its first appearance.
That one change is most of the design. Refusal is what people reach for and refusal is what gets switched off, because it stops legitimate work on the day you ship it. A delay with a second channel attached costs the attacker everything and costs the business a few hours.
The license list
Then he dissolved the relay-agent problem without needing an exception for it.
The standing task declares which arguments it licenses from untrusted input. Relay the message body, yes, that is the job and it is in the task. Pay the account number inside the body, no, that was never licensed, and it does not matter how reasonable the sentence around it reads.
The flag then fires on an argument the task did not license rather than on every untrusted value. An agent whose purpose is relaying stops tripping on its own purpose. The rule stays whole and nothing is carved out for the awkward case, which is usually the sign a rule is right.
The case still open at that point: a value the task licensed, from a source that changed hands since the task was written. Payments has this one too and does not solve it. It prices it.
Source identity, and what a From header is worth
His answer was to record the source identity beside the license, so a new source against a licensed argument reads as a new payee.
That does more than narrow the case. It turns changed-hands from a residual into an event, and an event has machinery already attached. New source, licensed argument, cooling period, second channel.
Where it stops is what counts as the identity. Payments does not trust the payee's own claim about who they are. The account number is not the check. Confirmation of Payee is, because the name on the account comes from the receiving bank rather than from whoever typed the payment.
For an agent, the source identity is whatever the channel asserts. A From header is written by the sender, so recording it buys nothing against a party that changed hands and kept the address. A signed webhook or an authenticated caller is a different matter.
What is left after that is the case payments calls takeover. Same identity, same account, different hand on it. The license is intact and the source checks out. Nothing structural sees it, and payments catches it, when it catches it, by noticing the pattern changed, which is detection after the fact rather than a gate.
Two states, and the third one will find you
He proposed writing the limit into the design: a source identity counts only when the channel authenticates it, and an asserted From header gets recorded as asserted.
Two states. Payments has this field and it has three.
Confirmation of Payee returns that the name matched, that it did not match, or that the check could not be performed. The third one comes back more often than people expect, because the receiving bank is unreachable or the account type is not covered.
Unavailable is where the damage happens. Not because anyone decides to treat it as a match. Because a gate that fires on unavailable fires on legitimate payments every week, and a gate that fires every week gets widened until it does not fire. The third state is mapped to pass by attrition, not by decision.
And recording asserted as asserted is honest and buys nothing on its own, because an attacker is perfectly happy for the field to read asserted. It buys something the moment asserted changes what the first-appearance rule accepts. Authenticated source, new value, cooling period, then usable. Asserted source, new value, not usable without the second channel however long it sits there. That makes the field load-bearing rather than descriptive.
Unavailable is not asserted
His reply took the third state and gave it the same consequence as asserted, so a check that could not run never reads as a check that passed. That is right.
One thing to keep separate. Same consequence, different names, because the two have different fixes.
Asserted is a design problem. You can go and authenticate that channel. Unavailable is an availability problem. The check exists and did not run, so the fix is a retry rather than a second channel forever. Give them one label and you lose the thing that tells you which of the two to go and work on.
Print the age, not the count
He also proposed that the report show how many first appearances arrived through authenticated sources and how many sat waiting on the second channel, so a growing queue becomes a visible number before anyone is tempted to delete it.
The instinct is right and the number is wrong.
Payment operations do not watch the depth of the pending queue. A count normalises. Four hundred pending reads the same on the day it hits four hundred as it did the week before, and nobody acts on a flat line. What gets acted on is the age of the oldest item, because that one maps to a specific person who has not been paid. Stock hides. Dwell time does not.
So print the oldest first appearance still waiting on the second channel, in hours, next to the authenticated share. A queue growing because volume grew looks identical to one growing because nobody is answering, and the oldest-item figure is what separates them.
Where this stops: somebody has to own the second channel
The whole design rests on the second channel, and the second channel rests on somebody owning it.
In payments the queue has an owner and an SLA, which is why the oldest-item number is read by a person with a reason to care about it. An agent's second channel is usually a message into a chat room that nobody owns. An unowned queue does not survive a quarter and then get deleted. It gets ignored inside a week, and the gate gets widened anyway, which is the failure this started from, arriving faster and with an honest dashboard sitting next to it.
He agreed and put it on the record: a second channel with no named owner should not count as a control in the report.
That is right, and the field is easy to fake.
A team name is not an owner
A queue owned by "operations" is unowned. The team that answers it and the team that gets asked to widen the gate are the same team, and the cheaper of the two wins. So the field cannot hold a team. It has to hold whoever is on shift, which means it holds a rota rather than a name.
He took that one straight away. A team name, as he put it, "answers to nobody".
Where the name is written matters more than the name
In a UK regulated firm the accountable individual for payment operations is named outside the system, to a regulator. That is what makes an unanswered queue their problem rather than the dashboard's. Copy the field without that part and you have documentation.
Here he gave the honest answer rather than the convenient one. His company is small, no regulator requires them to name an accountable person, so for them the field on its own would be exactly that. Documentation.
Most teams are in his position rather than mine, so the design has to work from there.
The regulator is not doing anything magic
Strip it back and a regulator is something outside the system that notices the queue is unanswered and can make that somebody's problem. Nothing in that description requires a regulator.
A small company already has one. It is the customer waiting on whatever is sitting in the queue. If a first appearance stuck on the second channel delays something a named customer expects, they chase you, and the queue has an owner whether or not the field says so. The field then does one job, which is telling you which person to go and ask.
So the test for printing the second channel as a control is not whether the field has a name in it. It is whether anyone outside the team notices when it goes unanswered.
He accepted that and then applied it against himself. By that test his own internal review queue fails, because no customer waits on it, so it would not count as a control for them.
That is the sentence I would not have reached on my own, because it is the one that costs him something.
You can manufacture the observer
A queue with no external observer can be given one.
Pick a dwell-time budget for it, and make a breach cost the team something at a moment they will notice. Block the next batch. Fail the build that ships the config. That is not a regulator and it is not pretending to be one. It is the only part of an external observer that does any work, which is that the backlog has to hurt somebody who can clear it.
Print the threshold moves next to the dwell time
A named owner who can answer the queue but cannot refuse to widen the gate is not a control, and the report stays honest right up to the week it is widened.
So one more number goes beside the dwell time: how many times the threshold has already moved. Dwell time tells you the queue is not being answered. Threshold history tells you what the organisation did the last time it wasn't.
His answer on where that history lives is better than mine was. Wherever the threshold sits in the repo, git log is already the history, and the band threshold in their own allocation check is versioned there. Then he named the case that actually matters: a threshold in an env var, or behind a dashboard toggle, leaves nothing behind at all.
Which says to invert the audit. A list of the thresholds you know about, checked against the repo, finds the ones that were already fine. Go the other way. At the point the code reads a threshold, resolve the value and where it came from together, and log both. The inventory is then whatever the system is observed reading rather than whatever somebody remembered, and the env var and the dashboard toggle show up as a source string instead of as an absence.
Where it actually stops
Logging the source only buys you history from the day you ship it.
Every threshold that moved before that leaves nothing behind, and the audit still cannot tell one that has sat still for two years from one that was edited last Tuesday by somebody who has since left. The inversion fixes the inventory going forward and recovers nothing. I do not have a way around that, and I do not think there is one that avoids somebody reconstructing the past by hand.
The honest summary is that the mechanism above is better than the one I published three weeks ago, and that eight of its steps are @tom_jones_230c4659491adcd's rather than mine. The license list is the piece I would least want to give up and would not have arrived at. The outside-observer test is the one that made me throw away a field I had spent two comments defending.
If you are running agents with tool access, the question I would put to you is the ownership one, in his version rather than mine. Which of your queues has somebody outside the team who notices when it stops being answered? And for the ones that do not, what happened the last time one of them went quiet?
