Building an AI Legal Assistant: From Early Testing to Production Deployment

casetext · Legal · 2023 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Legal AI assistant

Casetext needed to turn GPT-4's breakthrough legal reasoning into a production legal assistant accurate enough for mission-critical legal research and document review.

Constraints:

Architecture

Casetext built Co-Counsel as a set of legal 'skills' rather than one monolithic chat prompt. For a legal research task, the system decomposes the lawyer's request into search queries, executes them against legal databases, reads and summarizes returned cases, extracts cited insights, and assembles a memo. Each prompt in the chain is developed test-first with gold-standard expected outputs and thousands of regression cases.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  lawyer[Lawyer] --> co-counsel[Co-Counsel]
  co-counsel --> skill-chain[Skill Chain]
  skill-chain --> prompt-steps[Prompt Steps]
  skill-chain --> legal-databases[Legal Databases]
  prompt-steps --> test-harness[Test Harness]
  prompt-engineers[Prompt Engineers] --> test-harness[Test Harness]
  prompt-engineers --> prompt-steps[Prompt Steps]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Lawyer User assigning legal research or document-review tasks. Co-Counsel
Co-Counsel AI legal assistant that routes tasks through legal skills. Lawyer, Skill Chain, Legal Databases, Test Harness
Skill Chain Dozen-or-more prompt steps that break legal work into search, reading, note-taking, and memo assembly. Co-Counsel, Prompt Steps
Prompt Steps Individual English-language prompts with clear expected behavior and regression tests. Skill Chain, Test Harness
Legal Databases Case law, statutes, regulations, and search systems queried during legal research. Co-Counsel, Skill Chain
Test Harness Gold-standard prompt tests used to verify each prompt in each skill chain. Prompt Steps, Prompt Engineers
Prompt Engineers Casetext staff writing prompt tests and prompts for legal skill behavior. Test Harness, Prompt Steps

Data flow

A lawyer gives Co-Counsel a task such as reviewing documents or researching a legal question; the system breaks it into legal substeps, runs database searches, reads case/statute/regulation results, notes and summarizes findings, composes a memo with citations, and each prompt step is guarded by a battery of tests.

“from the English language query you have to break it down to these different kind of search queries maybe a dozen different search queries”transcript, stated
“finally based on all that work and all the citations you've gathered Etc then finally you put together your your you know research memo”transcript, stated

Why this architecture

Legal work demanded reliable intermediate reasoning, citations, and regression safety. Casetext therefore modeled how a strong attorney would work, decomposed each job into promptable steps, and made prompt engineering test-driven so fixing one failure would not silently break another legal subtask.

“how would the best attorney in the world approach this problem and so in the case of research for example the best attorney would you know get the request save from a partner and then break that request down into like actual search”transcript, stated
“with prompting actually think becomes even more important because of the kind of like nature of these llms they might go in Crazy directions unexpectedly”transcript, stated

Models used: GPT-4 · GPT-3.5

Scale

Alternatives considered (roads not taken)

Continue incremental legal NLP and recommendation features.

Rejected because: They generated revenue but were not transformative enough to overcome lawyer inertia.

“product and we're making you know we're growing 70 80% year-over-year we're between $15 and $20 million in ARR things weren't like terrible right um that's great yeah we're great yeah we but like so they were like what why are we even the board you know some of the”transcript, stated

Ask one large prompt to solve full legal research tasks.

Rejected because: The team modeled attorney work as a chain of search, reading, note-taking, citation, and memo-writing steps.

“know so getting to the final result may be a dozen or two dozen different individual prompts Each of which might by the way be thinking step by step them themselves but um and for the for each of those prompts you know as part of this like chain of of actions you take”transcript, stated

Vibes-only prompt engineering.

Rejected because: Legal reliability required tests for each prompt because instructions can fix one issue and break another.

“test driven we're just like Vibes only prompt engineering and maybe I mean you switched over to this uh very quickly then like was it just obvious from the beginning you're like we just can't do it that other way we should not raw dog”transcript, stated

Patterns

prompt-chaining (workflow)

Legal skills are decomposed into a dozen or two dozen prompt steps that mirror expert attorney workflow.

“we actually broke it down each each you know so getting to the final result may be a dozen or two dozen different individual prompts”transcript, stated

eval-driven-development (quality)

Prompt engineers wrote tests before prompt changes and used batteries of cases to prevent regressions.

“writing these English language prompts to try to you know write the test first basically”transcript, stated

structured-output-contract (legal-workflow)

Each prompt step had a clear expected output such as search queries or cited memo sections.

“we had a a very clear sense of what good search queries look like and wrote like a gold standard answers”transcript, stated

Tradeoffs

Company focus

Chose Pivot all 120 people to GPT-4 legal assistant work over Continue the existing NLP business trajectory.

Rationale: GPT-4 produced a step-function capability increase in legal tasks.

“this is super super super different”transcript, stated

Legal workflow design

Chose Skill chains with tested intermediate prompts over Single end-to-end prompt.

Rationale: Decomposition followed how expert attorneys actually perform legal research.

“the best attorney would you know get the request save from a partner and then break that request down into like actual search queries”transcript, stated

Prompt engineering method

Chose Test-driven prompt development over Manual prompt tweaking by feel.

Rationale: High-stakes legal work needed regression confidence at every prompt step.

“test driven development oh yeah really approach from doing software engineering to to to prompt”transcript, stated

Gotchas (what bit them)

Legal GPT work cannot tolerate plausible hallucination.

Root cause: Legal users need accurate citations and assumptions grounded in the provided context.

Resolution: Prompt toward actual context citations and validate steps with tests.

“we did a lot of prompt work to get it to essentially just do it accurately to cite the actual things in the in context uh that we gave it”transcript, stated

Fixing one prompt behavior can break another.

Root cause: LLMs may go in unexpected directions after new instructions are added.

Resolution: Run prompt changes against large regression batteries for each skill step.

“you might very easily add in a set of instructions to solve one problem you're seeing with these sets of tests and then to break something”transcript, stated

Transformative AI required founder-led organizational conviction.

Root cause: The company already had meaningful ARR, so not everyone immediately agreed to pivot.

Resolution: The founder built the first version himself and led by example.

“I led the way through example I built the first version of it myself”transcript, stated

Evaluation

Casetext evaluates legal assistant behavior through prompt-level gold-standard expected outputs, dozens to thousands of tests per prompt, bar-exam style studies, and regression batteries for each legal skill step.

Metrics: Bar-passage percentile · Prompt test pass rate · Gold-standard search-query match · Regression failures by prompt step · Legal task completion time

“we' write at first maybe a few dozen tests and then a few hundred and a few thousand for every single one of those PRS”transcript, stated
“of 1,200 times they got the right answer 1, 1,199 times or what have you”transcript, stated

Outcomes

The source cites 120 employees, 48-hour company pivot, 70-80% YoY growth, $15-20M ARR, $100M to $650M valuation/exit change, 10th vs 90th percentile bar results, hundreds/thousands of cases, and prompt tests scaling from dozens to thousands.

“whole company all 120 of us did not sleep for those you know months before gbd4 was like publicly launch”transcript, stated
“doing these tasks that would take me when I practiced like a whole day and it's being done in a minute and a half”transcript, stated