LPA Safety Score
The LPA Safety Score (0–100) is the primary output of the /fund review-lpa command and the automated inbox review pipeline.

How It Works
Five agents run in parallel, each analysing a different dimension of the LPA. Their scores are combined as a weighted average.
| Agent | Role | Weight |
|---|---|---|
fund-terms | Term extraction & categorisation | 20% |
fund-risks | Risk scoring (1–10 per provision) | 25% |
fund-compliance | Regulatory compliance checks | 20% |
fund-obligations | Obligations & timeline mapping | 15% |
fund-recommendations | Negotiation recommendations | 20% |
Agent data flows linearly: the Terms agent output feeds into Risk, Compliance, Obligations, and Recommendations agents.

Grade Thresholds
| Score | Grade | Interpretation |
|---|---|---|
| 90–100 | A | Investor-favourable, minor concerns only |
| 75–89 | B | Standard market terms with some negotiation points |
| 60–74 | C | Material issues, negotiation recommended |
| 45–59 | D | Significant risk, legal review required |
| 0–44 | F | Highly investor-unfavourable, do not sign without major revisions |

Implementation
The pipeline runs via the Anthropic SDK directly in apps/web/src/lib/review-pipeline.ts. It does not depend on the claude CLI binary.
PDF Prompt Caching
The document is sent once with cache_control: ephemeral. All five agent calls share the cached prefix, significantly reducing API cost for large documents.
Input Format
interface ReviewResult {
fundSlug: string;
fundName: string;
documentName: string;
reviewedAt: string;
safetyScore: number; // 0–100
grade: 'A' | 'B' | 'C' | 'D' | 'F';
verdict: string;
agents: AgentResult[];
totalFindings: number;
}Findings Severity
Each finding carries a severity level: high, med, or low. The compliance tracker raises macOS notifications for High Risk findings when running locally.
Triggering a Review
Via CLI (T1)
/fund review-lpa path/to/lpa.pdfVia Webapp Upload (T3)
Drop a PDF into the upload UI at /w/[slug]/upload. The inbox watcher picks it up within 30 seconds and triggers the pipeline automatically.
Via API (T3)
curl -X POST http://localhost:3000/api/review/trigger \
-H "Content-Type: application/json" \
-d '{"filename": "apex-lpa-2024.pdf", "fundId": "..."}'Via Direct Upload API
curl -X POST http://localhost:3000/api/upload \
-H "x-api-key: $UPLOAD_API_KEY" \
-F "file=@apex-lpa-2024.pdf"Intentional Test Issues
The sample LPA (generate_sample_lpa.py) contains 10 intentional issues for validating detection:
- Aggressive carry (25%, no hurdle)
- Weak clawback
- Broad GP discretion on investment period extension
- No LPAC consent for affiliate transactions
- Vague fee offsets
- Missing key person provision
- Overly broad confidentiality
- 120-day opt-out trap
- Free GP assignment
- No excuse/exclusion rights