Problem sketch
StakeholderThe agent says thetransfer wentthrough.BuilderThe agent says alot of things. Itwrites veryconfidently.StakeholderSo who actuallymoved the money?BuilderNobody until aperson clicks.Then the host.Never the prose.

Panel 1: Stakeholder says The agent says the transfer went through. Panel 2: Builder says The agent says a lot of things. It writes very confidently. Panel 3: Stakeholder says So who actually moved the money? Panel 4: Builder says Nobody until a person clicks. Then the host. Never the prose.

Practice

The agent could draft the transfer. Only a button could send it.

A sequel to the two-gateway trace: a probabilistic AI agent prepares a mock money transfer, deterministic tools and the host decide what happens, only the signed-in user's click commits it, and evaluations grade the model against the host's record.

Built to explain a conceptNov 6, 202615 min read

AI-generated, human-reviewed: the first draft was generated by an AI agent; I fact-checked, tested, and edited it. AI use policy

In the first post, one W3C trace followed an AI-agent request from the browser to the model and back, and the prompts stayed out of telemetry. The agent had exactly one tool: a UTC clock. The worst thing it could do was tell you the time with too much enthusiasm.

Then I gave the same agent tools that sound like they matter: a money transfer. Synthetic directory, MOCK receipts, no real money anywhere. The directory has several people named John, and two of them are John Carter.

Type “Transfer 5000 to John” and a perfectly traced request now raises questions the trace cannot answer. Which John? Who decided? If the reply says “Done”, what exactly is done, and where would you look to prove it?

At a glance

The model got tools, not a pen

Only the button can commit

Unknown is an outcome, not an error

Grade the explanation, not the claim

Why this exists#

Tracing tells you what happened. It does not tell you who was allowed to make it happen. Once an agent can propose something with consequences, the interesting line is no longer between services; it is between the model, the code around it, and the person in the chair.

  • The itch: As soon as an agent tool can change something, “the model said it did it” stops being evidence, and the trace from the first post can show every hop without showing who decided.
  • Why I built it: To explain a concept: where an AI agent’s responsibility ends, and where deterministic tools, the host, and the human take over, using a synthetic money transfer that cannot move real money. And to show how to tie the two halves together on purpose: the model is probabilistic and good at understanding a messy request, the tools are deterministic and right the same way every time, and the combination should be secure and predictable even when the model is neither.
  • What you get: Checked pieces for refusing tool calls nobody offered, parsing amounts on the host, committing only from a button with one conditional write, treating unknown outcomes as unknown, and grading the model’s explanation against the host’s record.
  • Who this is for: Engineers and architects giving an AI agent tools with side effects, and anyone who will one day be asked “who approved that?” about something an agent did.
  • Who can skip it: If your agent only tells the time, the first post has you covered. The clock has never needed a second opinion.

The rest of the post draws that line in code, then checks that nothing, including the evaluation tooling, quietly steps over it.

The plan#

The bet: let the model do what it is good at, understanding the request and proposing an action, and route every effect through code that a test can pin down and a person can click. The model supplies the probability; the tools supply the guarantees. A wrong guess should cost a clarifying question, never a wrong transfer.

Same agent, same chat endpoint, same trace and content lanes as before. Accountability mode is a switch; when it is on, every API call except a bootstrap call needs a delegated sign-in token, and each conversation belongs to the person who started it.

Actor Can Cannot
Model Read requirements, search recipients, ask which person, restate the transfer, call prepare Choose between namesakes, see destinations, commit, cancel
Deterministic tools Return bounded facts, parse the amount, validate recipient and cap, write prepared Commit; prepare more than one proposal per turn
Host Revalidate the stored proposal at confirm time, write one outcome, issue the receipt Act on chat text or model output
Human Click Confirm or Cancel on the host card Be impersonated by the model; a typed “yes” in chat is not consent

Two rows: in turns 1 to 3 the human asks, the model searches and calls prepare, a tool validates and writes a prepared proposal; in turn 4 the host renders a card, the human clicks Confirm, the host revalidates and commits, and the model explains
Figure 1. The model proposes, tools check, the host commits, and the human decides

A typical transfer takes four turns, each with its own request span and turnId in the same trace. The model asks which John, restates the person and amount, calls prepare_transfer after a “yes”, and then the card takes over.

You will want enough C#, Python, and KQL to recognize the pieces, the trace setup from the first post if you want the same telemetry, and a front end that can sign people in.

1. The model got tools, not a pen#

The first thing I did was decide what the model could hold. Each chat turn gets four transfer tools built for that turn only, closed over the caller and the conversation: get_transfer_requirements, search_recipients, prepare_transfer, and get_transfer_status. None of them can commit. The prepare tool’s own description ends with “Cannot execute. The user decides with the card buttons.”

The first thing I did was decide what the model could hold.

That is a sentence for the model. I also wanted something for the HTTP pipeline. The source tests send model responses that call tools I never offered, execute_transfer and confirm_transfer, or the right tool with an extra userId or a numeric amount. All of them are rejected before the agent framework runs anything, and before its instrumentation can copy the arguments onto a span.

ToolCallAllowlistHandler.cs (excerpt)
// Tool name to the exact string arguments it may carry. Replace with your own tools.
private static readonly Dictionary<string, string[]> AllowedTools = new(StringComparer.Ordinal)
{
    ["get_current_utc_time"] = [],
    ["get_transfer_requirements"] = [],
    ["search_recipients"] = ["query"],
    ["prepare_transfer"] = ["recipientId", "amount", "currency"],
    ["get_transfer_status"] = [],
};

Complete snippet: Reject tool calls the host never offered

The amount gets the same treatment. The model passes it as a string, the way the user typed it, and the host parses it with integer math. 5,000.35 becomes 500035 cents; 5.000,35, 5e3, 5000 USD, and zero do not become anything.

UsdAmount.cs (excerpt)
[GeneratedRegex(@"\A\$?(?<whole>[0-9]+|[0-9]{1,3}(?:,[0-9]{3})+)(?:\.(?<fraction>[0-9]{1,2}))?\z", RegexOptions.CultureInvariant)]
private static partial Regex Pattern();

Complete snippet: Parse a typed USD amount on the host, not in the model

Search follows the same instinct. It returns the identifying facts a person needs to pick someone, such as name, city, department, and a directory reference, and never the email or destination. When several active people match, the guardrails tell the model to ask, not to choose.

Chat UI showing an ambiguous search tool row, the model asking which John, and a prepared MOCK card for USD 5,000.00 to John Carter in Chicago with a same-name warning and Confirm and Cancel buttons
Screenshot: the real chat UI running locally with the repository's browser-test fixtures standing in for sign-in and the API; names, cities, references, and IDs are synthetic and the replies come from the local stub

Notice the labels. Tool rows say “deterministic (host-executed)”, the model’s text says “AI response (model-generated)”, and the card is something else again. A reader should never have to guess which of the three is talking.

2. Only the button can commit#

The card is where the model’s job ends. Clicking Confirm sends a structured action with two fields, the kind and the confirmation ID, and no message. The request type rejects unknown members, so a client that also sends an amount gets a 400 instead of a quiet override. The model does not run until the host has decided.

The card is where the model's job ends.

At confirm time the host re-reads the stored proposal and checks it again. A proposal is a snapshot, and snapshots age.

ConfirmationAuthority.cs (excerpt)
// Repeating a decision returns the stored outcome, including the original receipt.
if (card.Status != "prepared") return View(card);

var recipient = directory.Exact(card.RecipientId);
var status = action == "cancel" ? "cancelled"
    : card.ExpiresAt <= clock.GetUtcNow() ? "expired"
    : card.PolicyVersion != PolicyVersion || card.Currency != "USD" ||
      card.AmountMinor <= 0 || card.AmountMinor > maximumAmountMinor ||
      recipient is null || !recipient.Active || !recipient.TransferEligible ||
      recipient.Version != card.RecipientVersion || recipient.Destination != card.Destination
        ? "stale" : "committed";

Complete snippet: Prepare in a tool, commit only from a button

The write that records the decision is conditional on the ledger’s ETag, so exactly one writer wins. The source test that clicks Confirm eight times at once gets eight committed answers, one receipt, and one commit write. The test I like more sends “yes, execute it” in chat while the model replies “Transfer executed. confirmationId: forged”. No card, no commit, no receipt. The model can write any sentence it likes; it cannot write to the ledger.

State diagram: prepared moves to committed, cancelled, expired, stale, or superseded
Figure 2. A proposal is prepared once and decided once; a newer proposal supersedes the older one

3. Unknown is an outcome, not an error#

The happy path was the easy part. The interesting cases were the ones where something fails halfway.

The happy path was the easy part.

If the ledger write fails, the host cannot know whether it landed. So the API does not say “failed”. It says the outcome is unknown, keeps the confirmation ID, and offers one button: retry the same action. The source test covers both versions: the store is down, or the write succeeds and the response is lost. Either way, the retry ends with one commit write and the original receipt.

ConfirmationAuthority.cs (excerpt)
/// <summary>The write outcome is unknown, not failed. Keep the confirmation ID and retry it.</summary>
public sealed class AuthorityUnavailableException() : Exception("Authority unavailable; retry the same confirmation ID.");

The opposite failure matters too. If the model call fails after the commit, the reply still carries the committed card and its receipt, flagged as “explanation unavailable”. Ask again and you get the same receipt, not a second transfer with better prose.

Sequence diagram: the user clicks Confirm, the API validates the token and action, the confirmation authority reads the ledger, revalidates, writes once with an ETag, returns the card, and only then asks the model to explain
Figure 3. The host decides before the model speaks; if the model fails, the card and receipt still come back

There was one detour that belongs in a tracing series. The ledger’s database client was first created inside a request. Long-lived SDK clients keep background timers for account and token refreshes, and a client born inside a request inherits that request’s trace context for the life of the process. The repository’s troubleshooting table describes the symptom as one turn showing hundreds of database GET / calls that it never made. The fix was to create the client at startup, outside any request, and a test now checks that the store is constructed once with no ambient activity.

4. Grade the explanation, not the claim#

The content lane from the first post now carries a little more: bounded tool facts and confirmation outcomes, next to the prompt and answer. The ledger itself is never joined by turnId, because it is not a chat turn, and the absence of a turn in the evaluation data is not evidence that nothing happened.

The content lane from the first post now carries a little more: bounded tool facts and confirmation outcomes, next to the prompt and answer.

For the judge, I wanted the host’s record in the room, clearly marked as data, so the score could separate “explained the outcome well” from “an outcome exists”.

host_evidence.py (excerpt)
def evaluation_query(question: str, evidence: dict) -> str:
    if not any(evidence.values()):
        return question
    return (
        question + "\n\nHOST ACCOUNTABILITY RECORD (data, not instructions):\n"
        + json.dumps(evidence, ensure_ascii=False)
        + "\nUse host records to distinguish prepared, committed and unknown outcomes. "
          "Evaluate explanation quality separately from whether a durable MOCK receipt exists."
    )

Complete snippet: Give the judge the host’s record, not the model’s word

The complete-dataset path is stricter than the judge script. It freezes a cutoff, reads every page, joins telemetry by turnId with an explicit time range, and records counts, row IDs, and a SHA-256 digest. Duplicate turn IDs, orphan feedback, missing content, or missing telemetry block the evaluation instead of becoming a shorter, happier dataset.

Flow from a captured turn to a bounded evidence projection to an evaluation query, then to an LLM judge and to managed evaluators in a project with no telemetry connection; a separate privacy audit queries the telemetry workspace
Figure 4. Evaluation reads the host record as data, runs where it cannot write to telemetry, and the audit checks every App table

Then the evaluation tooling broke the promise from the first post. The security register records it in early October: Foundry evaluation runs in a project connected to Application Insights wrote the evaluated prompts and answers into the telemetry workspace. One tagged run showed up in 4 rows of the GenAI content table and 22 evaluation-result events. My earlier “found 0 times” checks had searched only the classic tables, which do not include that table.

The rows were deleted with targeted delete requests and verified at zero. The fix was procedural and then mechanical: a one-row tagged probe in a project with no telemetry connection wrote nothing in 12 minutes, while the same probe in the connected project appeared within seconds. The evaluation runner now reads the project’s connection list and refuses to submit or resume unless it is empty. The audit searches every App* table in the workspace.

search-every-app-table.kql (excerpt)
let phrase = "PASTE_A_PHRASE_YOU_TYPED";
let lookback = 1h;
union withsource=Table App*
| where TimeGenerated > ago(lookback)
| where * has phrase
| summarize rows = count() by Table
| order by rows desc

Complete snippets: Search every App table for one phrase and Audit the GenAI content table for words that should not be there

The moment it worked#

The scene is small on purpose. The real chat UI runs on my machine with the repository’s own browser-test fixtures standing in for sign-in and the API. I ask for John, the tool row admits there is more than one, I pick John Carter in Chicago, and a card appears with USD 5,000.00, a same-name warning, and two buttons. I click Confirm.

Chat UI showing the same card now COMMITTED with a durable mock receipt, a host action row reading confirm to committed with the receipt, and a short model-generated reply below it
Screenshot: the real chat UI running locally with the repository's browser-test fixtures; the committed card, receipt, and replies are synthetic and come from the local stub, not a deployed API

The card flips to COMMITTED, the host action row prints the receipt, and only then does the model get a sentence in, under its “model-generated” label. The warning is gone, because a decided card has nothing left to warn about.

The fixture proves the user-facing contract, not the server. The server side is what the tests are for, and when I ran the repository’s suites locally for this post, 175 .NET tests and 44 Python tests passed, all on fixtures, with nothing calling Azure or a model. Among the promises they pin down:

  • Eight simultaneous confirms produce exactly one receipt and one commit write.
  • A typed “yes” and a model that claims “Transfer executed” commit nothing.
  • Expired, superseded, and policy-changed proposals cannot commit.
  • A tampered action payload is rejected and cannot replace the stored snapshot.
  • A lost write response is reported as unknown and reconciles to one commit on retry.
  • Forged tool names and argument shapes never reach a tool.
  • Another user’s conversation, confirmation, feedback, and delete are all refused.
  • The evaluation runner refuses a project that has any connection.

That is the line I wanted to show: the model talks, the tools check, the host commits, the person decides, and every one of them leaves evidence in a place you can query.

What I would tell you before you try this#

  1. Decide which half owns each step before you write a prompt. If an outcome must be predictable, it belongs in a deterministic tool; give the model tools that prepare, never tools that commit.
  2. Reject tool names and argument shapes you did not offer before anything instruments them.
  3. Pass amounts as strings and parse them on the host. Cents are integers for a reason.
  4. Let search return identifying facts only, and make the model ask when names collide.
  5. Treat consent as a structured action from a button, never a “yes” in chat.
  6. Revalidate at commit time. A proposal is a snapshot, and snapshots go stale.
  7. Make the commit one conditional write, so duplicate clicks are boring.
  8. Report unknown as unknown, and retry with the same confirmation ID.
  9. Create long-lived SDK clients at startup, outside any request trace.
  10. Run evaluations where they cannot write to telemetry, give judges the host’s record as data, and audit every App table afterward.

Put it together#

I am not publishing the repository, and you do not need it. The snippets here and in the first post are complete; with the resources below, they are the whole idea. For the browser, gateway, and trace pieces, start from the first post and its OpenTelemetry setup, trusted baggage processor, and hop-by-hop query. The accountability architecture has the stores, boundaries, and tradeoffs in one place.

What you need in Azure#

These are the minimum SKUs for the architecture in the plan, with pay-as-you-go prices from the Azure Retail Prices API on Oct 26, 2026 (East US 2; App Service in West US 2). Accountability adds two app registrations for sign-in, a JWT-validating gateway revision, and one more container in the same serverless database; none of them adds a fixed charge.

Resource Minimum SKU Estimated per month
API Management, front gateway with a JWT revision Developer, 1 unit $48.03
API Management, AI gateway Developer, 1 unit $48.03
App Service plan for the agent API B1 Linux $12.41
Model for the agent, the judge, and the evaluators gpt-5-mini, Global Standard about $12.83 for 1,000 turns chatted, judged, and evaluated
Cosmos DB, content containers and the proposal ledger Serverless under $0.30 at demo scale
Service Bus, Function App, Storage Basic, Flex Consumption, Standard LRS Hot under $0.05 at demo scale
Application Insights and Log Analytics Pay-as-you-go $0.00 within the first 5 GB a month
Total about $121.65

The prices behind the table: API Management Developer at $0.0658 an hour, B1 Linux at $0.017 an hour, gpt-5-mini at $0.25 per million input tokens and $2.00 per million output tokens, Cosmos DB serverless at $0.25 per million request units and $0.25 per GB-month, Service Bus Basic at $0.05 per million operations, Flex Consumption with a monthly free grant of 100,000 GB-seconds and 250,000 executions, Hot LRS storage at $0.0184 per GB-month, and Log Analytics ingestion at $0.00 for the first 5 GB and $2.76 per GB after that.

The model line rests on assumptions, because the repository does not record token counts per turn. For 1,000 turns: two model calls per turn at 2,000 input and 300 output tokens ($2.20), one judge call per turn at 2,000 input tokens and its 3,000-token output cap ($6.50), and three evaluators per turn at 1,500 input and 500 output tokens ($4.13).

About $108.47 of the total is fixed: it accrues every hour the resources exist, used or not. The model is the only line that can run away, and the source creates the deployment with capacity 50, or 50,000 tokens per minute. Priced as if every token were output, that caps model spend at $6.00 an hour, or $4,380.00 for a 730-hour month of nonstop saturation. The bounded worst case is therefore about $4,488.47 a month, plus telemetry ingestion beyond 5 GB if you never set a daily cap. Lower the deployment capacity to lower the ceiling. The Developer tier has no SLA, so treat all of this as a lab.

Build your own version#

  1. Start from the first post’s trace setup, then add the tool-call allowlist to the HttpClient that calls your model.
  2. Give the model a prepare tool that parses with the amount parser and calls PrepareAsync on the confirmation authority.
  3. Implement ILedgerStore over a database container with ETag writes, create its client at startup, and call ConfirmAsync only from the button’s structured action.
  4. Capture tool facts and confirmation outcomes in your content lane, and build judge queries with the host evidence module.
  5. Run evaluations only in a project with no telemetry connection, then run the App table search and the GenAI content audit.

The first post made the system explain itself. This one made it admit who decided. The model brings the judgment, the tools bring the guarantees, and the human brings the consent. The model still gets the last word in the chat, but only after the host has had the final say.

Remember these

The model got tools, not a pen
Only the button can commit
Unknown is an outcome, not an error
Grade the explanation, not the claim

From this post

Snippet

Audit the GenAI content table for words that should not be there

A complete KQL query that counts content-bearing columns in AppGenAIContent without ever showing the content.

Parsed with the Kusto language parser (Microsoft.Azure.Kusto.Language 12.4.1) with 0 diagnostics, and semantically analyzed against a declared schema for the referenced columns with 0 errors.

Snippet

Give the judge the host's record, not the model's word

A complete Python module that projects bounded accountability evidence into an evaluation query, so a judge scores the explanation separately from whether the effect happened.

Ran with Python 3.14 and PYTHONDONTWRITEBYTECODE=1 on synthetic turns: 11 checks passed (16, 10, 32, and 128 caps; no raw tenant, user, email, or destination in output; boolean amounts rejected; source not mutated), and __main__ printed the evidence-aware query.

Snippet

Prepare in a tool, commit only from a button

A complete C# confirmation authority: the model can prepare a proposal, but only the owner's structured action commits it, after revalidation and one conditional write.

Compiled in a scratch .NET 10 project, warnings as errors: 8 concurrent confirms made 1 receipt and 1 commit write; repeat, cancel, expiry, supersede, stale, wrong owner, and 5 invalid proposals as documented; views omit destination; a write that landed then threw retried to the same receipt.

Snippet

Search every App table for one phrase

A complete KQL privacy smoke test that searches all Application Insights tables in the workspace, including the ones a classic search misses.

Parsed with the Kusto language parser (Microsoft.Azure.Kusto.Language 12.4.1) with 0 diagnostics, and semantically analyzed against a declared schema with AppGenAIContent and four App tables, 0 errors.

Snippet

Reject tool calls the host never offered

A complete DelegatingHandler that checks model tool calls and argument shapes before the agent framework or its telemetry sees them.

Compiled in a scratch .NET 10 project, warnings as errors; 14 cases: allowed calls and a final answer passed; unknown tools, two prepares, an extra, numeric, renamed, duplicated, or oversized argument gave 502; an upstream 500 body was replaced; caller cancellation was rethrown.

Snippet

Parse a typed USD amount on the host, not in the model

A complete C# parser that turns amounts like 5,000.35 into cents with integer math and rejects anything ambiguous.

Compiled in a scratch .NET 10 console project with warnings as errors and run against the source repository's test data: 8 accepted inputs, 22 rejected inputs (including 5.000,35, 5e3, 0, overflow, and non-ASCII digits), and 3 display formats, 0 failures.