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.
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.
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
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.
Plain-English captions, no sound needed. Switch to For tech for the architecture, guardrails and evaluation detail.
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.
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.
| Phase | Controls | What the auditor needs to see |
|---|---|---|
| Assess | C1.1 | Is AI the right tool? Business case, data needs, security requirements, solution justification, customer sign-off. |
| Design | C2.1 · C2.2 · C2.3 | Solution design, Well-Architected Review, proof of concept. Responsible AI acknowledgement and impact assessment are mandatory. |
| Build | C3.1 | Signed statement of work through high-level design, low-level design and as-built. Azure AI Foundry must be in the production stack. |
| Run | C4.1 · C4.2 | User-acceptance sign-off, operational Well-Architected Review, standard operating procedures, customer acceptance. |
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.
Name the customer, project, sector, platform and audit date. The workspace creates five folders that mirror a standard project site.
Statements of work, designs, decks, spreadsheets, meeting transcripts and sign-offs, in Word, PDF, Excel, PowerPoint, VTT or text.
Every document is split into citable pieces with page, paragraph and heading kept, and indexed for this project only.
Each Microsoft template is mapped once: sections, tables, styles, word budgets and what the auditor will look for.
The Manager reads the checklist, picks templates by priority, orders them by control and sets the budget.
For every section: retrieve evidence, draft with quotes, tighten, challenge, then pass a code check of every quotation.
Text goes into the original Word file with its styling intact. Anything not final carries a visible marker and its reason.
Mappings, coverage, client emails, cost breakdown and chain of custody are zipped. Approved work feeds a practice library.
Reviewers work the queue, check readiness, download the pack and send the client requests. A re-run picks up new evidence.
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.
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.
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.
Each project has its own index and retrieval is scoped to it, so evidence from one customer cannot appear in another customer's pack.
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.
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.
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 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.
| Agent | Its job | Its limit |
|---|---|---|
| Parser | Reads every document, keeping anchors for citation | Never interprets; reports files it cannot read |
| RAG Indexer | Makes the corpus searchable, tagged by document, page and paragraph | No cross-customer retrieval |
| Schema Understanding | Learns each template and what each section is for | Describes; never writes content |
| Manager | Plans, dispatches, enforces the budget, packages the run | A failed template is recorded; the run continues |
| Synthesis | Drafts from the top eight retrieved chunks and approved examples | Project documents only; no evidence means a client request |
| Wordsmith | Cuts padding and marketing language; applies house style | Cannot add or remove facts or citations |
| Critic | Hunts unsupported claims, misquotes and personal data | Can object and route; never rewrites |
| Validation | Plain code: quotes, citation density, word budget, banned phrases | Hard stop for a fabricated citation |
| Style | Writes into the original Word file, styling intact | Anything not final carries a visible marker |
| Outcome | What it means | What happens next |
|---|---|---|
| Auto-approved | Cleared every gate with a score of 0.85 or more | Written as final text |
| For review | A grounded draft exists, but the critic or validator raised a specific concern | A reviewer accepts or edits, with the concern shown beside the draft |
| Client RFI | The documents hold no evidence for this section | A draft email to the customer naming the evidence needed |
| Rejected | A quotation could not be found in its source | Kept out of the document and flagged |
| Not applicable | Preamble or metadata | Filled 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.
These controls run on every section of every run, inside the production pipeline, not in a separate test environment.
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.
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.
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.
An ungrounded section is never padded. It becomes a client request with a drafted email, and a visible marker in the document.
Every model response must fit a typed schema. Common formatting slips are repaired in code; anything still malformed is refused, never guessed at.
A banned-phrase list blocks marketing language, exclamation marks and US spellings. The critic flags “this demonstrates” claims a chunk does not support.
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 | Outcome | Action |
|---|---|---|
| 0.85 or more | Auto-approved | Written as final; score kept in the audit trail |
| 0.50 – 0.85 | For review | Human review queue, with the reason |
| below 0.50 | Rejected | Kept out of the document; flagged |
An unresolved critic objection or validation issue sends a section to review whatever its score.
The workspace is built for an audit reviewer, not an engineer. Each screen answers one question in the reviewer's own terms.
“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.
“What needs my judgement?” Every flagged section, filterable by control, status, template or keyword, with the critic's or validator's specific reason.
“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.
“Where is the pack?” Download the submission ZIP, the master mapping or the client emails, and browse earlier runs.
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.
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.
Slow providers, malformed responses and exhausted credits were each observed in real runs, and each one is handled.
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.
| Metric | What it protects | Target | Hard gate | Status |
|---|---|---|---|---|
| Citation verbatim match | Every quote is really in its source | 100% | any miss fails | Every run |
| Fabricated citations on the page | Nothing invented reaches the reviewer | 0 | more than 0 fails | Every run |
| Word budget conformance | Sections fit what the template asks for | in budget | ±20% | Every run |
| Banned phrases in output | No marketing voice, no unsupported inference | 0 | more than 0 flags | Every run |
| Parse success rate | Documents are read, not silently skipped | ≥ 99.5% | 95% | Unit tested |
| Control classification, top-1 | Evidence lands under the right control | ≥ 92% | 80% | Staged |
| Verifier-supported rate | An independent verifier backs each claim | ≥ 95% | 90% | Staged |
| End-to-end hallucination rate | Whole-pack factual accuracy | ≤ 0.5% | 1% | Staged |
| Model cost per full pack | Predictable cost per engagement | ≤ US$5 | US$10 | Metered |
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.
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.
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 measured | What it means | Result |
|---|---|---|
| Source documents | The project's own files as delivered: Word, PDF, Excel, PowerPoint, a meeting transcript and others | 17 |
| Templates produced | Every required template across the seven controls, written into the original Microsoft files | 46 of 46 |
| Sections in scope | 305 sections were mapped; 45 were preamble or metadata and filled automatically | 260 |
| Drafted from evidence | Sections with a grounded draft citing the project's documents: 1 auto-approved, 121 waiting for review, each with a specific reason | 122 · 47% |
| Became client requests | Sections the 17 documents could not support. The system said so and drafted the email instead of writing around the gap | 138 · 53% |
| Fabricated citations | Quotations that reached the page without being found in their source, at the final gate | 0 |
| Readiness at baseline | In the “hold a gap review meeting” band. That is the correct call for this corpus, and the 138 requests are the agenda | 23.7% |
| Unattended run time | The whole pack with no operator, about 2.9 minutes of processing per template | 4 h 14 min |
| Model cost, full pack | Inside the US$10 ceiling, above the US$5 target; US$0.21 per template on average, US$0.51 at most | US$9.91 |
| Prompt tokens from cache | Stable instructions served from the provider's cache instead of re-sent | ~38% |
| Files under chain of custody | Every file in the bundle, each with a SHA-256 fingerprint | 98 |
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.
| Control | In scope | Drafted | Client requests |
|---|---|---|---|
| C1.1 Assess | 51 | 22 · 43% | 29 |
| C2.1 Design | 66 | 36 · 55% | 30 |
| C2.2 Well-Architected | 18 | 4 · 22% | 14 |
| C2.3 Proof of concept | 31 | 12 · 39% | 19 |
| C3.1 Build | 51 | 18 · 35% | 33 |
| C4.1 Validate | 20 | 10 · 50% | 10 |
| C4.2 Handover | 23 | 20 · 87% | 3 |
| Total | 260 | 122 · 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.
Improvements shipped after the pilot run are listed separately from the pilot results and will be measured on the next engagement.
| What we saw | What we changed | Status |
|---|---|---|
| First drafts read as essay paragraphs; auditors scan, they do not read prose | Drafting follows each section's shape: bullets, tables, sign-off blocks, short paragraphs in the project's own vocabulary, rendered as native Word elements | Shipped |
| A provider credit exhaustion made the critic fail mid-run | Cross-provider failover on hard blocks, tagged in telemetry and pinned by tests | Shipped |
| Long runs looked stalled to operators | Background worker, live agent log with a heartbeat, persisted event stream | Shipped |
| A response occasionally omitted a field that could be derived | Schema repair computes it before validation | Shipped |
| The critic objected to most drafts, so auto-approval stayed rare | Tune the writer–critic contract and feed critic lessons back to the writer | Next |
| A “document purpose” block in some templates stayed as placeholder text | Treat it as a populatable section | Next |
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.
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.
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.
| Layer | Component | Role in the system |
|---|---|---|
| Workspace | Streamlit, eight pages | Project workspace, review queue, audit health, outputs, the agents, knowledge base, template glossary |
| Contracts | Python · pydantic v2 | Typed, validated objects between every agent |
| Orchestration | Plain-code Python supervisor on a background worker | Planning, dispatch, budget, failure isolation, packaging |
| Drafting & critique | Claude Sonnet 4.6 | Synthesis, Wordsmith and Critic, structured output through forced tool use, prompt caching |
| Template enrichment | Claude Haiku 4.5 | Infers each section's intent, required fields and audit relevance, once per template |
| Failover | GPT-4o-mini | Second provider with JSON-schema structured output; every failover logged |
| Retrieval | text-embedding-3-large · ChromaDB | One persistent collection per project, plus four practice-library collections |
| Reading documents | python-docx · pypdf · PyMuPDF · openpyxl · python-pptx · WebVTT | Format-aware parsing with page, paragraph and heading anchors |
| Writing documents | python-docx · lxml | Style-preserving write-back, native bullets and tables, provenance banner |
| Tool protocol | Model Context Protocol, official Python SDK | Client registry over HTTP and stdio, category-bound tool discovery, mock registry for tests |
| Integrity & testing | SHA-256 manifest · pytest | Chain of custody across every output file; unit, integration and regression markers |