Kartez Contract — AI contract drafting, review and editing

Halted by the client one month from completion, for war-related funding reasons. The engineering write-up below is the part that outlived the contract.

At a glance

  • Contract work in Persian needs AI that stays tied to the document on the table, because an invented clause is a liability.
  • A drafting wizard, a review written from the user's side of the deal, and a contract studio with an editing copilot.
  • Halted by the client one month from completion, for war-related funding reasons.

Highlights

  • 2,144 document types to start from

    Each type is named in Persian, Arabic and English, and choosing one returns its typical structure and key considerations.

  • 3 negotiating positions per question

    Aggressive, standard or concession, each with sample wording, legal effect, commercial impact and the other side's likely reaction.

  • Review from the user's side of the deal

    The user states their role and uploads or pastes the agreement; every finding is written for that position across a 5-step journey.

  • Fixes written against the contract's own wording

    Each fix is required to quote the current wording word for word, so it can be found and replaced, and comes with ready-to-use replacement text, ranked by priority.

  • A health score on 4 dimensions

    Enforceability, clarity, balance and completeness, each scored 0 to 100, with risks rated critical, high, medium or low.

  • A copilot that edits the whole contract

    Plain-language instructions are planned, applied to every affected section and highlighted, with a saved conversation per contract.

The challenge

Contract work punishes invention. A model that makes up a clause is worse than no model at all, because the invented clause becomes a liability for whoever signs. A useful assistant has to stay tied to the contract actually on the table, and point to places in it that a professional can check.

The audience added its own constraints. Kartez Contract was built for lawyers, businesses and individuals working in Persian, with Arabic and English alongside, and Persian contracts have their own structure of articles, clauses and notes. The interface had to be right-to-left by design, and every AI reply had to come back in the user's language.

Finally, drafting, reviewing and editing are three different jobs. Starting from a blank page, understanding someone else's agreement and changing a draft mid-negotiation each need their own guided workflow, not one chat window.

Architecture

Three guided workflows sit on one AI engine: drafting, review and a contract studio. The engine runs as its own service beside the accounts and contracts service, each with its own health check. It retrieves in two ways, each for a different job.

  • Library retrieval for drafting. The user's requirements are turned into research topics, and the most relevant passages from a curated library of English contract-drafting texts are placed in front of the model while it writes questions and drafts.

  • Clause retrieval for the copilot. The user's own contract is split along its structure, including Persian articles, clauses and notes, and only the sections relevant to a question are used to answer it.

Every analysis returns a fixed structure, so the interface can lay out timelines, risk registers and fixes consistently, and a badly formed response is repaired where possible and never shown raw. The reference library is maintained without code: documents dropped into a collection folder are picked up on a sync, only new or changed files are re-indexed, and collections can be switched on or off.

What I built

The three workflows share one rule: the AI proposes and the user decides. Suggested fixes come with ready-to-use replacement text that can be applied from the review, and copilot edits are highlighted in the editor for the user to accept or reject.

Drafting wizard

  • 2,144 document types to start from, each named in Persian, Arabic and English with a description, or a custom type in the user's own words.

  • A briefing for the chosen type: an overview, the typical structure, key considerations, and a suggested jurisdiction and governing law with the reasoning.

  • Exactly 7 plain-language questions, each with a note on why it matters, and an AI review that grades the answers and suggests better ones before drafting starts.

  • Guide Me on every question: 3 negotiating positions (aggressive, standard and concession), each with sample wording, legal effect, commercial impact and the likely reaction from the other side.

  • 6 drafting styles (formal, plain, pro-buyer, pro-seller, detailed and concise), with the draft streaming live into the editor.

Review from the user's side

  • A 5-step journey: input, overview, risks, fix and negotiate, then the studio. The user uploads a PDF, DOCX or TXT file, or pastes the text, and states their role in the deal.

  • Overview: a timeline of deadlines, payments, renewals and notice triggers; an executive brief; and key clause extracts explained in plain language.

  • Risks: a categorised risk register with a mitigation for each item, and a section-by-section reading of pros, cons and effects.

  • Fix and negotiate: prioritised fixes, each required to quote the current wording exactly and supply replacement text, plus a negotiation playbook of collaborative, assertive and compromise strategies.

Contract studio and copilot

  • A copilot that tells questions from edit requests, shows its progress, answers from the relevant clauses, and is instructed to say when it needs sections it was not shown.

  • Whole-contract edits in plain language: an instruction such as renaming a party is planned first, applied to every affected section, and highlighted in the editor.

  • A contract health score across 4 dimensions (enforceability, clarity, balance and completeness), plus risks rated critical, high, medium or low.

  • A deep risk report with at least two alternative wordings for each flagged clause, and a one-click report in 4 formats: copy, TXT, DOCX or PDF.

Outcome

The client halted the engagement one month before completion, when war-related financial difficulties stopped the funding. It was a client funding failure, not a delivery failure.

By that point the drafting wizard, the contract studio with its copilot, the reference-library pipeline and the trilingual interface were built and wired end to end, from the interface through to the AI engine. The review journey was built across all five steps; it had not been fully tested and was still being refined when work stopped.

Post-mortem

The hardest problems were retrieval and anchoring. The copilot had to find the right clauses inside Persian contracts, with their own numbering of articles, clauses and notes, and the drafting wizard had to carry Persian requirements into a library of English contract-drafting texts.

Keeping the model anchored was handled by structure rather than trust: answers draw only on the selected clauses, fixes are required to quote the existing wording exactly, outputs follow fixed schemas, and the model runs with low randomness when drafting. These are design constraints, not a measured guarantee.

No accuracy figure is published here. The engagement stopped before a formal evaluation set was built, and this site does not estimate numbers it has not measured.

My role

  • Rebuilt and extended the AI engine behind all three workflows (the drafting wizard, the review journey and the contract studio), starting from the client's first basic AI chains.
  • Built the reference-library pipeline: ingestion, change-aware re-indexing, retrieval for drafting, and controls to switch collections on or off.
  • Built the agentic copilot that classifies each request, finds the relevant clauses and plans edits across the whole contract.
  • Made the product trilingual and right-to-left, and brought the 2,144-entry document-type catalogue into the wizard.
  • Engineered background jobs with live progress, live-streamed drafts, the four-format export and compiled production builds.
  • Sign-in, the marketing pages, billing and the first basic AI chains came from the client's own foundation and are not credited to this work.

Engineering

  • Anchored to the document in front of it

    Answers use only the relevant clauses, the copilot is instructed to say when it needs sections it was not shown, and fixes are required to quote the text exactly.

  • Resilient drafting, without repeated text

    If topic generation or retrieval fails, fallback topics and a path without retrieval keep drafting going; a draft that has started streaming is never retried, so no text repeats.

  • Structured output that survives bad replies

    Responses pass a multi-stage parse-and-repair step, including repair of cut-off replies, and are retried with more room when needed.

  • Long analyses run in the background

    Heavy analyses run as background jobs with live progress, while drafts and copilot replies stream as they are written.

  • Separated, compiled and auditable

    The AI engine runs apart from accounts and contracts, production builds ship compiled, and every drafting and question prompt is logged for audit.

Outcomes

  • Halted by the client one month from completion, for war-related funding reasons: a funding failure, not a delivery failure.
  • The drafting wizard, contract studio, copilot and reference-library pipeline were built and wired end to end.
  • The five-step review journey was built, but had not been fully tested when the work stopped.
  • No accuracy figure is claimed: the engagement ended before a formal evaluation set was built.