Architecture
Accountable actions for an AI agent: propose, confirm, commit
A reference architecture where the model proposes a consequential action, deterministic tools validate it, the host commits only from the signed-in owner's button, and evaluations read the host's record.
AI-generated, human-reviewed: the first draft was generated by an AI agent; I fact-checked, tested, and edited it. AI use policy
Architecture#

This builds on end-to-end tracing for an AI agent behind two API gateways. The trace, the baggage boundaries, and the content lane are unchanged; this page covers what accountability adds. The core pattern pairs a probabilistic model, which interprets the request and proposes, with deterministic tools and a host, which validate and commit, so the outcome is secure and predictable even when the model’s output is not.
Dataflow#
- The browser signs the user in and calls the front gateway with a delegated token; the gateway validates the token in a separate revision and forwards the W3C trace unchanged.
- The agent API validates the token again, derives an owner key and an HMAC actor pseudonym, and binds the conversation to that owner.
- For each turn the API builds four transfer tools closed over the caller and the conversation, and a response check rejects tool names and argument shapes it did not offer.
- The model reads requirements, searches the synthetic directory, asks which person when
names collide, and calls
prepare_transfer. The tool parses the amount on the host, validates recipient, cap, and currency, supersedes older pending cards, and writes apreparedproposal to the ledger. - The browser renders a host card. Confirm or Cancel sends a structured action with only the kind and the confirmation ID.
- The host re-reads the proposal, revalidates expiry, policy version, recipient snapshot, cap,
and currency, and writes one ETag-conditional outcome. A commit gets a
MOCK-receipt. - Only then does the model explain the outcome. A span event records the action and status, and the content lane carries bounded tool facts and confirmation outcomes for evaluation.

Components#
| Component | Role in this architecture |
|---|---|
| Microsoft Entra ID | Delegated sign-in for the browser; the API accepts user tokens only, not app tokens |
| API Management (front gateway) | CORS, per-IP limits, baggage removal, and JWT validation in a separate revision |
| ASP.NET Core 10 agent API | Owner binding, per-turn tools, response check, structured actions, host commit |
| Microsoft Agent Framework and model | Understand intent, call tools, restate the transfer, explain outcomes |
| Cosmos DB proposal ledger container | One ledger per conversation with owner key, proposals, statuses, and receipts |
| Content lane (Service Bus, Function) | Prompt, answer, bounded tool facts, and confirmation outcomes per turn |
| Evaluation scripts and evaluators | Judge with the host record as data; managed evaluators only in a connection-free place |
| Application Insights | IDs, outcomes, statuses, and pseudonymous actor IDs; never content or raw identities |
Considerations#
Reliability#
The ledger write is synchronous and durable before the reply; the content lane stays best
effort. When the write outcome is uncertain, the API reports unknown, keeps the confirmation
ID, and retries the same action; repeating a decision returns the stored outcome. There is no
in-memory fallback for the ledger. Conversation sessions are still in memory and single
instance.
Security#
The model never sees destinations or emails and cannot commit or cancel. Tool names and argument shapes are allow-listed before invocation. Structured actions reject unknown fields, so a client cannot change the amount or recipient at confirm time. Confirmation proves the signed-in owner sent the action; it is same-user consent, not four-eyes approval. Real money needs step-up authentication or a second approver and an idempotent payment API keyed by the confirmation ID.
Cost optimization#
Accountability adds no fixed charge: app registrations, a gateway revision, and one more serverless container. The model is the variable cost, now spent on chat, judging, and evaluation; the deployment’s tokens-per-minute capacity is the ceiling. The two Developer gateways remain most of the fixed bill.
Operational excellence#
Every turn has a turnId in telemetry and content; confirmations add an
app.confirmation.resolved span event with action and status. Create long-lived SDK clients at
startup so background refreshes do not inherit a request’s trace. Audit every App* table in
the workspace, including the GenAI content table, after any evaluation.
Performance efficiency#
The confirm path does one ledger read and one conditional write before the model runs, and the model’s explanation is short by instruction. Tool activity can stream to the browser as server-sent events, so long turns show progress without streaming model text.
When to use this architecture#
- An agent proposes actions with consequences, and you need to show who decided and what actually happened.
- You evaluate agent answers and need the judge to tell a good explanation apart from a real effect.
When not to use it#
- The agent only reads and answers; the first architecture is enough.
- The action needs more than one approver; add that workflow before you add a model.
Build it#
The post The agent could draft the transfer. Only a button could send it. walks through it, and these complete snippets are the working parts: