Due Diligence Orchestrator Code

Multi-agent contract review

AI misses things. This catches it.

Ask an AI whether a contract protects you, and “I didn't find it” looks exactly like “it isn't there.” One of those is fine. The other can cost you a lawsuit. This project makes a second AI try to prove the first one wrong — and measures how often that saves you.

21
mistakes caught by the second AI
0
times it wrongly cleared a real problem
6
test contracts, 48 checks, answers known in advance

Part one

The problem, in one example

Here is a question a lawyer asks about every contract that crosses their desk.

“If this deal goes wrong, is there a limit on how much we could be sued for?”

The AI answers: “No limit on damages found.”

It read the contract. It was 80% confident. It sounds authoritative.

liability_worker · status=MISSING · confidence=0.80 · 34 blocks examined

Part two

How it works, in three steps

No step requires you to trust the AI's word for anything.

1

Read the contract, and remember where everything is

Ingestion · no AI involved

The contract is split into paragraphs, and every paragraph keeps its page number and section number attached. That way, any answer later on can point back to the exact spot it came from. This step is ordinary code, not AI, so it behaves the same way every single time.

2

Check the contract against a checklist, one item at a time

Worker agents · Claude

The firm writes a checklist — “must limit liability”, “must say which country's law applies”, and so on. A separate AI handles each item. Crucially, to claim an item is covered, it has to quote the contract word for word. If the quote doesn't actually appear in the document, the claim is thrown away.

3

Get a second AI to try to prove the first one wrong

Adversarial verification · Gemini

Whenever the first AI says “this is missing”, a second AI — built by a different company — searches the whole contract again, using different words. Its job is not to agree. Its job is to find the clause. If it finds one real example, the first AI's answer is overturned.

Part three

Watch it work

Press play. Each step is one thing the system actually did.

Contract:

Press play to walk through this case one step at a time.

Try another case:

Part four

Did it actually work?

Six contracts were written with the answers known in advance, then run through the system — 48 checks in total. A “false alarm” means the system told you something was missing when it was really there.

Without the second AIfirst AI alone
21 false alarms
With the second AIafter double-checking
7 false alarms

The second AI overturned 21 findings. Every one of those 21 was correct — it never once wrongly cleared a problem that was genuinely there.

Show the technical metrics
ConfigurationPrecisionRecallF1False pos.False neg.
Workers only0.2220.6670.333213
+ verification0.4620.6670.54673

Positive class is an absence claim. Run with deterministic stand-in agents rather than live models, so these figures characterise the pipeline's recovery behaviour — not model accuracy. The system has never been benchmarked against Claude and Gemini, and no such claim is made.

Part five

Where it still fails

A review tool that only shows you its wins is not a review tool.

It only double-checks the “not found” answers

If the first AI says “yes, this is covered”, nobody challenges it. So a contract with a section headed “Limitation of Liability” whose text actually says “nothing shall limit either party's liability” sails straight through. The heading reassures; the body does the opposite.

All three remaining mistakes in the test set are exactly this shape. The fix — challenging “found it” answers the same way — is the next thing to build. Until then the number stays published rather than hidden.

Part six

Run it yourself

No API key needed for the first two commands — they use built-in sample contracts and cost nothing.

# get set up $ git clone https://github.com/rhain-r/legal-due-diligence-orchestrator $ cd legal-due-diligence-orchestrator && uv sync # see a contract get parsed — no AI, no key, no cost $ uv run ldd inspect agent/tests/fixtures/sample_nda.pdf # watch the second AI overturn eight findings $ uv run ldd audit agent/evals/golden/build/msa_buried.pdf --simulate --verbose