Custos teaches the AI which side of the table it's on

A small fix for an embarrassing failure mode: contract extractors that name your own firm as the counterparty.

contract-reviewintake

When you upload an Adobe contract and the AI confidently reports the counterparty as your own company, you've got a credibility problem. Custos hit exactly that bug on legalos, their fork of Mike: the extractor was getting biased by filenames and other cues, and would sometimes return the user's own organisation as the other side of the deal.

The fix is twofold. The system now tells the model which organisation the user belongs to and explicitly forbids returning it as the counterparty. A second guard catches anything that slips through by normalising company suffixes (Inc, LLC, Ltd) and nulling the field rather than producing a wrong answer. A small companion change also tidies up screaming-caps entity names so 'ADOBE INC.' renders as 'Adobe Inc.' - the kind of polish that separates a demo from a tool a lawyer will actually paste into a memo.

So what Anyone shipping auto-extraction over contracts should steal this - hallucinating your own firm as the counterparty is a near-universal failure mode worth guarding against.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

2 commits from Custos/legalos, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
a9426b0c Intake/counterparty: pass user organisation to LLM + self-reference guard Custos 2026-05-04 ↗ GitHub
commit body
The intake and counterparty extraction prompts didn't tell the model
which side of the agreement was "us", so the LLM sometimes returned the
user's own org as the counterparty (Kodex, Inc. on Adobe contracts -
biased by Kodex appearing in the filename).

- userSettings now reads + returns user_profiles.organisation.
- buildSystemPrompt() in intakeAnalysis + counterpartyExtraction injects
  "the user's own organization is X - never return X as the counterparty"
  into the system prompt.
- isSelfReference() guard normalises company suffixes (Inc, LLC, ...) and
  nulls counterparty/parent if the model returns a self-match anyway.
- Orchestrators thread organisation through the analysis call.

Set your org in /account/profile (organisation field) for this to work.
282e57c1 Normalise entity casing on extraction (Adobe Inc., not ADOBE INC.) Custos 2026-05-04 ↗ GitHub

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-43.md from inside the repo you want the changes in.

⬇ Download capture-thread-43.md