Pranav GudiseCode on GitHub

Contract memory harness

A small agent harness and eval for one question: when an agent works over a firm's contract bank, does a memory built ahead of time answer as well as rereading the contracts, at a fraction of the tokens, and what happens when a contract is amended? Five public contracts from CUAD, 25 questions, a tool-using agent, and a plug-in slot where a learned memory (such as an Engram) would go.

Same answers at 10x fewer tokens, but 5 of 5 answers went stale after amendments until the memory was rebuilt

The precomputed memory matched long context, 25/25 to 25/25, on a 69,221-token bank of five public contracts.

25 questions, one square eachCorrect · context tokens per question
Long contextAll five contracts pasted into every prompt
Single facts 18
Not there 4
Across 3
25/25
69,221tokens / question
RetrievalTop 6 matching passages (BM25) in the prompt
Single facts 18
Not there 4
Across 3
19/25
3,510tokens / question
Tool agentSearches and reads passages over several turns, then answers
Single facts 18
Not there 4
Across 3
19/25
5,172tokens / question
Precomputed memoryCompact notes written once per contract, offline; only the notes go in the prompt
Single facts 18
Not there 4
Across 3
25/25
7,073tokens / question
After four amendmentsFive questions whose answers the amendments changed.
Memory, not rebuiltNotes from before the amendments
0/5
7,073tokens / question
Memory with stale guardNotes, but questions on a changed contract fall back to retrieval
5/5
3,210tokens / question
Memory, rebuiltNotes rebuilt for the four changed contracts only
5/5
6,504tokens / question
CorrectWrong Stale: answered from the old termsSelect a square to read the answer.

Answer quality and cost

Correct answers against context tokens per questionLong context: 25 of 25 at 69,221 tokens; Retrieval: 19 of 25 at 3,510 tokens; Tool agent: 19 of 25 at 5,172 tokens; Precomputed memory: 25 of 25 at 7,073 tokens1520251k3k10k30k100kContext tokens per question (log scale)Correct of 2510x fewer tokens, same 25 of 25Long context25/25 · 69,221Precomputed memory25/25 · 7,073Retrieval19/25 · 3,510Tool agent19/25 · 5,172

The precomputed memory scored 25/25 against long context's 25/25 (misses: memory none; long context none) with about 1/10 of the context per question, after a one-time offline build of 108,853 tokens.

Retrieval and the tool agent used the least context per question but missed 5 and 4 single facts; 5 and 3 of those misses said the term was not in what they found, and no config made up a term.

ConfigCorrectMade upStaleContext tokens / questionBilled input tokens / questionLatency / questionModel calls
Long context
All five contracts pasted into every prompt
25/25
Single fact 18/18
Not in contract 4/4
Across contracts 3/3
0069,22194,0781.38s1
Retrieval
Top 6 matching passages (BM25) in the prompt
19/25
Single fact 13/18
Not in contract 4/4
Across contracts 2/3
003,5106,0341.4s1
Tool agent
Searches and reads passages over several turns, then answers
19/25
Single fact 14/18
Not in contract 4/4
Across contracts 1/3
005,17212,9027.16s5.4
Precomputed memory
Compact notes written once per contract, offline; only the notes go in the prompt
25/25
Single fact 18/18
Not in contract 4/4
Across contracts 3/3
007,07312,0851.19s1

Context tokens are counted by the harness (about 4 characters per token) for what each config puts in the prompt. Billed input tokens are what the model provider reported, including its own fixed prompt overhead and cached reads. The precomputed memory also spent 108,853 tokens once, offline, to write its notes.

How it is graded

25 questions: 18 single facts, 4 terms the contract does not contain (the right answer is “not there”), and 3 that need several contracts. Grading is a fixed rubric (exact figure present, right contract cited, no made-up terms), not a model judging a model. Figures must match as whole numbers, so “5,000” does not match inside “4,500,000”. Citing a contract that the answer checked and ruled out is not penalized; the first version of the rubric did penalize it and failed four correct answers. Cross-contract answers are graded on recall only (every right contract named), not on precision.

Changes since the first published run, which is kept in runs/v1_topic_list_notes: the note-writing prompt no longer lists the clause types the questions ask about (it now asks generically for the terms a lawyer would be likely to ask about), and the grader now matches whole figures. The numbers on this page are from a fresh live run with both changes in place; it is a single run, so a one-question difference is within run-to-run noise. The grades shown are the recorded answers re-graded with the final grader, which changes only q15 (fail to pass in long context, retrieval and the memory); the scores the live run reported are in runs/latest/results_as_recorded.json.

Every answer

pass q01 · Single fact · What law governs the Corio and Commerce One license and hosting agreement?

Answer: The Corio and Commerce One agreement is governed by the laws of the State of California, USA, excluding conflict of laws provisions and the 1980 UN Convention on Contracts for the International Sale of Goods (Section 14.3). Disputes go to binding AAA arbitration in San Francisco County, California.
found=True · cites corio · 69,221 context tokens · 1.2s

pass q02 · Single fact · How long is the initial term of the Corio and Commerce One license and hosting agreement?

Answer: The initial term is five (5) years from the Effective Date of October 29, 1999. After that it automatically renews for successive one-year periods unless either party gives written notice at least 30 days before expiration.
found=True · cites corio · 69,221 context tokens · 1.11s

pass q03 · Single fact · Under the Corio license and hosting agreement, how much notice must a party give to stop an automatic renewal?

Answer: Under Section 11.1, the agreement runs for an initial five-year term and then automatically renews for successive one-year periods unless either party gives written notice of its intention to terminate at least thirty (30) days before the initial five-year term or any one-year renewal expires.
found=True · cites corio · 69,221 context tokens · 1.29s

pass q04 · Single fact · How much written notice does either party need to give to terminate the Purolator and Dynamex transportation services agreement without cause?

Answer: Either party may terminate without cause by giving two (2) years' written notice (Section 19.1 of the Purolator/Dynamex agreement).
found=True · cites dynamex · 69,221 context tokens · 1.03s

pass q05 · Single fact · Which jurisdiction's law governs the Purolator and Dynamex transportation services agreement?

Answer: The Purolator/Dynamex agreement is governed by the laws of the Province of Ontario (Section 36.1), and legal proceedings must be brought in a court of competent jurisdiction in Ontario.
found=True · cites dynamex · 69,221 context tokens · 1.07s

pass q06 · Single fact · Under the Purolator and Dynamex agreement, what is the minimum cargo liability insurance each party must carry?

Answer: Under Section 9.1(a), each party must maintain cargo liability insurance with a combined single limit of not less than $100,000 inclusive per occurrence, naming the other party as additional insured with a cross liability clause.
found=True · cites dynamex · 69,221 context tokens · 1.19s

pass q07 · Single fact · What is the minimum monthly fee BNL pays under its outsourcing agreement with Virtual Item Processing Systems?

Answer: The minimum monthly fee BNL pays VIP is $5,000 per month (the "Minimum Fee"), per Section 5(A) of the Outsourcing Agreement dated May 1, 2006.
found=True · cites bnl · 69,221 context tokens · 1.07s

pass q08 · Single fact · Under the BNL outsourcing agreement, how much notice before the end of the initial term is needed to stop it continuing year to year?

Answer: Either party must give written notice to terminate at least six (6) months before the end of the one-year Initial Term (which began May 1, 2006); otherwise the agreement continues year to year, with the same six-month notice required before the end of each Extended Term.
found=True · cites bnl · 69,221 context tokens · 1.27s

pass q09 · Single fact · What state's law governs the BNL outsourcing agreement with Virtual Item Processing Systems?

Answer: The BNL outsourcing agreement is governed by the laws of the State of Oklahoma, without regard to conflict of laws (paragraph 16(G)). Litigation venue is in federal or state court in Austin, Texas or Oklahoma City, Oklahoma, subject to the binding arbitration requirement.
found=True · cites bnl · 69,221 context tokens · 1.11s

pass q10 · Single fact · What minimum fee does Converge owe for services during the initial term of the VerticalNet maintenance and support agreement?

Answer: Under Section 4.1, Converge owes a minimum fee of $4,500,000 for the Initial Term (through March 31, 2003), payable in 18 equal non-refundable Monthly Installments of $250,000, the first due on execution and the rest by the first day of each month from November 2001 through March 2003.
found=True · cites verticalnet · 69,221 context tokens · 1.35s

pass q11 · Single fact · When does the initial term of the VerticalNet and Converge maintenance and support agreement end?

Answer: The Initial Term runs from the October 1, 2001 Effective Date and continues until March 31, 2003 (Section 9.1). Renewal is only by mutual written agreement, for up to three additional one-year terms.
found=True · cites verticalnet · 69,221 context tokens · 1.27s

pass q12 · Single fact · What state's law governs the PcoMed and Integra supply agreement?

Answer: The PcoMed and Integra Supply Agreement is governed by the laws of the State of New Jersey (Section 12.3). Disputes are separately subject to binding arbitration in Denver, Colorado.
found=True · cites seaspine · 69,221 context tokens · 1.11s

pass q13 · Single fact · After the VerticalNet and Converge maintenance agreement ends, for how long does the employee non-solicitation obligation continue?

Answer: The non-solicitation obligation in Section 8 applies during the Term and for one year (1 year) after the agreement ends.
found=True · cites verticalnet · 69,221 context tokens · 1.14s

pass q14 · Single fact · Under the Corio license agreement's audit clause, what size of underpayment makes Corio reimburse Commerce One for the cost of the audit?

Answer: Under Section 4.4 of the Corio agreement, if an inspection reveals an underpayment of more than five percent (5%) for the period under audit, Corio must reimburse Commerce One for the reasonable cost of the examination. Otherwise Commerce One bears the inspection costs.
found=True · cites corio · 69,221 context tokens · 1.11s

pass q15 · Single fact · Under the BNL outsourcing agreement, what is BNL's liability to VIP limited to?

Answer: BNL's liability to VIP for any cause of action is limited to the amounts BNL paid VIP in the twelve (12) months before the claim accrued for the specific service at issue (or, if accrual occurs in the first 12 months of the initial term, the minimum fees payable during those first 12 months, i.e., $5,000 per month). This cap does not apply to VIP's claims for minimum and other fees and expenses owed under paragraphs 5, 15(a) and 15(c), or to BNL's breach of VIP's proprietary rights under paragraph 13.
found=True · cites bnl · 69,221 context tokens · 1.89s

pass q16 · Single fact · In the Purolator and Dynamex agreement, what per-kilogram liability limit do the parties' contracts of carriage set for loss, damage or delay?

Answer: Section 6.3 says the parties' contracts of carriage with their customers limit liability for loss, damage or delay (including consequential loss) to $4.41 per kilogram, or $2.00 per pound, unless a higher value has been declared for insurance purposes.
found=True · cites dynamex · 69,221 context tokens · 1.15s

pass q17 · Single fact · Under the VerticalNet maintenance agreement's services warranty, within how many days must Converge report a breach?

Answer: Under Section 5.1 of the VerticalNet maintenance agreement, Converge must report a breach of the services warranty to VNE in writing within 90 days following the date of performance of the Services in question; VNE's sole obligation and Converge's exclusive remedy is to repair, replace or re-perform the Services at no additional cost.
found=True · cites verticalnet · 69,221 context tokens · 1.26s

pass q18 · Single fact · Within how many days of the effective date must Commerce One sign a source code escrow agreement under the Corio agreement?

Answer: Under Section 12.1 of the Corio agreement, Commerce One must execute the source code escrow agreement within sixty (60) days of the Effective Date (October 29, 1999).
found=True · cites corio · 69,221 context tokens · 1.06s

pass q19 · Not in contract · Does the BNL outsourcing agreement restrict either party from soliciting the other party's employees? If so, for how long?

Answer: The BNL outsourcing agreement between VIP and BNL contains no employee non-solicitation provision. Its only related terms are confidentiality, assignment and 'Services for Others' (VIP may use the same personnel for other clients), none of which restrict soliciting the other party's employees. The only non-solicitation clause in the materials is in the VerticalNet/Converge agreement, which is a different contract.
found=False · cites bnl · 69,221 context tokens · 1.54s

pass q20 · Not in contract · Does the VerticalNet and Converge maintenance agreement require a source code escrow? If so, when must it be set up?

Answer: The VerticalNet/Converge Maintenance and Support Agreement contains no source code escrow requirement. It only states that Vert has no obligation to deliver Source Code for Maintenance Updates or Converge-Requested Enhancements except as set out in the Subscription License Agreement (Sections 2.13 and 3.12), which is not in the material provided.
found=False · cites verticalnet · 69,221 context tokens · 1.28s

pass q21 · Not in contract · What insurance does the Corio and Commerce One license agreement require either party to carry?

Answer: The Corio and Commerce One License and Hosting Agreement does not contain any insurance requirement for either party; no section or exhibit addresses insurance coverage or limits.
found=False · cites corio · 69,221 context tokens · 1.19s

pass q22 · Not in contract · Does the PcoMed and Integra supply agreement bar either party from hiring away the other's employees? If so, for how long?

Answer: The PcoMed/Integra Supply Agreement contains no employee non-solicitation or no-hire clause. Its only employee-related provisions are confidentiality obligations on each party's employees and agents (Section 5.4) and a representation about a non-compete for an individual (Section 7.2(e)), neither of which bars hiring the other party's employees.
found=False · cites seaspine · 69,221 context tokens · 1.52s

pass q23 · Across contracts · Across the contract bank, which agreements are governed by the law of a jurisdiction outside the United States?

Answer: Only one agreement is governed by non-U.S. law: the Purolator/Dynamex Marketing and Transportation Services Agreement (dynamex) is governed by the laws of the Province of Ontario, Canada (Section 36.1), with Ontario courts and arbitration in Toronto. The others are governed by U.S. state law: corio (California), seaspine (New Jersey), bnl (Oklahoma), and verticalnet (Pennsylvania and U.S. federal law).
found=True · cites dynamex, corio, seaspine, bnl, verticalnet · 69,221 context tokens · 1.87s

pass q24 · Across contracts · Across the contract bank, which agreements state a minimum fee commitment in dollars, and what is each amount?

Answer: Two agreements state a dollar minimum fee. The BNL/VIP outsourcing agreement sets a minimum monthly fee of $5,000 (Section 5(A)). The VerticalNet/Converge agreement sets an Initial Term Minimum Fee of $4,500,000, payable in 18 monthly installments of $250,000 (Section 4.1). The Integra/PcoMed supply agreement has Minimum Payments for seven periods, but the amounts are redacted, and the Corio and Dynamex/Purolator agreements state no dollar minimum.
found=True · cites bnl, verticalnet, seaspine · 69,221 context tokens · 3.09s

pass q25 · Across contracts · Across the contract bank, which agreements renew automatically unless a party gives notice, and how much notice does each require?

Answer: Corio (Corio/Commerce One): after the 5-year initial term it auto-renews for 1-year periods unless either party gives written notice at least 30 days before expiry. BNL (VIP/BNL): after the 1-year initial term it continues year to year unless either party gives written notice at least 6 months before the end of the then-current term (early termination by BNL on less than 6 months' notice triggers a cancellation fee). Dynamex/Purolator is indefinite (not a fixed-term auto-renewal; terminable on 2 years' notice), PcoMed/Integra and VerticalNet/Converge do not auto-renew (the latter renews only by mutual written agreement).
found=True · cites corio, bnl · 69,221 context tokens · 2.26s

When a contract changes

Four amendments (written for this test and labeled as such) change five answers: a longer term, a new governing law, a shorter termination notice, and two minimum fees. A memory built before the change still answers from the old terms. The harness detects which contracts changed by comparing document hashes with the ones the memory was built from, then either guards (sends questions on changed contracts to retrieval) or rebuilds only those contracts.

The rule this suggests for a deployment: until a memory is rebuilt, route any question on a contract family that changed since the last build to the current path.

The guard was exercised only on the five changed questions, which all routed to retrieval; its routing for unchanged contracts after an amendment is untested.

Contracts flagged stale: corio, dynamex, bnl, verticalnet. Rebuilt: corio, dynamex, bnl, verticalnet, for 83,153 tokens (the full build was 108,853).

ConfigCorrectMade upStaleContext tokens / questionBilled input tokens / questionLatency / questionModel calls
Long context
All five contracts pasted into every prompt
5/5
Changed by amendment 5/5
0070,32896,0641.23s1
Retrieval
Top 6 matching passages (BM25) in the prompt
5/5
Changed by amendment 5/5
003,2105,8401.21s1
Tool agent
Searches and reads passages over several turns, then answers
5/5
Changed by amendment 5/5
001,8336,2113.81s3.2
Memory, not rebuilt
Notes from before the amendments
0/5
Changed by amendment 0/5
057,07312,0851.02s1
Memory with stale guard
Notes, but questions on a changed contract fall back to retrieval
5/5
Changed by amendment 5/5
003,2105,8381.15s1
Memory, rebuilt
Notes rebuilt for the four changed contracts only
5/5
Changed by amendment 5/5
006,50411,1231.14s1
stale c01 · Changed by amendment · How long is the initial term of the Corio and Commerce One license and hosting agreement?

Answer: The initial term is 5 years (§11), after which the agreement renews automatically for 1-year terms unless either party gives 30 days' written notice before expiry.
found=True · cites corio · 7,073 context tokens · 1.03s
Failed checks: fact 1

stale c02 · Changed by amendment · What state's law governs the BNL outsourcing agreement with Virtual Item Processing Systems?

Answer: The BNL outsourcing agreement with Virtual Item Processing Systems is governed by Oklahoma law.
found=True · cites bnl · 7,073 context tokens · 0.94s
Failed checks: fact 1

stale c03 · Changed by amendment · How much written notice does either party need to give to terminate the Purolator and Dynamex transportation services agreement without cause?

Answer: Either party may terminate without cause on 2 years' written notice (section 19.1). The agreement has an indefinite term (section 2.1).
found=True · cites dynamex · 7,073 context tokens · 0.98s
Failed checks: fact 1

stale c04 · Changed by amendment · What minimum fee does Converge owe for services during the initial term of the VerticalNet maintenance and support agreement?

Answer: Converge owes an Initial Term Minimum Fee of $4,500,000, paid as 18 non-refundable monthly installments of $250,000 (first due on execution, the rest on the 1st of each month from Nov 2001 through Mar 2003).
found=True · cites verticalnet · 7,073 context tokens · 1.08s
Failed checks: fact 1

stale c05 · Changed by amendment · What is the minimum monthly fee BNL pays under its outsourcing agreement with Virtual Item Processing Systems?

Answer: BNL pays a minimum monthly fee of $5,000 under ¶5A of the VIP–BNL Outsourcing Agreement, in addition to the Schedule B rate of $.305 per policy per month. No amendments were provided.
found=True · cites bnl · 7,073 context tokens · 1.09s
Failed checks: fact 1

Plugging in a learned memory

Every config implements the same small interface in cmh/memory.py: build(corpus) runs offline, context(question) returns what goes in the prompt, and stale_docs(corpus) says which contracts the memory no longer matches. EngramMemory is the empty slot: with access, build() would train or point at an engram for the bank, context() would send little or nothing, and the same 30 questions would score it next to the baselines on accuracy, tokens and latency.