Legal Document Automation for Dangote

An AI drafting agent that produces formal legal correspondence where the fixed legal wording is reproduced exactly — every time.

Legal AI AI Agent LLM Document Automation

The Client

Dangote is one of Africa's largest industrial conglomerates, best known as the continent's leading cement manufacturer. Its legal team produces a steady stream of formal correspondence — letters of introduction, internal memos, and other corporate documents — where the wording of fixed clauses is not negotiable: it must appear exactly as approved.

The Problem

The obvious approach — ask a large language model to generate each letter and "fill in the details" — is the wrong tool for legal documents. A generative model emits every token from its own distribution, so it paraphrases, compresses, and silently drops clauses. Retrieval tricks make it worse: chunked templates and top-k retrieval mean the model often never sees the whole document it is supposed to reproduce. For a legal team, a draft that is 98% right is 100% unusable.

The Solution

We rebuilt the system around a single principle: fixed legal text is reproduced by code, verbatim — the LLM only supplies the variable parts. If the model is not responsible for writing a clause, it cannot drop it.

Template Library (approved, version-controlled)
  → Field Extraction (LLM: structured JSON only, never prose)
  → Deterministic Assembly (code fills slots; boilerplate is verbatim)
  → Verification Gate (every required clause + field proven present)
  → Render (DOCX / PDF / TXT)
  • Human-reviewed templates are the source of truth, version-controlled in git
  • The LLM converses with the user and extracts typed field values as structured JSON — it never writes legal prose
  • Deterministic assembly inserts fixed clauses by code, so clause-dropping is structurally impossible
  • A verification gate blocks any draft missing a required clause or field before it renders
  • Golden-file tests fail the build if legal wording ever drifts
  • New document types are auto-extracted from existing documents, then human-reviewed before use

The Stack

Python and FastAPI serve a conversational web UI with authentication. A provider-agnostic LLM client handles field extraction and clearly-bounded narrative sections. Templates are typed pydantic models loaded from version-controlled JSON, and finished drafts render to DOCX, PDF, or plain text.

The Outcome

The legal team gets conversational drafting speed without generative risk: every draft either reproduces the approved wording exactly or is blocked by the verification gate before anyone sees it. The system is live, with an auditable template library the team extends themselves — each new document type is auto-extracted, human-reviewed, and locked in with golden tests.