ClauseGuard
Multi-agent contract & policy review pipeline
Upload a contract, get back a risk verdict — so a human reviewer starts from a report instead of a blank document.
3
Specialised agents
23
Test suite
2
LLM backends
01The problem
Legal, procurement and compliance teams read long contracts by hand to spot auto-renewal traps, low liability caps and one-sided indemnity. It's slow, inconsistent between reviewers, and doesn't scale.
02The approach
Three LangGraph agents automate the first pass: the Extractor segments the document into labeled clauses, the Risk Analyzer checks each against a configurable rule set, and the Summarizer writes a plain-English verdict.
03Architecture — the camera follows the data
How it works
> Every arrow here is a Pydantic-validated hand-off.
Step 1: Upload
PDF or text
Step 2: Extractor
labeled clauses
Step 3: Risk Analyzer
rules × BM25 + embeddings
Where the work happens
Step 4: Summarizer
plain-English summary
Step 5: Verdict
e.g. HIGH_RISK
Where the work happens
04Perks — why it's built this way
The edge
Validated hand-offs
Every hand-off between agents is checked against a Pydantic schema, so a malformed step fails loudly instead of flowing downstream.
Hybrid retrieval that degrades
BM25 keyword search fused with local Ollama embeddings by reciprocal rank fusion — and keyword-only, automatically, when no embedding model is present.
Two backends, chosen per run
Local Ollama for free offline runs, the Anthropic API for higher-quality paid ones. One LLM seam, so tests mock exactly one thing.
Evals, not vibes
An eval harness scores the model on labeled documents — recall, precision, latency, tokens and cost per case — separate from the 23 offline unit tests.
05Tech — and what each part does
The stack
- Python
- Pipeline and rules
- LangGraph
- Three-agent state graph
- FastAPI
- POST /review, history, web UI
- Pydantic
- Schema on every hand-off
- Ollama
- qwen2.5:7b + nomic-embed-text, local
- Anthropic API
- Paid, higher-quality backend
- SQLite
- Review audit history
- pytest
- 23 tests, every LLM call mocked
07Known limits — stated plainly
Where it doesn't win
- No retry yet when the model returns malformed JSON.
- No OCR — scanned PDFs aren't readable.
- No human-review queue for low-confidence extractions.