Context
The pipeline takes a universe of listed equities, runs a deterministic fundamental screen over them (solvency, dilution, revenue growth, ROIC, valuation) and produces a ranked output with a confidence band for a person to read.
The problem
The scoring maths is the easy part. The hard part is that a language model asked to review an investment thesis will agree with whatever number you show it.
Show a reviewer the score, the probability and the price target, and it will write a narrative that ratifies them. Show it last week’s estimate and it will anchor to that. Ask it in the prompt not to do this and it will comply for a few runs and then drift, and you will not notice, because a fluent second opinion looks exactly like a good one.
There is a related, more boring failure: once an LLM SDK is imported into the core of a pipeline, it stops being possible to say with confidence which parts of the output are deterministic.
What I did
The core pipeline is stdlib-only Python. LLM calls sit behind an adapter exposing a Callable[[dict], dict] transport, so the core runs with no provider SDK imported at all: the requirements.txt lists no third-party packages. Swapping a provider is a transport, not a refactor.
The agent graph is three roles with different jobs. An analyst produces a narrative read over each candidate. A validator checks specific claims against the data. An epistemic reviewer writes a second opinion, but the data it receives is EpistemicReviewInput, a frozen dataclass that excludes scores, probabilities, valuations and numeric targets. That is not an instruction the model can drift away from. The score fields never reach the reviewer.
Around that sits the machinery for catching the failures anyway: a probability-anchoring detector that flags the 60% a model tends to default to when it is unsure, a set of hardening gates, and a three-agent exception panel that must be unanimous, for candidates that fall just below the return hurdle. The scan logs its model calls, so a run can be reviewed after the fact.
The screening checks are governed by a written contract, and assets/methodology/strategy-rules.md is the single source of truth. When a helper function disagrees with the methodology document, the methodology wins and the helper is the bug.
The result
The design principle generalises past this project. LLM discipline that lives in a prompt is a suggestion. LLM discipline that lives in a frozen dataclass is a constraint, and it still holds on the run nobody is watching.

