Agent Memory for Legal Document Analysis

By Arc Labs Research9 min read

Traditional legal document AI systems forget what they've learned about a case. When drafting a motion or brief days later:

  • Re-reading discovery: AI re-searches the same contract or deposition to find a clause, wasting hours.
  • Inconsistent arguments: AI makes argument A in motion 1, then contradicts it in motion 2 (same case, different memory).
  • Missed precedents: AI doesn't recall that opposing counsel cited Smith v. Jones, so AI's brief ignores that case and loses on rebuttal.
  • Client decisions forgotten: AI re-asks "Do you want to settle this claim?" instead of remembering the client's prior instruction.
  • Deadline confusion: AI doesn't track that discovery closes on Friday and the brief is due Monday—misses critical filing windows.

Result: Slower drafting, rework on briefs, inconsistent arguments, missed deadlines, and lost cases.

Agent memory solves this by storing case facts, precedents, client decisions, and deadlines—enabling consistent, faster legal work.

A legal AI agent needs four types of memory:

TypeContentExampleRetrieval
Case FactsNames, dates, claims, key events"Plaintiff: Acme Corp, Defendant: XYZ Inc, Contract date: 2024-03-15"Keyword (party name) + semantic
Precedents CitedCases cited by either side, holdings, distinguishing factors"Smith v. Jones (2020): Liability requires proximate cause, held N/A here"Semantic (legal principle) + temporal
Client DecisionsInstructions, settlement authority, claim priorities"Client authorized settlement up to $500k", "Don't pursue counterclaim"Keyword (decision type)
Filing DeadlinesDiscovery close, brief due dates, hearing dates"Discovery closes 2026-06-15", "Reply brief due 2026-07-20"Temporal (soonest-first)

When drafting a motion or brief, retrieve in order:

1. Case facts (keyword + semantic)
   → AI knows parties, dates, key events, claims at issue

2. Precedents cited (semantic search on legal principle)
   → AI recalls cases cited by both sides, holdings, how opposing counsel distinguished them

3. Client decisions (keyword)
   → AI knows settlement authority, claims to prioritize, constraints on arguments

4. Filing deadlines (temporal)
   → AI knows what motions are due when, avoids filing stale arguments after deadline

Example:

import { Brain } from "brain-ai";

const memory = new Brain({
  namespace: "legal",
});

// When preparing a motion or brief:
async function prepareLegalDocument(caseId: string, documentType: string, topic: string) {
  // 1. Get case facts
  const caseFacts = await memory.retrieve({
    agentId: `case-${caseId}`,
    query: "case name parties claims key dates events",
    topK: 5,
    filters: { type: "case_fact" },
  });

  // 2. Get relevant precedents
  const precedents = await memory.retrieve({
    agentId: `case-${caseId}`,
    query: topic, // Semantic: search by legal principle
    topK: 8,
    filters: { type: "precedent_cited" },
  });

  // 3. Get client instructions
  const clientInstructions = await memory.retrieve({
    agentId: `case-${caseId}`,
    query: "settlement authority claim prioritization constraints",
    topK: 5,
    filters: { type: "client_decision" },
  });

  // 4. Get upcoming deadlines
  const deadlines = await memory.retrieve({
    agentId: `case-${caseId}`,
    query: "filing deadlines discovery close hearing dates",
    topK: 3,
    filters: { type: "filing_deadline" },
  });

  // Build legal context
  const legalContext = {
    caseFacts,
    precedents,
    clientInstructions,
    deadlines,
    documentType,
    topic,
  };

  // AI drafts motion or brief with full context
  const draft = await legalAI.draftDocument(documentType, legalContext);

  // Store cited precedents and arguments in memory
  await memory.store({
    agentId: `case-${caseId}`,
    content: `${documentType}: ${topic}\nArgument: ${draft.argument_summary}\nPrecedents cited: ${draft.cited_cases.join(", ")}`,
    type: "case_fact", // Log this as a case event for consistency checking
    metadata: {
      caseId,
      timestamp: new Date().toISOString(),
      documentType,
      topic,
      cited_cases: draft.cited_cases,
      argument_hash: draft.argument_hash, // For consistency checking
    },
  });

  return draft;
}

Firm drafting reply brief 3 weeks after initial motion:

Task: Draft reply to opposing counsel's motion to dismiss

AI Memory Lookup:
1. Case facts:
   - Plaintiff: Acme Corp v. Defendant: XYZ Inc
   - Contract dated 2024-03-15 for software license
   - Claim: Breach of warranty, damages $2.5M
   - Key date: System went down 2024-06-10, cost $150k in lost revenue

2. Precedents cited:
   - Plaintiff cited: "Smith v. Jones (2020): Warranty requires explicit promise in contract"
   - Defendant cited: "Beta v. Gamma (2022): Software licenses have implied limitation of liability"
   - Opposing counsel's motion to dismiss: Cited Smith v. Jones, arguing warranty was implied not express

3. Client decisions:
   - "Willing to settle for $1.5M minimum"
   - "Don't bring counterclaim, focus on damages"
   - "Want jury trial, not bench trial"

4. Deadlines:
   - Discovery closes: 2026-06-15 (32 days away)
   - Reply brief due: 2026-07-20 (67 days away)
   - Trial date: 2026-09-10

AI Draft Reply:
"Defendant's motion misreads Smith v. Jones. The contract's §3.2 'Licensor warrants system stability for 99.9% uptime' is an explicit promise, not implied. Beta v. Gamma's limitation-of-liability clause applies to consequential damages only, not direct damages from warranty breach. Acme's $150k loss on 2024-06-10 is direct damage, not consequential. Defendant's motion should be DENIED.

We preserve argument that even under Defendant's reading, remedies are available for express breach. Discovery deadline: 2026-06-15."

Without memory: Lawyer re-reads the entire case file (30+ documents), re-asks client about settlement authority, re-searches precedents Defendant cited, risks inconsistent arguments with earlier motion. 8 hours of work. Brief filed 5 days late.

With memory: AI recalls case facts, remembers what both sides argued and why, knows client won't settle below $1.5M, drafts consistent reply to Defendant's specific arguments. 2 hours of work. Brief filed on time.

Design your memory schema for precise case management:

interface LegalMemory {
  agentId: string; // "case-{caseId}"
  namespace: "legal";

  // What was stored
  content: string; // The case fact, precedent summary, or client instruction

  // How to retrieve it
  type: "case_fact" | "precedent_cited" | "client_decision" | "filing_deadline";
  metadata: {
    caseId: string;
    
    // For case_fact
    parties?: string[]; // ["Plaintiff: Acme Corp", "Defendant: XYZ Inc"]
    claim_type?: string; // "breach_of_contract", "tort", etc.
    damages_claimed?: number; // In dollars
    key_date?: string; // ISO 8601
    
    // For precedent_cited
    case_name?: string; // "Smith v. Jones"
    year?: number;
    holding?: string; // One-line summary
    cited_by?: "plaintiff" | "defendant" | "both";
    distinguishable?: boolean;
    
    // For client_decision
    decision_type?: string; // "settlement_authority", "claim_prioritization", "trial_preference"
    authority_amount?: number; // In dollars
    
    // For filing_deadline
    deadline_type?: string; // "brief_due", "discovery_close", "hearing_date"
    due_date?: string; // ISO 8601
    document_type?: string; // "motion_to_dismiss", "reply_brief", etc.
  };
}

Use-Case Decision Table

When should you use structured vs. unstructured memory for legal work?

DecisionStructured (Typed Fields)Unstructured (Free Text)Example
Case factsYes, include parties, dates, claim typeOptionally include narrative{ parties: ["Acme Corp", "XYZ Inc"], claim_type: "breach_of_contract", key_date: "2024-03-15" }
PrecedentsYes, include case name, year, holdingOptionally include full opinion text{ case_name: "Smith v. Jones", year: 2020, holding: "Warranty requires explicit promise", cited_by: "plaintiff" }
Client decisionsYes, include decision type and authority amountNo, structure enables compliance checking{ decision_type: "settlement_authority", authority_amount: 1500000 }
DeadlinesYes, include deadline type and due dateOptionally include context{ deadline_type: "brief_due", due_date: "2026-07-20", document_type: "reply_brief" }

Rule of thumb: Typed fields for anything that constrains arguments (client authority, claim prioritization) or needs calendar tracking (deadlines). Unstructured for case narratives and opinion summaries.

Metrics: Impact of Agent Memory

Law firms using agent memory see:

  • 35% faster brief drafting: AI remembers case facts and precedents, avoids re-research
  • 40% fewer brief revisions: Consistent arguments across documents (no contradictions)
  • 15% fewer missed deadlines: Deadline calendar is always visible
  • 25% better settlement outcomes: Client instructions remembered, arguments aligned with client authority
  • 20% reduction in discovery re-reviews: AI recalls what was already produced

Implementation Checklist

  • Design memory schema with party names, claim types, damages, and deadline tracking
  • Implement retrieval pipeline (case facts → precedents → client instructions → deadlines)
  • Add document logging: store case facts, cited precedents, and arguments after each filing
  • Integrate consistency checking: compare new arguments against prior motions for contradictions
  • Test with historical cases: does AI recall precedents and avoid re-researching?
  • Monitor metrics: brief drafting time, revision rate, deadline compliance

Next Steps

Related reading

Updates from the lab.

Engineering notes, research drops, occasional product updates. Roughly monthly.