Case study · built for a Microsoft partner · Oct 2026 · core pipeline live, pilot complete

Autonomous Agentic AI Auditor: an audit pack drafted from evidence, not from memory

Microsoft partners pursuing the AI Platform on Azure specialisation must prove, project by project, that each AI engagement followed a disciplined lifecycle. The proof is a pack of Word templates, written by hand from documents scattered across the project. I built a chain of nine AI agents that drafts the pack from the project's own documents, quotes them word for word, and turns every gap into a precise request to the client instead of filling it with plausible text.

My role

Principal AI Engineer. I designed and built the system: the nine-agent chain and its plain-code supervisor, the grounding guardrails, the evaluation harness, the reviewer workspace and the production hardening.

Stack

Python · pydantic v2 · Claude Sonnet 4.6 (drafting, critique) · Claude Haiku 4.5 (template enrichment) · GPT-4o-mini (failover) · text-embedding-3-large · ChromaDB · Model Context Protocol · python-docx · Streamlit

Where it stands

Core pipeline live. First real engagement complete: an Australian public-sector agency's AI assistant on Azure AI Foundry. Grounded checks over MCP and approval gates are next.

Watch first · about a minute

From a folder of documents to a reviewed audit pack.

Plain-English captions, no sound needed. Switch to For tech for the architecture, guardrails and evaluation detail.

▶ Explainer · about a minute · captions on screenGIF
Business view shows the story and results; tech view adds every engineering section.
In one minute

Upload the documents, press run, review what comes back.

The delivery team uploads a project's documents and presses run. A few hours later every required audit template is filled in. Each claim quotes the project's own words with the page and paragraph it came from, and every topic the documents do not cover comes back as a ready-to-send email to the client.

The hard part is not the writing. Any language model writes fluently. The hard part is writing only what the evidence supports and saying plainly where it runs out. So the AI reads and drafts, separate agents and plain code check every line, and people decide what ships.

  • GroundedDrafts may use only the customer's own documents. Every quotation is checked, letter for letter, against its source before it reaches the page.
  • HonestWhen evidence is missing the system says so and drafts the client request. It never pads a section to make it look complete.
  • ReviewableA review queue, a readiness view by control and a section-by-section map show what is done, what needs judgement and what is waiting on the client.
The problem

The evidence exists. It is just everywhere.

An AI specialisation audit asks for structured proof across the whole delivery lifecycle. The proof sits in the project's own documents, in its own words.

PhaseControlsWhat the auditor needs to see
AssessC1.1Is AI the right tool? Business case, data needs, security requirements, solution justification, customer sign-off.
DesignC2.1 · C2.2 · C2.3Solution design, Well-Architected Review, proof of concept. Responsible AI acknowledgement and impact assessment are mandatory.
BuildC3.1Signed statement of work through high-level design, low-level design and as-built. Azure AI Foundry must be in the production stack.
RunC4.1 · C4.2User-acceptance sign-off, operational Well-Architected Review, standard operating procedures, customer acceptance.

Why the pack is slow to write

  • Volume. Up to 74 templates are tracked and 46 are required, each with several sections, required fields and a word budget.
  • Scatter. One section can depend on a sentence in the statement of work, a table in the requirements and a line in a meeting transcript.
  • Exactness. Auditors look for the project's own words, dates and names. A paraphrase that drifts from the source weakens the case.
  • Recency. Evidence must fall inside a 12-month window of the audit date. A stale document quietly invalidates a control.
  • Hard gates. Responsible AI artefacts and proof that Azure AI Foundry is in production cannot be waived.

Why generic AI makes it worse

  • Ask a model to “fill in the business case” and it writes fluent, plausible text. That is exactly the risk.
  • Plausible content the project never stated is worse than a blank section: it misleads the reviewer and fails under audit.
  • What the job needs is a system that retrieves before it writes, cites what it retrieved, has its work checked by a second agent, and sends anything unsupported to a person or to the client.
How it works

Nine steps from an empty project to a reviewed pack.

The operator does three things: set up the project, add the documents, press run. Everything between is the system's job, narrated live as it happens.

01Set up the project

Name the customer, project, sector, platform and audit date. The workspace creates five folders that mirror a standard project site.

02Add the documents

Statements of work, designs, decks, spreadsheets, meeting transcripts and sign-offs, in Word, PDF, Excel, PowerPoint, VTT or text.

03Read and index

Every document is split into citable pieces with page, paragraph and heading kept, and indexed for this project only.

04Learn the templates

Each Microsoft template is mapped once: sections, tables, styles, word budgets and what the auditor will look for.

05Plan the run

The Manager reads the checklist, picks templates by priority, orders them by control and sets the budget.

06Draft, challenge, verify

For every section: retrieve evidence, draft with quotes, tighten, challenge, then pass a code check of every quotation.

07Write into the template

Text goes into the original Word file with its styling intact. Anything not final carries a visible marker and its reason.

08Assemble and learn

Mappings, coverage, client emails, cost breakdown and chain of custody are zipped. Approved work feeds a practice library.

09Review and send

Reviewers work the queue, check readiness, download the pack and send the client requests. A re-run picks up new evidence.

Architecture

Six layers, each with one job.

Models sit inside a gateway, agents inside an orchestrator, and the orchestrator behind a workspace any auditor can use. Control flow, budget and failure handling never depend on a model's judgement.

Workspace
Project workspace · set up, upload, runReview queue · flagged sectionsAudit health · readiness by controlOutputs and knowledge base
↓
Orchestration
Manager · plain-code supervisor on a background workerplan → dispatch → isolate failures → package → learnevery action streamed live and logged
↓
Agent chain
ParserRAG IndexerSchema UnderstandingSynthesisWordsmithCriticValidation (code)Style
↓
Knowledge & state
Project corpus index · one per projectPractice library · four learning collectionsTemplate schema cacheAudit knowledge base · checklist, tracker, glossary
↓
Model & tool layer
Model gateway · typed output, repair, failover, cost meterMCP client registry · HTTP and stdio, tools bound by category
↓
Outputs
Populated Word templatesPer-template and master mappingCoverage matrixClient request emailsCost breakdownSHA-256 chain of custodySubmission ZIP

Code decides, models write

The orchestrator is ordinary, testable code. The same inputs produce the same plan, and a run never stalls on an agent's indecision. Models are used only inside agents, through one gateway.

Typed handoffs

Every agent emits a schema-validated object: a drafted section, a polished section, a critique or a validation report. Free-form text never passes from one agent to the next.

One customer, one index

Each project has its own index and retrieval is scoped to it, so evidence from one customer cannot appear in another customer's pack.

MCP, stated honestly

An MCP client registry and tool bridge are built and tested; agents ask for tool categories, not hard-coded servers. The checks that will use them, such as confirming Azure AI Foundry in the customer's subscription, are on the roadmap. Until then every draft is grounded in the uploaded documents.

Memory that is scoped

A practice library keeps approved sections, critic lessons, before-and-after wording pairs and a voice profile per customer. Examples teach structure and tone only; facts must come from the current project.

Runs that survive

Every run is a dated folder with its outputs and an append-only event log. It keeps going on a background worker even if the browser is closed.

The agent chain

Nine specialists, and no agent marks its own work.

The writers (Synthesis, Wordsmith) and the checkers (Critic, Validation) are separate agents with separate instructions. Each agent has one input, one output and one clear limit.

Follow one section through the nine agents
0 / 10
prepare · once per runper-section loopfive possible outcomesParserpage + paragraph anchorsRAG Indexerone index per projectSchema Understanding74 templates · cachedManagerplain code · plans the runSynthesisdraft + citeWordsmithtighten onlyCriticdefault: disagreeValidation (code)exact-quote checkStylewrites the DOCXNot applicablepreamble · metadataRejectedkept out · flaggedAuto-approvedscore ≥ 0.85For reviewobjection attachedClient RFIemail drafted
—

AgentIts jobIts limit
ParserReads every document, keeping anchors for citationNever interprets; reports files it cannot read
RAG IndexerMakes the corpus searchable, tagged by document, page and paragraphNo cross-customer retrieval
Schema UnderstandingLearns each template and what each section is forDescribes; never writes content
ManagerPlans, dispatches, enforces the budget, packages the runA failed template is recorded; the run continues
SynthesisDrafts from the top eight retrieved chunks and approved examplesProject documents only; no evidence means a client request
WordsmithCuts padding and marketing language; applies house styleCannot add or remove facts or citations
CriticHunts unsupported claims, misquotes and personal dataCan object and route; never rewrites
ValidationPlain code: quotes, citation density, word budget, banned phrasesHard stop for a fabricated citation
StyleWrites into the original Word file, styling intactAnything not final carries a visible marker
OutcomeWhat it meansWhat happens next
Auto-approvedCleared every gate with a score of 0.85 or moreWritten as final text
For reviewA grounded draft exists, but the critic or validator raised a specific concernA reviewer accepts or edits, with the concern shown beside the draft
Client RFIThe documents hold no evidence for this sectionA draft email to the customer naming the evidence needed
RejectedA quotation could not be found in its sourceKept out of the document and flagged
Not applicablePreamble or metadataFilled automatically from project details

The contract between agents: no agent may state a fact it cannot back with a quotation retrieved in this run, and no agent may change another agent's citations.

Guardrails

Fluency is cheap. Defensibility is the product.

These controls run on every section of every run, inside the production pipeline, not in a separate test environment.

01 · Evidence onlyClosed-book drafting

The writer sees only chunks retrieved from this project and may not use general knowledge. If the chunks fall short it must return “not grounded”, with a reason.

02 · Verbatim citationQuotes checked letter for letter

Each citation quotes eight or more consecutive words, an exact substring of its chunk, with no brackets or ellipses. Only whitespace and punctuation may drift.

03 · Two-agent verificationThe writer never grades itself

A separate critic reviews every polished section. If the writer has failed over to the second provider, the critic stays on the primary, so a different model family checks the draft.

04 · Honest gapsMissing evidence becomes a request

An ungrounded section is never padded. It becomes a client request with a drafted email, and a visible marker in the document.

05 · Typed outputsFit the schema, or be refused

Every model response must fit a typed schema. Common formatting slips are repaired in code; anything still malformed is refused, never guessed at.

06 · Voice gateNo marketing, no inference verbs

A banned-phrase list blocks marketing language, exclamation marks and US spellings. The critic flags “this demonstrates” claims a chunk does not support.

How a section earns auto-approval

Four signals are multiplied: how confident the writer says it is, how well retrieval grounded the draft, the share of quotations that passed the code check, and whether the critic agreed (1.0 when it approves, 0.5 when it objects). Because they are multiplied, one weak signal pulls the whole score down. A section cannot reach auto-approval on fluency alone.

score = confidence × grounding × citation match rate × critic agreement
ScoreOutcomeAction
0.85 or moreAuto-approvedWritten as final; score kept in the audit trail
0.50 – 0.85For reviewHuman review queue, with the reason
below 0.50RejectedKept out of the document; flagged

An unresolved critic objection or validation issue sends a section to review whatever its score.

Human in the loop

People review, decide and send. The system prepares.

The workspace is built for an audit reviewer, not an engineer. Each screen answers one question in the reviewer's own terms.

Project workspace

“What do I upload, and is it running?” Four numbered steps. During a run a live agent log narrates every action and finished templates appear as they complete.

Review queue

“What needs my judgement?” Every flagged section, filterable by control, status, template or keyword, with the critic's or validator's specific reason.

Audit health

“How ready are we?” Readiness overall and by control. Templates with the longest review queues come first, so effort goes where it moves readiness most.

Outputs

“Where is the pack?” Download the submission ZIP, the master mapping or the client emails, and browse earlier runs.

Readiness, in words

Count every auto-approved section as done and every section in review as half done, because it has a grounded draft that only needs confirming. A client request counts as nothing until the evidence arrives. Divide by the sections in scope, leaving out preamble and metadata.

readiness = (auto-approved + ½ × for review) ÷ sections in scope
80%+submission-ready
60–80%finish the review queue
40–60%send the client requests now
below 40%hold a gap review meeting

The same truth in the document

Each populated Word file opens with a banner naming the project, customer, audit date and run. A section that is not final carries a short marker with its outcome and reason, for example that no retrieved evidence describes the business problem.

Each evidence gap becomes one email naming the template, the section, why the documents did not support it and what the customer should send. The delivery team reviews and sends. The system never contacts a customer on its own.

Production hardening & cost

Built for the unhappy paths of a four-hour unattended run.

Slow providers, malformed responses and exhausted credits were each observed in real runs, and each one is handled.

Reliability

  • Failover. Drafting and polishing fail over to a second provider only on hard blocks such as exhausted credit, revoked authentication or quota; each failover is tagged in telemetry
  • Failure isolation. A template that fails is recorded with its error and the run moves on; one bad document never sinks the pack
  • Schema repair before refusal. Recurring response-shape slips are corrected in code and pinned by tests
  • Retries with back-off on rate limits; a heartbeat during long model calls

Data isolation & safety

  • One index per project; retrieval physically scoped to the engagement
  • Document text enters the model as content to analyse, never as instructions, which limits prompt injection from uploaded files
  • Drafts refer to roles, not individuals; the critic flags names, emails and phone numbers
  • Provider keys in environment configuration, never in outputs or logs

Budget cap

  • A cost meter tracks spend during the run: at 70% of the cap it warns, at 90% drafting shifts to the lower-cost provider, and at 100% the run stops cleanly, records why and still packages everything completed
  • Every call metered: agent, model, input, output and cached tokens, latency, cost, error
  • Prompt caching for stable instructions; the strongest model drafts and critiques, a faster one enriches templates

Chain of custody

  • Every file in the bundle listed with its SHA-256 fingerprint and size
  • A provenance banner on every document: project, customer, audit date, run
  • A record per section: status, reason, score, retries, citation and word counts
  • Prompts live in version control and change only through reviewed commits
Evaluation harness

Each layer has its own metric, target and hard floor.

So one layer can never hide another's failure. “Every run” means the check executes inside the production pipeline on every section. “Staged” means the test is written and waits on the agent it measures.

MetricWhat it protectsTargetHard gateStatus
Citation verbatim matchEvery quote is really in its source100%any miss failsEvery run
Fabricated citations on the pageNothing invented reaches the reviewer0more than 0 failsEvery run
Word budget conformanceSections fit what the template asks forin budget±20%Every run
Banned phrases in outputNo marketing voice, no unsupported inference0more than 0 flagsEvery run
Parse success rateDocuments are read, not silently skipped≥ 99.5%95%Unit tested
Control classification, top-1Evidence lands under the right control≥ 92%80%Staged
Verifier-supported rateAn independent verifier backs each claim≥ 95%90%Staged
End-to-end hallucination rateWhole-pack factual accuracy≤ 0.5%1%Staged
Model cost per full packPredictable cost per engagement≤ US$5US$10Metered

The test suite today

Fast unit tests with no network pin the failures seen in production: twelve for response-shape repair, ten for which provider errors may and may not trigger failover, nine for how bullets and tables become native Word elements, plus schema, knowledge-base and parser contracts. 58 pass in under five seconds; 14 integration and regression tests are staged for the roadmap agents.

Golden dossiers with planted gaps

Two synthetic engagements are release-gate fixtures. One must proceed with exactly four named gaps: an unassigned Responsible AI owner, a stale Well-Architected Review, a verbal-only go-live sign-off and patient names needing redaction. The other must be found ineligible, with seven gaps including the absence of Azure AI Foundry. Both are among the staged tests.

Pilot results

A real engagement, measured end to end, read honestly.

The pilot was an Australian public-sector agency's AI assistant for analytical papers, built on Azure AI Foundry. The documents were left exactly as delivered, with no clean-up. It is a baseline, not a showcase.

What was measuredWhat it meansResult
Source documentsThe project's own files as delivered: Word, PDF, Excel, PowerPoint, a meeting transcript and others17
Templates producedEvery required template across the seven controls, written into the original Microsoft files46 of 46
Sections in scope305 sections were mapped; 45 were preamble or metadata and filled automatically260
Drafted from evidenceSections with a grounded draft citing the project's documents: 1 auto-approved, 121 waiting for review, each with a specific reason122 · 47%
Became client requestsSections the 17 documents could not support. The system said so and drafted the email instead of writing around the gap138 · 53%
Fabricated citationsQuotations that reached the page without being found in their source, at the final gate0
Readiness at baselineIn the “hold a gap review meeting” band. That is the correct call for this corpus, and the 138 requests are the agenda23.7%
Unattended run timeThe whole pack with no operator, about 2.9 minutes of processing per template4 h 14 min
Model cost, full packInside the US$10 ceiling, above the US$5 target; US$0.21 per template on average, US$0.51 at mostUS$9.91
Prompt tokens from cacheStable instructions served from the provider's cache instead of re-sent~38%
Files under chain of custodyEvery file in the bundle, each with a SHA-256 fingerprint98

Why 53% client requests is the right behaviour

Seventeen documents cannot cover a 46-template lifecycle. Much of the evidence simply was not in the corpus, and the system said so instead of writing around it. Coverage followed the documents: Handover had its evidence and reached 87% drafted; the Well-Architected Review reached 22% because the review exports were not supplied, and the client requests point at exactly those exports.

A pack that admits half its sections are waiting on the customer holds up under audit. One that looks complete and is not unravels at the first question.

ControlIn scopeDraftedClient requests
C1.1 Assess5122 · 43%29
C2.1 Design6636 · 55%30
C2.2 Well-Architected184 · 22%14
C2.3 Proof of concept3112 · 39%19
C3.1 Build5118 · 35%33
C4.1 Validate2010 · 50%10
C4.2 Handover2320 · 87%3
Total260122 · 47%138

The responsible-AI impact assessment template failed schema validation in this run, was regenerated afterwards and is not in the section count. That failure is now covered by schema-repair tests.

Only one section auto-approved, on purpose. The critic is deliberately strict and objected to most drafts, so 121 sections sit in review with a specific reason each. Tuning the writer–critic contract is the main quality lever for the next engagement. What changed for the analyst: the first-draft pass, reading every document against every section, is done by the machine. Analysts start from a mapped pack: grounded drafts to confirm, specific objections to resolve, and client emails ready to send.
Lessons & roadmap

What the pilot taught, and what ships next.

Improvements shipped after the pilot run are listed separately from the pilot results and will be measured on the next engagement.

What we sawWhat we changedStatus
First drafts read as essay paragraphs; auditors scan, they do not read proseDrafting follows each section's shape: bullets, tables, sign-off blocks, short paragraphs in the project's own vocabulary, rendered as native Word elementsShipped
A provider credit exhaustion made the critic fail mid-runCross-provider failover on hard blocks, tagged in telemetry and pinned by testsShipped
Long runs looked stalled to operatorsBackground worker, live agent log with a heartbeat, persisted event streamShipped
A response occasionally omitted a field that could be derivedSchema repair computes it before validationShipped
The critic objected to most drafts, so auto-approval stayed rareTune the writer–critic contract and feed critic lessons back to the writerNext
A “document purpose” block in some templates stayed as placeholder textTreat it as a populatable sectionNext

Track A · grounded checks over MCP

A Responsible AI watchdog grounded in Microsoft Learn, an Azure AI Foundry presence check that queries the customer's subscription through the Azure MCP server, a recency and checklist-version validator, and a Well-Architected specialist. A model's memory of a standard is not accepted as evidence.

Track B · orchestration and gates

A graph-based state machine with five named human approval gates: scope, classification, extraction, gap and risk, and pack. A control classifier, a template matcher and an independent adversarial verifier, which activate the staged tests.

Track C · enterprise integration

Evidence sync from SharePoint and tracker write-back through Microsoft 365 MCP, client requests sent through the customer's preferred channel with a person approving each send, a personal-data anonymisation agent and OCR for scanned evidence.

Technology stack

Standard, inspectable parts, chosen for traceability.

LayerComponentRole in the system
WorkspaceStreamlit, eight pagesProject workspace, review queue, audit health, outputs, the agents, knowledge base, template glossary
ContractsPython · pydantic v2Typed, validated objects between every agent
OrchestrationPlain-code Python supervisor on a background workerPlanning, dispatch, budget, failure isolation, packaging
Drafting & critiqueClaude Sonnet 4.6Synthesis, Wordsmith and Critic, structured output through forced tool use, prompt caching
Template enrichmentClaude Haiku 4.5Infers each section's intent, required fields and audit relevance, once per template
FailoverGPT-4o-miniSecond provider with JSON-schema structured output; every failover logged
Retrievaltext-embedding-3-large · ChromaDBOne persistent collection per project, plus four practice-library collections
Reading documentspython-docx · pypdf · PyMuPDF · openpyxl · python-pptx · WebVTTFormat-aware parsing with page, paragraph and heading anchors
Writing documentspython-docx · lxmlStyle-preserving write-back, native bullets and tables, provenance banner
Tool protocolModel Context Protocol, official Python SDKClient registry over HTTP and stdio, category-bound tool discovery, mock registry for tests
Integrity & testingSHA-256 manifest · pytestChain of custody across every output file; unit, integration and regression markers

Need AI output that holds up under audit?