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.

Built to explain a conceptNov 6, 2026

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

Architecture#

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
Architecture: the model proposes, tools check, the host commits, and the human decides

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#

  1. 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.
  2. The agent API validates the token again, derives an owner key and an HMAC actor pseudonym, and binds the conversation to that owner.
  3. 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.
  4. 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 a prepared proposal to the ledger.
  5. The browser renders a host card. Confirm or Cancel sends a structured action with only the kind and the confirmation ID.
  6. 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.
  7. 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.

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
Dataflow: the host decides before the model speaks

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: