Skip to content

    AI Architect Case Files

    Case File: Contract Search, Build vs Buy vs Configure

    A legal team started building AI contract search before costing it. A three-year comparison of configure, buy and build shows where the plan went wrong.

    By Published 7 min read

    • ai-architect
    • case-file
    • industry-legal
    • pattern-build-vs-buy
    • failure-cost-overrun
    • kind-composite
    Share

    Composite scenario, not a real company. Assembled from common industry patterns; every number is illustrative and its assumptions are listed at the end.

    Context

    • The in-house legal department of a mid-sized company has 40 lawyers and paralegals and about 18,000 contracts in its document management system, with roughly 3,000 more added each year.
    • Lawyers ask questions that cut across contracts: which supplier agreements allow termination for convenience on under 90 days' notice, which need consent on a change of control.
    • Today they combine folders, keyword search and paralegals who read contracts.
    • An engineer built a retrieval-augmented prototype in a few weeks; the department asked for a production plan.

    Problem statement

    Measure Value
    Build plan, three years 198k currency units (144k to build, 18k a year to run)
    Projection five months in, with maintenance, evaluation and legal review 438k, which is 121% above the plan
    Options compared before building None. The prototype had made building feel like the default

    Goal: choose the approach on a three-year total cost and on a pass rate against 100 real lawyer questions, before more build effort is spent.

    Constraints

    • Fixed: contracts are confidential; only providers on the approved list may process them, and every answer must link to the clause it came from.
    • Fixed: access follows matter-level permissions; some contracts are restricted to named lawyers.
    • Fixed: a lawyer is accountable for every conclusion; the tool finds clauses.
    • Negotiable: the delivery date and the clause types covered first.
    • Limit: two engineers part time, none with search-service experience.

    Why the traditional approach fell short

    Approach Where it fell short
    Keyword search Misses wording variants ("terminate for convenience", "terminate without cause", "exit on notice" share few words) and returns whole documents, not the clause
    Metadata and folders Hold only what someone typed at intake (counterparty, date, value), so clause-level attributes are not there
    Manual reading Accurate but slow: 4,000 in-force contracts at 15 minutes each is 1,000 hours for one question

    Options considered

    Option Why accepted or rejected
    A. Configure the existing system (non-AI): intake fields, paralegal tagging of 12 common clause types on in-force contracts, saved searches Baseline, kept as fallback. Cheapest, no new vendor, explainable; answers only the 12 tagged types
    B. Buy a contract-search product Preferred, subject to a trial. Handles free-form questions; the vendor shares maintenance; the trial must pass on the department's own contracts
    C. Build retrieval over the contracts Rejected for now. Highest three-year cost; the department would own evaluation, permissions and maintenance

    The ADR carries a review trigger: build is reconsidered only if the trial of option B fails a fixed constraint or the annual licence exceeds the break-even under "Under the hood".

    Solution architecture

    Figure 1. Contract search components with matter-level access

    Contract search componentsClient app to API gateway; API gateway to Policy engine; API gateway to Retriever; Retriever to Document store; Retriever to Model gateway; API gateway to Trace store (traces); Trace store to Eval service (monthly); Model gateway to LLM provider (model call)COMPANY BOUNDARYClient appClient appAPI gateway: SSOAPI gatewaySSOPolicy engine: matter accessPolicy enginematter accessRetriever: contract searchRetrievercontract searchDocument store: contractsDocument storecontractsModel gatewayModel gatewayTrace storeTrace storeEval service: 100 questionsEval service100 questionsLLM provider: approved listLLM providerapproved listtracesmonthlymodel call

    How to read this: the policy engine filters by matter before search, and every query leaves a trace for audit and for the monthly evaluation.

    Figure 2. One question, with the no-answer path

    sequenceDiagram accTitle: Runtime path for a contract question accDescr: A lawyer asks a question. The gateway authenticates, the policy engine lists permitted matters, and the retriever searches only those contracts. It returns clause passages with citations, or reports no answer and offers keyword search. participant CA as Client app participant GW as API gateway participant PE as Policy engine participant RT as Retriever participant DS as Document store participant MG as Model gateway participant TS as Trace store CA->>GW: Question GW->>PE: User identity PE-->>GW: Permitted matters GW->>RT: Question and permitted matters RT->>DS: Search within permitted matters DS-->>RT: Candidate clauses alt Clauses found above threshold RT->>MG: Draft short answer from clauses MG-->>RT: Answer text RT-->>CA: Answer with clause links else Nothing above threshold RT-->>CA: No answer found, offer keyword search end GW->>TS: Query, results, user, versions

    How to read this: the answer is built only from clauses the user may see, and an empty result is reported honestly instead of guessed.

    How AI solved it, step by step

    One contract question, from ask to audit (interactive when JavaScript is on)
    1. Ask. A lawyer asks, for example, which supplier contracts allow termination for convenience on under 90 days' notice.
    2. Authenticate. The gateway identifies the user through single sign-on.
    3. Filter. The policy engine returns the matters this user may see. Restricted contracts are excluded before any search happens.
    4. Retrieve. The retriever ranks clause-level passages in permitted contracts, by meaning and by keyword.
    5. Threshold. If no passage scores above the agreed threshold, the system says so and offers keyword search. No answer is better than an unsupported one.
    6. Draft. The model gateway asks an approved model for a two-sentence answer using only those passages.
    7. Cite. The answer links to each clause, so the lawyer checks the source.
    8. Trace. The query, results, user and versions are stored for audit.
    9. Evaluate. Each month the evaluation service reruns the 100-question set against the requirement.

    Under the hood

    The failure in this case was arithmetic. The plan counted the build and the running cost. The projection added what it left out: engineers keeping the system working (half an engineer a year) and evaluation with legal review of outputs.

    Break-even is the licence price at which buying costs the same as building.

    Step Value
    Buy, non-licence costs 40k implementation + 15k vendor review + 86.4k administration (28.8k x 3 years) = 141.4k
    Buy, three-year cost 3 x licence + 141.4k
    Set equal to the build projection 3 x licence + 141.4k = 438k
    Break-even licence (438 - 141.4) / 3 = 98.9k a year

    Below 98.9k a year, buying is cheaper than building on these assumptions; above it the answer flips. The method for the requirement and the ADR is in AI Architect mindset: requirements, ADRs and design reviews, under "Build vs buy vs configure".

    What went wrong / failure modes

    Failure Mitigation
    Cost overrun from omitted lines: the plan priced the build, not the system's life The ADR must include a three-year total with maintenance, evaluation and review lines
    Scope growth: scanned-document text extraction, matter permissions and citations were not in the first estimate List them as requirements first and price every option against all of them
    A demo passes and your data fails Trial on 100 real questions against the department's own contracts, with a stated pass mark
    Superseded versions retrieved: an amended contract returned beside its replacement Index the current version and show effective dates
    Permission leak: search that ignores matter access exposes restricted contracts Filter by permission before retrieval and test with a case that must return nothing

    Results

    These results are illustrative targets and arithmetic, not measurements. Thousands of currency units:

    Option Year 1 Year 2 Year 3 Three-year total Free-form questions
    A. Configure (non-AI) 99.65 40.65 40.65 180.95 No, 12 tagged clause types only
    B. Buy 143.8 88.8 88.8 321.4 Yes, subject to the trial
    C. Build (projected) 218 110 110 438 Yes, after build
    C. Build (original plan) n/a n/a n/a 198 Yes

    Decision rule: a candidate passes if the correct clause is in its top five results for at least 80 of 100 questions; among those that pass, choose the lowest three-year total unless a fixed constraint rules it out. Option A is expected to fail on questions outside its 12 tagged clause types, which is why B is preferred. If the 100 questions are mostly about those 12 types, A passes and wins on cost.

    Tradeoffs and when NOT to use this approach

    • Do not buy when the data cannot leave your boundary and no product runs inside it.
    • Do not buy when licences pass the break-even, about 98.9k a year on these assumptions.
    • Do not build for a common need unless a constraint forces it. Controlling the data path is a legitimate tradeoff if the cost is priced and approved up front.
    • Do not use AI when configure is enough. If 12 tagged clause types cover the questions, option A costs about 56% of option B and is simpler to explain.

    Design rules extracted

    1. Price every option over three years, including maintenance, evaluation and review, before approving any build.
    2. Always include a simple non-AI option; it sets the baseline the AI option must beat.
    3. Run each option against the same real questions with a written pass mark.
    4. Write the break-even price into the ADR as a review trigger.
    5. Apply permissions as a filter before search and test it with a case that must return nothing.

    Assumptions

    All numbers are illustrative; k means thousand currency units. An engineer-month costs 12k fully loaded, and a paralegal hour costs 35 currency units (0.035k).

    Item Arithmetic
    Contracts 18,000 in total, 4,000 in force and in scope, 3,000 added a year. Manual reading: 4,000 x 0.25 h = 1,000 hours for one question
    Build (projected), year 1 Build 2 engineers x 6 months x 12 = 144; support 0.5 engineer x 6 months x 12 = 36; running (hosting and model usage) 18; evaluation and legal review of outputs 20; total 218
    Build (projected), years 2 and 3 Support 0.5 x 12 x 12 = 72, running 18, evaluation 20; total 110 each. Three years: 218 + 110 + 110 = 438
    Build (original plan) 144 + 3 x 18 = 198. Overrun: (438 - 198) / 198 = 1.21 (121%)
    Buy Licence 60 a year; implementation and migration 40 once; vendor security review 15 once; administration 0.2 engineer x 12 months x 12 = 28.8 a year. Year 1: 143.8. Years 2 and 3: 88.8 each. Total 321.4
    Configure Setup 2 engineer-months x 12 = 24; initial tagging 4,000 x 0.25 h x 35 = 35; ongoing tagging 3,000 x 0.25 h x 35 = 26.25 a year; administration 0.1 engineer x 12 x 12 = 14.4 a year. Year 1: 99.65. Years 2 and 3: 40.65 each. Total 180.95
    Break-even licence (438 - (40 + 15 + 86.4)) / 3 = (438 - 141.4) / 3 = 98.87 a year
    Configure to buy 180.95 / 321.4 = 0.563 (about 56%)
    Trial 100 lawyer questions, pass mark 80 with the correct clause in the top five results, and a 15-minute read per contract. Chosen for illustration, not measured

    Last verified: 2026-10-21

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments