Skip to content
< all work

Agents & MCP · A real-estate developer's finance team · 2026

Document-grounded review assistant for lender and partner agreements

Reviews loan, guaranty and partnership agreements clause by clause against the team's key terms. Every flag carries a verified quote and a proposed redline, and the assistant proposes changes that a person applies.

agent-systemsgroundingllm-evaluation

A first-pass review where code checks every quote and number the model gives, and nothing changes until an analyst presses Apply. The demo runs on public SEC EDGAR filings.

Role
Sole engineer
Stack
Python · FastAPI · PostgreSQL · Alembic · OpenAI API · Tool calling · OpenTelemetry · Docker · pytest
The built-in tour over the demo data: four public SEC EDGAR filings, reviewed.

A real-estate developer's finance team reviews loan agreements, guaranties and partnership agreements against its own standard positions. I built a tool that does the first review. It checks every clause, down to each sub-paragraph, and each issue comes with the exact wording from the draft, a proposed redline, the fallback position and a precedent. The demo runs on public SEC EDGAR filings behind a passcode, with sample users in different roles.

The review is a background pipeline where code and model each do what they are good at. Code parses the draft into clauses and shortlists candidate pairs of clause and key term. A model judges each pair in parallel and returns structured JSON: a verdict, a materiality level, a verbatim quote and the numbers it relied on. Code then verifies. The quote must be an exact span of the clause, every number in the reason must appear in the clause or the key term, and limit comparisons are recomputed in code. Anything that fails is dropped and logged. Redlines must touch only the flagged span and keep every defined term, or the tool falls back to the standard wording.

The assistant answers questions about the drafts with read tools for drafts, clauses, key terms, precedents and the document library, and lists the sources it actually read. Every write tool comes in two halves. The describe half shows a proposal card. The apply half runs only when a person presses Apply, and the server checks that person's role. Only the terms keeper can change key terms, and only an admin can manage model keys.

For evaluation I built a gold set: two models label every clause and term pair blind, agreements go straight in, and each disagreement is adjudicated by reading the clause, with the reason logged. Candidate judge models are scored against it on recall of material issues, precision, materiality agreement and stability across repeated runs. The test suite never calls a model provider, so the evidence guarantees hold whichever model is chosen.

Architecture: drafts and key terms feed a parse, shortlist, judge, verify and redline pipeline; flags go to an assistant and an analyst; a gold set scores judge models
Code finds candidates and checks evidence. The model judges and drafts. A person decides.
All drafts: four reviewed EDGAR agreements with counterparties, open material and minor issue counts, and review status.
Every draft the team has run through a first review, with what is still open.
A limited partnership agreement with clause 4.3(c)(ii) flagged: the reason, the quoted wording, a tracked redline in the draft and the panel, the fallback, and 'Quote checked against the draft'.
One flag: why it matters, the exact wording, the redline, the fallback. The quote is verified in code before it is shown.
Key terms table: topic, preferred position, fallback, source and whether a miss is material or minor.
The standard positions every draft is checked against. Thresholds are compared in code, not by the model.
The assistant answering 'What does the Tradeport loan say about cross-default?': its search and read steps, an answer citing clause 5.1(c), and one source listed, Clause 5.1.
The assistant shows the steps it took and lists only the clauses it actually read.
A guided tour step, 10 of 19, explaining that every issue carries its reason, wording, redline, fallback and precedent.
A 19-step tour walks a first-time user through the workspace, a review, key terms, the assistant and settings.