Agentic Legal — Contract Clause Review

A contract-reviewer agent that diffs an inbound MSA against your standard playbook AND your recent negotiated precedents — surfacing deviations with the closest prior deal as a reference.

All recipes· agents· 12 minutesintermediateen
Instance: localhost:8080

Opens your running SynapCores (Agentic Legal — Contract Clause Review will be staged for a preview — nothing runs until you click Run). No instance yet? Install free in ~30s.

Share

Objective

Reviewing an inbound MSA against your playbook is a 4-hour paralegal job. The hard part isn't reading the contract — it's remembering what you agreed to in similar past deals. This recipe wires a contract-reviewer that retrieves your standard clauses + your closest precedent and produces a clause-by-clause delta.

Step 1: Create standard clauses, precedents, the inbound MSA

CREATE TABLE IF NOT EXISTS recipe_lg_standard_clauses (
  clause_id   INTEGER PRIMARY KEY,
  topic       TEXT,
  body        TEXT,
  embedding   VECTOR(384)
);

CREATE TABLE IF NOT EXISTS recipe_lg_precedents (
  precedent_id  INTEGER PRIMARY KEY,
  counterparty  TEXT,
  industry      TEXT,
  acv_band      TEXT,
  notes         TEXT,
  embedding     VECTOR(384)
);

CREATE TABLE IF NOT EXISTS recipe_lg_inbound_clauses (
  inbound_id  INTEGER PRIMARY KEY,
  msa_name    TEXT,
  topic       TEXT,
  body        TEXT
);

Step 2: Seed

INSERT INTO recipe_lg_standard_clauses (clause_id, topic, body) VALUES
 (1,'Liability Cap','Total liability is capped at the fees paid in the 12 months preceding the claim, subject to standard carve-outs for IP indemnity, breach of confidentiality, and gross negligence.'),
 (2,'IP Indemnity','Vendor will defend and indemnify customer against third-party claims that the service infringes patent, copyright, or trade secret rights.'),
 (3,'Data Residency','Customer data is stored in the customer-selected region. Cross-region replication occurs only with customer consent and under the same residency commitment.'),
 (4,'Termination for Convenience','Either party may terminate for convenience with 90 days written notice. Pre-paid unused fees are refunded pro-rata.'),
 (5,'Auto-Renewal','Subscription auto-renews for successive 1-year terms unless either party gives 60 days written notice prior to the renewal date.');

INSERT INTO recipe_lg_precedents (precedent_id, counterparty, industry, acv_band, notes) VALUES
 (1,'Acme Bank',          'Financial Services','$500k+','Forced "Liability Cap = 2x annual fees" — concession because of regulator pressure. Approved by GC.'),
 (2,'Helios Hospital',    'Healthcare',        '$100k-500k','Accepted BAA addendum + HIPAA carve-out for liability. No cap change.'),
 (3,'NorthernHydro',      'Utilities',         '$100k-500k','Data residency = EU-only, no cross-region replication permitted. Accepted.'),
 (4,'Riverbed Devops',    'Software',          '$50k-100k','Standard MSA accepted with no edits. 2-day cycle.'),
 (5,'BlueTrust Insurance','Insurance',         '$500k+','Required termination-for-convenience cut to 30 days; CFO declined; closed at 90 days standard.');

INSERT INTO recipe_lg_inbound_clauses (inbound_id, msa_name, topic, body) VALUES
 (1,'Acme-2026-MSA','Liability Cap',            'Vendor''s total liability for any and all claims arising under this Agreement shall be capped at three (3) times the fees paid in the 24-month period preceding the claim.'),
 (2,'Acme-2026-MSA','Termination for Convenience','Customer may terminate this Agreement for convenience upon thirty (30) days'' written notice. Vendor may not terminate for convenience.'),
 (3,'Acme-2026-MSA','Data Residency',           'All Customer Data shall be stored exclusively within the United States. No cross-border transfer is permitted under any circumstance.');

Step 3: Embed

UPDATE recipe_lg_standard_clauses SET embedding = EMBED(topic || ': ' || body);
UPDATE recipe_lg_precedents       SET embedding = EMBED(counterparty || ' ' || industry || ': ' || notes);

Step 4: Ground truth — find the matching standard clause

SELECT topic, COSINE_SIMILARITY(embedding, EMBED('Liability Cap: 3x fees over 24 months')) AS sim
FROM recipe_lg_standard_clauses ORDER BY sim DESC LIMIT 1;

Expected: Liability Cap matches.

Step 5: Ground truth — find the most similar precedent

SELECT counterparty, notes, COSINE_SIMILARITY(embedding, EMBED('Financial Services counterparty pushing liability cap above standard')) AS sim
FROM recipe_lg_precedents ORDER BY sim DESC LIMIT 2;

Expected: Acme Bank ranks first (similar pain, prior concession).

Step 6: Hand the MSA to the agent

SELECT AGENT_RUN(
  'aidb-assistant',
  'You are a contract-review assistant. Review every clause in recipe_lg_inbound_clauses for the MSA "Acme-2026-MSA". For each clause: use rag_search on recipe_lg_standard_clauses to find the corresponding standard clause; use rag_search on recipe_lg_precedents to find the closest prior negotiation. Output for each: (a) the inbound text, (b) our standard text, (c) the most similar precedent and what we accepted there, (d) a redline recommendation — accept, push back, escalate to GC. Be specific about which precedent you cited.'
) AS msa_review;

Cleanup

DROP TABLE IF EXISTS recipe_lg_standard_clauses;
DROP TABLE IF EXISTS recipe_lg_precedents;
DROP TABLE IF EXISTS recipe_lg_inbound_clauses;

Use it from your agent

  • REST/SDK: drop inbound clauses into the table at intake (parse the PDF first), then call Step 6 — the redline arrives by the time the lawyer opens the document.
  • MCP: call query from your contract-management tool.
  • Why in-DB: the legal precedent table is yours. A generic LLM only knows "industry standard"; SynapCores knows what you signed last quarter with a similar counterparty.

Key Concepts Learned

  • Legal review is a clause-by-clause diff against two sources: standard playbook + your precedent.
  • Embedding precedents with counterparty + industry + notes makes the "what did we accept here last time" lookup precise.
  • The agent doesn't replace the lawyer — it gets them to the first redline 8x faster.

Tags

ai-agentagent-runlegalcontractsmsaclause-comparisonragprecedent

Run this on your own machine

Install SynapCores Community Edition free, paste the SQL or Cypher above into the bundled web UI, and watch it run.

Download Free CE