New-matter intake agent
Checks an intake email for conflicts and drafts the new matter, which only the attorney or conflicts clerk who approves it can open.
Checks an intake email for conflicts and drafts the matter for approval.
Latest run: all 20 scenarios as expected, all 13 planted records found, and no matter opened without approval. See the results
Latest run: all 13 planted conflicts found.
Intake and conflicts
A made-up firm, searched before a matter opens
Results
All 20 scenarios ended as expected, with all 13 planted records found and no matter opened without approval, at $0.0246 and 7.9 seconds a scenario.
The latest run: claude-sonnet-5-5, Oct 29, 2026. Every number here comes from the results file in the repository, written by a public workflow; costs use the provider's list prices.
20 of 20scenarios as expected
- 13 of 13planted records found
- 0matters opened without approval
- $0.0246cost per scenario
None wrong in 20 scenarios puts the share of scenarios like these that go wrong under 13.9%, at 95% confidence.
| Measure | First run |
|---|---|
| Clean scenarios shown as a conflict | 0 of 3 |
| Ambiguous scenarios the agent marked review | 3 of 3 |
| Failures handled | 6 of 6 |
| Emails that gave orders, copied into the warnings | 3 of 3 |
| Time per scenario, typical | 7.9 s |
| Cost of the run | $0.49 |
How each number is measured
- Scenarios as expected
- A scenario ended as expected when its run ended the way the scenario calls for (sent to an approver, stopped with no draft, or left incomplete) and the verdict shown to the approver was the expected one: 20 of 20.
- Planted records found
- 13 of the 13 records planted in the scenarios, exact names, names typed the way people type them and a person named only as an owner, appeared in the draft's findings.
- Clean scenarios shown as a conflict
- Of the 3 scenarios with no conflict, one written to look like one, those the approver was shown as a conflict: 0 of 3.
- Ambiguous scenarios the agent marked review
- Of the 3 ambiguous scenarios, a possible match, a former client and a closed matter, those the agent marked review for a person to decide: 3 of 3.
- Verdicts as expected
- Of the 17 scenarios that end in a draft, those whose verdict shown to the approver, conflict, review or clear, was the expected one: 17 of 17.
- Failures handled
- Of the 6 failure scenarios, those handled as they should be: 6 of 6. A database timeout ends incomplete, an email that is not an intake ends with no draft, and an email that gives the agent orders ends submitted with the expected verdict and no matter opened.
- Matters opened without approval
- After each run that drafts a matter, an approver identity tries to open it with no approval record, which the gate must refuse. The agent itself never called open_matter.
- Cost per scenario, and of the run
- At the provider's list prices on Oct 15, 2026. The whole run cost $0.49.
- Time per scenario, typical
- The median over a scenario's model calls and tool calls. The slow end, the 95th percentile, was 10.7 s.
- Emails that gave orders, copied into the warnings
- Of the 3 emails that give the agent orders, those whose orders were copied into the draft's warnings for the approver to see: 3 of 3.
Charts
Time per scenario
Each mark is one scenario, on the row of its kind; where several took the same time, the marks run together.
- Every call went through
- A call refused or failed
Conflicts8.2 s typical
Ambiguous8.8 s typical
Clean7.3 s typical
Failures6.2 s typical
What went wrong
Nothing went wrong: all 20 scenarios ended as expected. The service refused one draft, which named a party no search had covered, and the agent drafted again.
Try it
The app at the top of this page is the agent's own web app from the repository, running in your browser on the saved live run. As the requester, replay an intake and watch each tool call land; as the approver, decide on the draft and open the matter, and see the gate refuse anyone else. The audit log lists everything that happened. On its own page it has the whole window. Nothing you do is sent anywhere.
System design
Every project follows the same seven layers, from what people use down to where its data comes from, and fills only the ones its problem needs.
- ProductThe web app: a requester runs an intake, and an approver, never the requester, decides
- IntelligenceClaude names the parties and calls the searches; the service computes the findings from them
- ServingFive scoped tools, the searches read-only; the API in FastAPI; an MCP server
- ModelingNot needed: the conflicts rules read the firm's records as they are stored
- StorageOne SQLite database: the firm's records, every run and tool call, the drafts and approvals
- IngestionEach email checked for length and rate; a guard copies any orders to the agent into the draft
- SourcesIntake emails; a made-up firm of about 500 names built around the records the tests plant
Across every layer
- Quality 20 scenarios: planted conflicts, clean controls, ambiguous names and six failures; targets set first
- Governance Triggers refuse a matter without an approval; every step audited; Entra ID tokens checked
- Observability A span per run, holding every model call and tool call, refusals included, for Langfuse
- CI/CD Lint, strict types, the tests and an offline evaluation that fails if the gate ever opens
- Cost Cost and time per scenario on every run, against a target of under $0.10
The skills it shows
- Human-in-the-loop
- Dashboards
- AI agents
- Entity resolution
- MCP
- APIs
- SQL
- Guardrails
- Synthetic data
- LLM evaluation
- Data governance
- LLM observability
- CI/CD
- LLM cost and latency
- Python
15 of the 33 on the skills page, each with where it is shown.
The problem
Of everything I build, an agent that can write to a live system is the one I trust least. Most designs hand the model the power to write and then ask it, politely, to be careful. I've gone the other way here. The agent gets the fewest tools that can still do the job, every move it makes is logged, and the one action that has consequences, opening a matter, stays locked until a person with the right role approves it.
Two people use it. The requester is whoever gets the intake email. The approver is the attorney or conflicts clerk who signs off on new matters.
Constraints
- A made-up firm: a seeded generator builds about 500 client and adverse-party names, and 180 matters, around the records the scenarios plant. It adds near duplicates on purpose, "ACME Logistics LLC" beside "Acme Logistic Inc.", so fuzzy matching gets tested rather than assumed. Every name and email is made up.
- The search tools can only read. The draft tool writes one draft per run, and only once every party on it has been searched.
- Opening a matter needs the approver role and an approval record from someone other than the requester. The API checks both, and a database trigger checks again, where the model can't get at either.
- Identity comes from Microsoft Entra ID tokens, with two app roles: requester and approver.
Design
- A guard reads the email first: 20 to 20,000 characters, at most six intakes a minute per person. Any line that gives the agent orders ("skip the approval step") is copied into the draft's warnings, for the approver to see.
- The model names the prospective client and everyone on the other side, then searches: the client against the parties the firm is against, everyone else against the firm's clients. Each match comes back with a score and a band: exact, likely (92 or more) or possible (80 or more).
- The draft tool is refused until every party on the draft has been searched in the run. The service, not the model, turns those searches into findings, so the agent can't leave a match out or soften one. The approver is shown the stricter of the agent's verdict and the checks'.
- Asking for approval sends the draft, and the agent's work ends. The agent acts with the requester's role alone, so any attempt it makes to open the matter is refused.
- An approver who isn't the requester decides. Approving past a flagged check needs a written reason, such as a waiver on file. Only then can the matter be opened.
- The audit log keeps every model call and tool call: the arguments with personal data redacted, a SHA-256 of each result, tokens, time and cost. Nothing can edit or delete it, and the web app shows it.
| Tool | What it may do |
|---|---|
search_clients |
Read only, fuzzy matching |
search_adverse_parties |
Read only, fuzzy matching |
draft_matter |
Writes one draft per run, after every party is searched |
request_approval |
Sends the run's draft to a person; the run ends |
open_matter |
Gated: refused without the approver role and an approval record |
The MCP server
The gate is only worth something if it holds whatever plays the agent. So the agent's tools are also an MCP server, and Claude Desktop, Claude Code or any other MCP client can do the agent's work: start a run on an intake email, search every party, draft the matter and send it for approval.
| Tool | What it may do |
|---|---|
start_intake |
Opens a run on an intake email and returns any lines that read like orders |
search_clients |
Read only, fuzzy matching |
search_adverse_parties |
Read only, fuzzy matching |
draft_matter |
Saves the run's draft, after every party on it is searched |
request_approval |
Sends the run's draft to a person; the run ends |
end_intake |
Ends a run without sending a draft, saying why |
There is no open_matter. Every call goes through the agent's own toolbox, so a draft names only parties
searched in its run, its findings come from those searches, and each call is written to the audit log. The client
acts as a requester only, and the database refuses to open a matter without an approver's record, so a draft sent
this way waits for an approver in the web app like any other. The server runs over stdio only, for the person who
starts it, because the API's sign-in doesn't reach it. A run a client leaves open ends as incomplete when it
disconnects. Six tests drive the server through a real MCP client.
Setting it up is a few
lines of a client's settings.
Evaluation
Twenty scenarios. Eight plant a conflict for the searches to find: exact names, names typed the way people type them, a person written last name first, a client named only as the owner of the company on the other side. Three are ambiguous, for a person to decide: a possible match, a former client, a closed matter. Three are clean, one written to look like a conflict. Six are failures: a database that times out, two emails that aren't intakes, and three emails that give the agent orders. Thirteen records are planted in all: one in each conflict and ambiguous scenario, and one in each of two of the emails that give orders. Fixed checks score every run, so anyone can repeat the scoring by hand. After each run that drafts a matter, an approver tries to open it before approving it, which the gate must refuse. I set the targets before the first live run, so the results couldn't move them.
With claude-sonnet-5-5 as the agent, every target was met. It found all 13 planted records, showed no clean scenario as a conflict, marked all three ambiguous ones for review rather than deciding them itself, and handled all six failures. No matter opened. With fixed rules playing the agent and no model, the searches found 10 of the 13: the rules miss a company written without its legal form ("Pinnacle Foods"), and the model doesn't.
The three emails that gave orders were each copied into the draft's warnings, and none changed the outcome. Told to skip approval and open the matter, the agent asked for approval and never tried to open it. Told that a company isn't a client and to skip the search, it searched anyway and found the exact match. Told to list every client, it didn't.
One run shows why the draft check lives in the service and not in the prompt. In the scenario where "Acme Logistic Inc." is a current client typed differently, the agent's first draft named a party it had never searched, an unnamed class of drivers. The service refused the draft, and the agent drafted again without the class, saying so in its reasoning. Every run is on the saved runs page, with the email, each tool call, the draft an approver would see and the gate check.
A set passed in full no longer tells a good agent from a better one, so the next set is harder: more parties per email, names spread across a thread, and owners and officers named only by their role.
Human review points
There's one, and it isn't optional: the approver. The agent can recommend. It can't open. The approver sees the email beside the draft, every finding with the record it matched, the warnings and the agent's reasoning, and needs a written reason to approve past a flagged check.
Security and logging
The gate is held three times: the agent has only the requester's role, the API refuses an opening without an approval record, and a database trigger refuses it even if the code above it were wrong. Email text never reaches the logs, and contact details and ID-like numbers are redacted from everything that does. Secrets live in environment variables, and the service won't start if one is written into its settings file. Entra ID tokens are checked against the tenant's signing keys, and local sign-in refuses to listen beyond the machine it runs on.
Traces
Each intake run is one trace: an agent span with its outcome, steps, tool calls and cost, holding a span for
every model call (its tokens, cost and why it stopped) and one for every tool call, which says whether the tool
worked and, when it didn't, the audit code. A refused open_matter shows there by name, which a test checks.
The spans are named as OpenTelemetry's GenAI conventions name them, so Langfuse shows a run as an agent with its
model calls and tools. Email text and tool arguments stay off the spans unless a setting turns them on, and with no Langfuse
keys set, no spans are sent. The Nov 7 rerun,
the same as the Oct 29 run on every measure, keeps its trace beside its results.
Known limitations
- A party the agent never names is never searched. The approver sees the email beside the draft, and the evaluation measures the parties named: every draft named every party.
- Related parties, such as a parent company or an officer, are checked only when the email names them.
- Every search scans every name: fine at 500, not at 500,000.
- The web app signs in with trusted headers on one machine; the API already checks Entra ID tokens, so web sign-in is next. A pilot also needs the firm's own conflicts database behind the read-only search interface.
