___ _ ___ _
/ __|| | __ _ _ _ ___ ___ / __|_ _ __ _ _ _ __| |
| (__ | |/ _` || || |(_-< / -_) | (_ | || |/ _` | '_|/ _` |
\___||_|\__,_| \_,_|/__/ \___| \___|\_,_|\__,_|_| \__,_|
AI-Powered Contract Risk Intelligence
ClauseGuard is a production-grade agentic contract review system built on LangGraph. It autonomously analyzes any commercial contract, extracts every clause, assesses legal risk using LLM-driven judgment, and produces a structured risk report — with a human-in-the-loop checkpoint for critical findings.
Manual contract review is slow, expensive, and inconsistent. A junior employee might miss a missing liability cap. A busy founder signs an NDA with perpetual confidentiality obligations. An auto-renewal clause goes unnoticed until the invoice arrives.
ClauseGuard addresses this by running every contract through a multi-step agentic pipeline that:
- Extracts every clause by category with no human guidance
- Applies LLM legal reasoning — not keyword matching — to assess risk
- Identifies clauses that should exist but don't
- Generates specific, actionable recommendations
- Pauses for human review when CRITICAL risk is detected
┌─────────┐
Contract ──►│ Ingest │ Clean text, detect contract type
└────┬────┘
│
┌────▼────┐
│ Extract │ Extract all clauses by category
└────┬────┘
│
┌────▼─────────┐
│ Assess Risk │ LLM risk rating per clause
└────┬─────────┘
│
┌───── has_critical? ──────┐
│ YES │ NO
┌────▼──────────────┐ │
│ Human Checkpoint │◄── PAUSE │
│ (interrupt_before)│ │
└────┬──────────────┘ │
│ approved=True │
└──────────────────────────┤
│
┌────────▼────────┐
│ Identify Missing │ Detect absent clauses
└────────┬─────────┘
│
┌─────▼──────┐
│ Recommend │ Actionable fixes
└─────┬──────┘
│
┌────────▼────────┐
│ Generate Report │ Full RiskReport
└────────┬─────────┘
│
[END]
| Type | Examples |
|---|---|
| Employment | Offer letters, consulting agreements |
| SaaS | Software subscription, platform licenses |
| NDA | Mutual and one-way non-disclosure |
| Vendor | Supplier and procurement agreements |
| B2B | Service agreements, MSAs |
| Other | Any unclassified commercial contract |
| Layer | Technology |
|---|---|
| Agent Orchestration | LangGraph 0.2+ |
| LLM | Anthropic Claude (claude-sonnet-4-20250514) |
| LLM Client | anthropic-sdk + langchain-anthropic |
| Tracing | LangSmith |
| API | FastAPI + uvicorn |
| PDF Parsing | PyMuPDF (fitz) |
| Validation | Pydantic v2 |
| Frontend | Vanilla HTML/CSS/JS |
git clone https://github.com/yourname/clauseguard
cd clauseguard
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY and LANGCHAIN_API_KEYuvicorn api.main:app --reload --port 8000Then open frontend/index.html in your browser (double-click or serve with any static file server).
- Open the frontend in your browser
- Drag and drop a contract PDF or .txt file onto the upload zone
- Watch the agent progress through each step in real-time
- If CRITICAL risk is found, the human checkpoint panel appears — review flagged clauses, add notes, and approve or reject
- The final risk report appears with score, clause breakdown, missing clauses, and recommendations
- Export the report as JSON with one click
{
"contract_type": "SaaS",
"overall_risk_score": 87,
"overall_risk_level": "CRITICAL",
"executive_summary": "This SaaS agreement presents critical risk to the customer...",
"total_clauses_found": 9,
"clause_analyses": [
{
"clause": { "category": "Liability", "title": "Limitation of Liability", "text": "..." },
"risk_level": "CRITICAL",
"risk_reason": "No liability cap specified — Provider faces unlimited exposure.",
"specific_concerns": [
"Absence of financial cap on damages",
"Customer bears asymmetric risk"
]
}
],
"missing_clauses": [
{ "clause_name": "Service Level Agreement", "reason": "No uptime or performance guarantees." }
],
"prioritized_recommendations": [
{
"clause_category": "Liability",
"issue": "No liability cap specified",
"recommendation_text": "Negotiate a mutual liability cap of 12 months of subscription fees.",
"priority": 1
}
]
}When the assess_risk node finds any clause rated CRITICAL, the LangGraph graph pauses before human_checkpoint using LangGraph's interrupt_before mechanism. The API returns status: "awaiting_review" along with the thread ID and partial state.
The frontend renders a review panel showing all critical clauses. The reviewer can:
- Add notes
- Approve — the graph resumes and continues to identify missing clauses, generate recommendations, and produce the final report
- Reject — the graph terminates and no report is generated
Resumption is handled via POST /resume which calls graph.update_state() to inject the human decision, then graph.invoke(None, config) to continue from the checkpoint.
clauseguard/
├── agent/
│ ├── graph.py # LangGraph state machine
│ ├── state.py # AgentState TypedDict
│ ├── nodes/ # 6 agent nodes
│ └── prompts/ # System + user prompt builders
├── schemas/ # Pydantic models
├── ingestion/ # PDF parser + text preprocessor
├── api/ # FastAPI app + routes
├── frontend/ # Single-file HTML/CSS/JS UI
└── tests/ # Unit tests + sample contracts
pytest tests/ -v