Intake/counterparty: pass user organisation to LLM + self-reference guard

↗ view on GitHub · Custos · 2026-05-04 · a9426b0c

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.
Repository Custos/legalos
Author Custos <jfeinblum@gmail.com>
Authored
Parents 11895ef6
Stats 3 files changed , +111 , -38
Part of Extraction prompt quality - org-aware self-reference guard + entity casing

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-a9426b0c.md from inside the repo you want the change in.

⬇ Download capture-commit-a9426b0c.md