如何在2026年构建(并评估)合同审查RAG Agent
In-house counsel asks the contract review bot: is the cap on liability acceptable on this MSA? The bot replies: “The cap is acceptable at 12 months of fees per Section 9.3.” Counsel checks. Section 9.3 is the payment-terms clause; limitation of liability lives in Section 12.4 and reads 6 months of fees. The trace shows the retriever surfaced a chunk that straddled the back half of payment terms and the front half of limitation of liability. The model grounded its answer in the chunk it got.
内部法律顾问询问合同审查机器人:这份 MSA 中的责任上限是否可以接受?机器人回答:“根据第 9.3 节,责任上限为 12 个月的费用,可以接受。”顾问进行核查。第 9.3 节是付款条款;责任限制在第 12.4 节,规定为 6 个月的费用。追踪记录显示,检索器提取了一个跨越付款条款后半部分和责任限制前半部分的文本块。模型基于其获取的文本块给出了回答。
This is the failure every contract review tutorial skips. The clause is the unit of legal reasoning. Token-counted chunking cuts across that unit and produces plausible answers that fail in legal review. The opinion this post earns: clause-level retrieval is the right primitive for contract review, not chunk-level, and a contract review agent without clause-citation eval is a liability, not a tool. Generic RAG patterns ship something that demos well. Legal-grade RAG ships something a senior partner is willing to bill against.
这是每个合同审查教程都会忽略的失败点。条款是法律推理的单位。按 token 计数的分块破坏了这一单位,产生了看似合理但在法律审查中会失败的答案。本文得出的观点是:条款级检索才是合同审查的正确原语,而非分块级,没有条款引用评估的合同审查代理是一种风险,而非工具。通用的 RAG 模式交付的产品演示效果很好。法律级的 RAG 交付的则是高级合伙人愿意据此向客户计费的产品。
This guide is the working playbook. Parse the contract so clauses stay clauses. Retrieve at clause granularity. Force the generator into structured citations and validate them deterministically. Split the eval suite by layer. Wire the LangGraph loop and instrument it. Code shaped against the ai-evaluation SDK and traceAI.
本指南是实操手册。解析合同以确保条款保持为条款。以条款粒度进行检索。强制生成器输出结构化引用并进行确定性验证。按层拆分评估套件。连接 LangGraph 循环并对其进行插桩。代码基于 ai-evaluation SDK 和 traceAI 构建。
TL;DR: the stack and the eval suite
TL;DR:技术栈与评估套件
| Layer | Choice in 2026 | What you evaluate |
|---|---|---|
| Parser | LlamaParse or Unstructured + clause segmenter | Section hierarchy, cross-reference resolution |
| Chunker | One c... |