Trade Surveillance Agent
An insider-trading investigator that refuses to publish what it cannot prove.
An AI investigator for SEC Form 4 insider filings. It gathers evidence, drafts a finding, checks every claim against what it actually retrieved, and hands a clear, flag or escalate outcome to a human — while openly reporting where its accuracy still falls short.
- live runs failing the process audit (of 10)
- 8 → 0
- disposition accuracy, reported openly
- 5 / 10
- claims grounded in the sample case — so it escalated
- 2 of 4
Why it exists
Executives, directors and large shareholders must publicly report their own trades within two business days, and a compliance team then has to decide which filings deserve a closer look.
A filing on its own cannot show whether an insider knew anything. A sale just before earnings is a classic warning sign — but it may also be a pre-planned trade or a routine tax disposition. Reviewers need an assistant that surfaces concerns and mitigating factors together, cites its sources, and is honest when its evidence is thin. A fluent paragraph that sounds right but is not grounded in the record is worse than no assistant at all, because it creates false confidence.
How it works
- 01 Input Form 4 filing
- 02 Model / AI Plan the evidence
- 03 Code Validate the plan
- 04 Model / AI Investigate & draft read-only tools
- 05 Check Claim-by-claim grounding
- 06 Code Publish clear / flag / escalate
- 07 Human Analyst accepts or overrides
The pipeline is a LangGraph state machine: plan the evidence needed, check the plan in code, investigate with read-only tools over the insider’s trading history and a firm-policy database, draft a finding, extract claims, judge grounding — and only then publish.
- The grounding loop is the centerpiece. The draft is decomposed into individual claims and each is checked against the evidence actually gathered. If a claim fails, the investigation goes back for more evidence rather than quietly rewriting the answer.
- Publication is deterministic. Once grounding is evaluated, code assembles the result, so the model cannot re-word its way around a failed check.
- Concerns and exculpatory factors sit side by side. A blackout-window sale appears next to factors that may explain it, such as an on-time filing below firm limits.
What a model judges, and what is plain code
Whether a claim is supported is judged by an LLM. Everything around that judgment is deterministic: the plan check, the exculpatory factors, and a process audit — was the required evidence gathered, in a sensible order, with real citations and supported exemptions? An included Gymnasium environment uses the same signal, and in its CI gate shortcut strategies score far below a proper investigation. That makes “did the agent actually do the work?” measurable.
A review queue lets an analyst accept or override the agent’s disposition. The decision is recorded against the run and never changes the agent’s finding, so the audit trail keeps both views.
Results and honest limits
- The grounding check catches weak output. In the sample case, the agent escalated a synthetic CFO sale two days before earnings because only 2 of 4 claims were supported; two cited no evidence, so human review is required.
- The process audit improved from a real finding. It exposed a claim-extractor problem; after the fix, live runs scoring zero on the audit fell from 8 of 10 to 0 of 10.
- Evaluation design: a canonical set gates every pull request; recorded live-model runs are shown next to scripted policies but are not gated.
Engineering decisions
- Plan once, validate in code, rather than trusting the model’s own plan.
- Vocabulary discipline: the interface says “flag” and “escalate”, never accuses, so the wording does not overclaim what the evidence supports.
- No vector store — a deliberate, documented decision rather than a default RAG setup.
- Quality gates: lint, strict typing, import contracts, tests, an evaluation harness, a documentation build and Playwright browser tests.
Who it’s for
For compliance and RegTech teams, it is a pattern for AI-assisted review that is explainable and honest about uncertainty. For AI engineering leaders, it shows how to evaluate an agent on how it worked as well as on what it concluded.