Case study · client delivery for a homebuilder · Apr 2026 · v2.0 · production hardening complete

Quote Intelligence: two builders' quotes, one comparison you can trust

A sales consultant sits beside a customer who asks one question: how does this compare to the other builder's quote? Quote Intelligence answers it with a side-by-side comparison in which every dollar traces back to the line and page it came from, the arithmetic is done by code, and anything the system cannot verify is flagged instead of guessed.

My role

Principal AI Engineer. Orchestration, the no-fabrication design, the deterministic compute engine, MCP tool surface, test suites and production hardening.

Stack

React 18 · Vite · TypeScript · Python 3.12 · FastAPI with SSE · OpenAI Agents SDK · LiteLLM routing · MCP tool servers · pdfplumber with a vision-OCR fallback · SQLite → PostgreSQL · python-docx · XlsxWriter · federated identity (OIDC / SAML)

Where it runs

Inside the client's own tenant, so there is no public demo. The architecture is reproduced in an open-source edition: Read the code ↗

Watch first · about a minute

Two quotes in, one comparison you can defend.

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

The AI reasons. Ordinary code guarantees the numbers.

The consultant uploads two quotes, their own and a competitor's. Minutes later they have a side-by-side comparison: every figure traced to the exact line on the exact page, the arithmetic correct to the cent, and every uncertain item flagged for them to resolve.

Reading PDFs is not the hard part; plenty of tools do that. The hard part is trust. A language model left to itself will happily invent a plausible price. So here the model reads, matches and flags, and it never decides what a number is.

  • Every figure shows its receiptNo price reaches the comparison without the page it came from and the exact words on that page.
  • The maths is codeEvery difference, subtotal and headline saving is computed by plain arithmetic, the same kind of code that runs a spreadsheet.
  • Uncertainty is shown, not hiddenAn unverified figure turns amber, the headline total refuses to show a number, and the consultant is told exactly what to resolve.
The problem

A half-day job by hand, and a risky one with a chatbot.

Why it is slow

  • The two quotes arrive in different formats and use different words for the same thing: one says “6.6kW solar system”, the other buries it inside an “energy package”.
  • “Included” items often have no quantity, and promotional discounts expire mid-cycle.
  • The consultant maps the quotes line by line, prices the gaps and lays it out so the customer sees like against like: routinely half a day per customer.

Why generic AI makes it worse

  • Dropping both PDFs into a chatbot fails at exactly the point that matters: the numbers.
  • A model asked to compare quotes will confidently produce a figure that reads right but was never in either document.
  • In a half-million-dollar decision, one fabricated $500 line found by the customer destroys the credibility of the whole comparison, and the sale with it.
The problem, stated precisely: read line items out of two unstructured PDFs, align them across two builders' vocabularies, and reconcile the money to the cent, while making it impossible for the AI to guess a number that is not in the source.
The four ideas

Four ideas explain the whole system.

Everything technical further down is these four, made rigorous.

Idea 1

Specialists, not a generalist

Six agents with one job each: read our quote, read the competitor's, match them up, flag anything ambiguous, double-check every figure, apply edits. Every step can be inspected.

Idea 2

Every number shows its receipt

A figure enters the comparison only with its page and the exact words containing it. A price without a receipt is marked unconfirmed and set aside for a person.

Idea 3

A second opinion from a different model

A different AI model re-reads both PDFs and confirms every figure, the way two independent people are unlikely to misread the same number the same way.

Idea 4

The maths is never left to the AI

Language models are superb at language and unreliable at arithmetic, so the arithmetic is taken away from them and done in exact decimals by code.

The mechanism

A plain-code orchestrator drives six specialists.

The two readers run at the same time. Matching, flagging and the independent double-check run in sequence. Then a pure-code check and the arithmetic engine finish the job.

Watch a figure try to get through
0 / 10
Our quote · PDFCompetitor · PDFOur-quote readerpage + exact snippetCompetitor readerpage + exact snippetAlignmentone row per conceptAmbiguity flags“included”, no countVerifierdifferent model + promptWall 3 · tripwirepure-code substring checkDecimal computeno rounding driftTable · Excel · Wordone data modelUnconfirmedstickyHeadline blocks at $0explicit noteConsultant resolvespasses Wall 3 too
—

AgentWhat it does
Our-quote readerReads the homebuilder's own quote into line items; every priced row carries its page and exact source snippet
Competitor readerSame job and same evidence rule for the competitor's quote, in parallel
AlignmentMatches like for like across the two vocabularies: one row per comparable item, both sides' scope and price
Ambiguity / flagRaises review items: “included” with no quantity, a promotional discount, an unnamed brand, a missing citation
VerifierA different model re-reads both PDFs and confirms every figure against the raw page text; anything unconfirmed is demoted
Chat-reviseTurns “add a rainwater tank at $1,500, source page 7” into an edit that passes the same checks as a manual one

Why the work is split this way

Reading and matching are language tasks, suited to a fast model. Verification has to be able to disagree with the readers, so it runs on a different model, with a different temperature and prompt. The final check and the arithmetic are plain code; the model layer never touches a sum.

The orchestrator itself is plain Python, not an AI. Every stage streams a progress line to the screen, so a six-minute run never looks frozen.

The three walls

“Every number shows its receipt”, enforced three separate ways.

A single bug in any one wall cannot let a made-up figure through, because the other two still stand. Anything that fails is rewritten to Unconfirmed: amber, no value in the totals, listed for review.

Wall 1evidence or it is flaggedstructural · enforced by the output format

Every priced row must carry a page and a verbatim snippet containing the figure. The readers cannot emit a price without one, and the same rule applies whenever a person or a chat instruction changes a price.

Wall 2an independent second readerdifferent model, temperature and prompt

A different model re-reads the source and confirms each figure. A disagreement is never silently resolved: it marks the row for scrutiny.

Wall 3a literal, mechanical checkplain code · no model involved

The first two walls rely on how the AI is instructed. The third does not use AI at all. It asks one question of every figure: does the quoted snippet appear, word for word, on the page it claims?

# Wall 3, in essence: does the snippet really appear on its cited page?
return normalise(snippet) in normalise(page_text[page])
And the total tells the truthThe arithmetic engine works in exact decimal amounts, with no rounding drift across quotes worth hundreds of thousands. If any row is Unconfirmed, the headline saving blocks at $0 with a note, rather than showing a number built on a figure the system could not stand behind.
What a user actually does

Five steps from the consultant's chair.

Everything in the mechanism happens invisibly between steps 3 and 5.

  1. Enter the basicsProject address, their own name, the competitor's name, the two quote PDFs and the quote dates, which default sensibly. No customer personal details are collected.
  2. Upload the quotesBoth PDFs are read page by page. Scanned, image-only quotes go through an optional vision step; a quote with no readable text gets a clear message, not a silent wrong answer.
  3. Run the comparisonThe six agents go to work while a live panel narrates each step, with a steady heartbeat during the longer stages.
  4. Resolve the flagsProvide a missing quantity, exclude the item, or mark it for discussion. The totals stay blocked until every flag is dealt with.
  5. Review and shareAn editable side-by-side table, a Yes/No inclusions matrix, a plain-language financial position, a Word document to the house template and a colour-coded Excel workbook, all from one data model.
Benefits by audience

The value lands differently depending on who you are.

AudienceWhat changes for them
Sales consultantHalf a day back per customer, and a comparison they can defend: when a customer challenges a figure, they point to the exact source line. They can still edit any row and watch the totals recompute.
Sales leadershipEvery consultant produces the same standard of comparison in the same house format, regardless of experience, and customers get a credible answer while the decision is live.
Risk and brandThe guarantees are built into the pipeline. No setting turns them off and no path bypasses them, so a made-up number cannot reach a customer.
IT and securityCustomer names, emails and phone numbers are never collected. Access is checked per user, every action is audit-logged, and the system holds no secrets of its own.
The businessThe reasoning layer is provider-neutral, so the AI models can be swapped as they improve or terms change, without touching the guarantees or the workflow.
Under the hood · guardrails

The guarantee lives below the model layer.

The controls are proportionate to the stakes: the model may read, align and narrate; only code may produce a number that reaches a customer.

Input guardrails
Federated identity (OIDC / SAML); the app never sees a passwordSix-layer upload validation: client check, Zod schema, size 413, page count 422, text-layer 422 or OCR, reasoning budgetSSRF guard on every outbound fetch: loopback, private, link-local and reserved ranges refusedNo customer PII collected; comparisons keyed by project address
↓
System-prompt constraints
Every priced row needs a page and a verbatim snippetMissing quantities become review items, never estimatesChat edits go through the same endpoint as manual edits
↓
Output guardrails
Pydantic-typed output on every agent; a shape the schema rejects is retried, then halts the pipeline with an explicit errorCross-model verifier on a different model, temperature and promptPure-code substring tripwire; Unconfirmed is sticky
↓
Programmatic controls
Decimal arithmetic; headline blocks at $0 while any row is UnconfirmedIDOR guard: centralised access check, non-owner gets 404Every MCP tool server authenticated and audit-logged; search and fetch hard-scopedAppend-only edit history with actor, timestamp, before and after; seven-year retentionModel identifier tagged on every agent call so a fleet change is traceable

Humans where the money is

The consultant resolves every ambiguity before totals unlock, and only an explicit human action clears an Unconfirmed row, an action that itself has to pass the tripwire. Routine rows need no touch; the system asks only about what the source genuinely does not say.

Production hardening

  • Federated identity; the application never sees a password
  • IDOR guard: a non-owner gets 404, not 403, so session existence is not leaked
  • Zero secrets in code; managed-identity credential chain
  • No customer PII; comparisons keyed by project address; a persistent INTERNAL banner on every export
  • SSRF guard on every outbound fetch; six-layer upload validation
  • Reconnect-safe SSE with sequence numbers; reasoning heartbeats every ~10 s
  • Append-only audit of every field-level edit, seven-year retention

Observability and replay

  • SSE stream reports every agent handoff; reconnect-safe with sequence numbers and reasoning heartbeats
  • Because compute and tripwire are pure code, any recorded comparison replays offline against the current engine
  • Self-verifying suites print the exact assertion that broke and exit non-zero
Results

Fast enough to change the sales motion, trustworthy enough to show the customer.

Measured on real customer jobs and in the automated test suites.

Time to a full comparison. From upload to a finished, source-traced comparison on a real job, against half a day of manual mapping.

6–8 min
end to end · was half a day

Figures traced to source. The share of priced rows that carry their page and the exact words containing the figure.

100%
of priced rows

Automated checks, all passing. Four self-verifying suites run on every change: adversarial (26), data model (14), Word generation (18) and inclusion matrix (5). On a failure they print the broken assertion and stop.

63
assertions · four suites

Fabricated figures that got through. The 26 adversarial checks try to sneak a number in: a mismatched snippet, a missing snippet, an edit that should be rejected. Every attempt is caught and flagged.

0
under adversarial testing

A real customer job. A mid-tier home against a large national builder's equivalent: 21 sections and 57 line items. The system raised items for review and correctly withheld the headline saving until they were resolved, telling the consultant why.

26
items raised for review

Arithmetic to the cent. A worked example from the test suite: 1234.99 + 99.99 + 2250 + 4200, reconciled against 3580.00, with no floating-point drift.

4204.98
exactly

Scanned quotes handled, not refused. Two real jobs arrived as image-only PDFs. With the vision step on, each page is transcribed and the full comparison runs.

~10 s
per scanned page

A screen that never looks stuck. The first progress update arrives soon after a run starts, then a heartbeat roughly every ten seconds through the longer stages.

~2 s
to the first update

If a single fabricated figure can cost you the deal, this is how I build.