Skip to content
Back to all work
AI Engineering · Retrieval · Security

Secure, Grounded AI Assistant for Due Diligence

A deal-scoped RAG assistant with corrective retrieval, user-selectable depth, SQL-backed portfolio analytics, and permission checks that stop data leaking between deals.

Role
AI / Backend Engineer (contractor) — chat orchestration, retrieval, and AI security.
Status
Anonymized
Deal-scoped chat — corrective retrieval + SQL analytics
Question+ chat modeScope checkpermission serviceClassifyintentdocsRetrievek = 5 / 20 / 30Grade evidence0–3 roundsretryenoughGeneratecited answerportfolioSlot-fillfixed vocabularySQL aggregaterow-level accessNarrateno maths
01 / OVERVIEW

What this is

An AI platform that helps private-equity deal teams and investment committees run due diligence faster. Its chat assistant answers questions about a deal from uploaded documents, with citations; separate pipelines produce findings, financial models, and committee memos for each deal.

Every deal is confidential, and users only have access to some of them — so the assistant has to be grounded and correctly scoped.

Domain
Private-equity due diligence
My role
Chat orchestration, retrieval, AI security
Engagement
Contractor
02 / THE PROBLEM

What needed to be solved

Three problems stood out. Every question ran the full corrective-retrieval loop (4–6 s), even simple lookups. Portfolio questions like "average EBITDA across our consumer deals" were either refused as off-topic or answered by pasting numbers into a prompt and letting the model do the maths. And testing found that a crafted prompt — or just a company name the model mis-matched — could pull documents from another deal into the answer.

03 / MY CONTRIBUTION

What I owned

I owned the chat-mode feature, the structured portfolio-analytics path, and the server-side fixes for cross-deal data leakage. I also built voice-assistant backend pieces and worked on the evaluation tasks (guardrails, error states, latency).

Owned
Chat modes, portfolio analytics, deal-scoping fixes
Contributed
Voice assistant backend, evaluation suites
04 / TECHNICAL DESIGN

Architecture & decisions

The chat runs as an agent workflow graph: resolve deal context → check scope → classify intent → retrieve from the search index → grade the evidence (re-retrieving if it's not good enough) → generate a cited answer. Documents are parsed by a document-intelligence service and indexed per deal.

Portfolio questions go down a separate path. The LLM only fills slots from a fixed vocabulary (group-by, metric, aggregate, filter); anything outside it is dropped before reaching SQL. The database computes the result under the same row-level access rules as the deal list, and a second LLM call only narrates it. The model never writes SQL and never does arithmetic.

Deal-scoped chat — corrective retrieval + SQL analytics
Question+ chat modeScope checkpermission serviceClassifyintentdocsRetrievek = 5 / 20 / 30Grade evidence0–3 roundsretryenoughGeneratecited answerportfolioSlot-fillfixed vocabularySQL aggregaterow-level accessNarrateno maths
05 / IMPLEMENTATION

How it was built

Chat modes added a chat_mode field to the contract, wired through the whole chain down to each graph node: Quick (k=5, no grading, < 1 s), Standard (k=20, 2 corrective rounds, 4–6 s) and Deep (k=30, 3 rounds, 8–15 s). It shipped with 15 tests, and Standard stays the default, so existing users see no change.

For deal scoping I applied defense in depth: any cross-deal ID sent by the client is checked against the permission service (view) on the server; a deal the model detects in a question must be in the user's authorized set; and the cross-deal handler re-checks before fetching documents. The voice backend added HMAC-signed tool webhooks with session and idempotency tables, plus a speech-synthesis endpoint and spoken "thinking fillers" to cover retrieval latency.

Modes
Quick / Standard / Deep — latency vs depth
Analytics
Closed-vocabulary slots → SQL → narrate
Security
3-layer server-side deal-scope checks
06 / OUTCOME

Results & lessons

Users can trade speed for depth per question, portfolio questions are answered with computed numbers instead of refusals or LLM arithmetic, and cross-deal retrieval now passes server-side permission checks instead of trusting the prompt or the client.

Next improvements I proposed: treat expected outcomes such as "no relevant documents" as normal chat answers instead of errors that trigger a retry toast, and add a deterministic guard so the active deal's own name can never be detected as a different deal.

Lesson: an LLM can choose; it shouldn't compute or authorize. Constrain its choices to a fixed vocabulary and enforce permissions in code.

07 / NEXT STEP

Have a similar challenge?

If your AI assistant sits on confidential, permissioned data — and you need answers that are grounded, fast enough, and can't leak — let's talk about your retrieval and access model.