Design an LLM Agent System That Revises a Contract to Comply with Dozens of Rules

Quick Overview

Design an LLM agent system that revises a given contract so it complies with several dozen given legal rules. It tests decomposing work across model calls, representing edits so they can be traced and merged, resolving overlapping or conflicting changes, per-rule verification, and cost and latency trade-offs.

Design an LLM Agent System That Revises a Contract to Comply with Dozens of Rules

Company: Harvey

Role: Software Engineer

Category: ML System Design

Difficulty: medium

Interview Round: Onsite

In an onsite system design round, you are given two inputs: a contract, and a list of several dozen legal rules. Each rule states a requirement that the contract must comply with. Design an LLM-based agent system that revises the contract so that it complies with every rule, and returns the revised contract. Walk through how the work is structured and coordinated, how the system handles rules that affect the same parts of the contract, how it checks that the result is correct, and what it costs in latency and model usage. ```hint One call, dozens of obligations Think about how reliably a single model call can satisfy dozens of independent requirements at once, and what smaller unit of work could be carried out and checked on its own. ``` ```hint Where the work collides Decide how the system would notice that two separate changes touch the same text, and what decides the final wording there. ``` ### Constraints and Clarifications - The rules and the contract are both provided; the system does not have to find or interpret external law. - There are several dozen rules, and each one must be satisfied by the returned contract. ### Clarifying Questions - How long is the contract compared with the model's context window? - Are the rules independent, or can two rules conflict? If they conflict, is there a priority order? - Should the output be a clean revised contract, tracked changes with a reason for each edit, or both? - Will a lawyer review the output before it is used, and what latency and cost per contract are acceptable? - Must text that no rule requires changing be left exactly as it was? ### What a Strong Answer Covers - A decomposition of the work, justified by model reliability, parallelism, cost and traceability - An edit representation that makes each change attributable to a rule and mergeable with others - Detection and resolution of changes that overlap or conflict - Verification that every rule is satisfied and that no text was changed unintentionally, with human review where the stakes require it - Latency, cost, retries, partial failures and observability of the whole run ### Follow-up Questions - Two rules genuinely contradict each other for one clause. What should the system do? - A rule changes a defined term that is used throughout the contract. How does your design handle an edit whose effects are global? - How would you evaluate the system before lawyers rely on it? - The same rule set is applied to thousands of contracts. What can be cached or precomputed?

Overview: Design an LLM agent system that revises a given contract so it complies with several dozen given legal rules. It tests decomposing work across model calls, representing edits so they can be traced and merged, resolving overlapping or conflicting changes, per-rule verification, and cost and latency trade-offs.

|Home/ML System Design/Harvey
Harvey logo
Harvey
Sep 22, 2026
mediumSoftware EngineerOnsiteML System Design
0
0

In an onsite system design round, you are given two inputs: a contract, and a list of several dozen legal rules. Each rule states a requirement that the contract must comply with. Design an LLM-based agent system that revises the contract so that it complies with every rule, and returns the revised contract.

Walk through how the work is structured and coordinated, how the system handles rules that affect the same parts of the contract, how it checks that the result is correct, and what it costs in latency and model usage.

Constraints and Clarifications

  • The rules and the contract are both provided; the system does not have to find or interpret external law.
  • There are several dozen rules, and each one must be satisfied by the returned contract.

Clarifying Questions Guidance

  • How long is the contract compared with the model's context window?
  • Are the rules independent, or can two rules conflict? If they conflict, is there a priority order?
  • Should the output be a clean revised contract, tracked changes with a reason for each edit, or both?
  • Will a lawyer review the output before it is used, and what latency and cost per contract are acceptable?
  • Must text that no rule requires changing be left exactly as it was?

What a Strong Answer Covers Guidance

  • A decomposition of the work, justified by model reliability, parallelism, cost and traceability
  • An edit representation that makes each change attributable to a rule and mergeable with others
  • Detection and resolution of changes that overlap or conflict
  • Verification that every rule is satisfied and that no text was changed unintentionally, with human review where the stakes require it
  • Latency, cost, retries, partial failures and observability of the whole run

Follow-up Questions Guidance

  • Two rules genuinely contradict each other for one clause. What should the system do?
  • A rule changes a defined term that is used throughout the contract. How does your design handle an edit whose effects are global?
  • How would you evaluate the system before lawyers rely on it?
  • The same rule set is applied to thousands of contracts. What can be cached or precomputed?

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...