
Case Study
Deterministic Quantitative Routing
A novel AI system architecture implementing the "Thin Agent, Fat Platform" pattern to eliminate hallucination and non-determinism in quantitative financial workflows. The system exposes a natural language interface that parses user intent using an LLM acting purely as a semantic router, then delegates all computation to a curated library of over 100 deterministic, mathematically verified functions covering portfolio metrics, risk calculations, technical indicators, options pricing models, and statistical analysis. By keeping the LLM strictly in the routing layer and out of the computation layer, the architecture guarantees fully reproducible, auditable numerical results regardless of model temperature or prompt variation — a critical requirement in financial applications where a single hallucinated figure can have material consequences. The platform is built with Python for the computation engine and Next.js for the conversational interface, and is designed to extend easily as new quantitative modules are added to the function library.
Role
AI/ML Engineer & Systems Architect
Duration
6 weeks
Tech Stack
The Problem
LLMs hallucinate. In natural language tasks this is tolerable; in quantitative financial workflows it is catastrophic. A single hallucinated numerical output — a risk metric, a delta exposure, an options price, a portfolio allocation weight — can produce trades with real material consequences. Existing LLM agent frameworks allow the model to generate and execute code freely, meaning every numerical result carries irreducible model uncertainty. Finance requires determinism, auditability, and reproducibility that probabilistic text models fundamentally cannot provide.
My Approach
Implemented the "Thin Agent, Fat Platform" (TAFP) architectural pattern — the core insight being that LLMs are excellent semantic parsers but poor mathematicians. The system enforces a strict separation of concerns: **Routing Layer (LLM):** The language model receives the user's natural language query and outputs only a structured routing decision — which deterministic function to invoke and with what parameters. It never computes a number directly. **Computation Layer (Deterministic functions):** A curated library of 100+ stateless Python functions covering portfolio metrics, risk calculations, technical indicators (ordpy-based complexity-entropy plane analysis), options pricing (Black-Scholes), and statistical analysis. Each function is parameter-less, scale-invariant, and mathematically verified. **Recursive Stability Engine:** Binary outputs are re-injected iteratively until Hamming Distance convergence reaches zero or falls below 1% of the array length. A circuit breaker halts execution on 2-cycle oscillation, detecting chaotic regimes before they propagate. **JIT Gateway Routing:** Skills are loaded just-in-time from structured markdown files, reducing per-agent context token cost from ~24,000 to ~2,700 tokens — a 9× reduction with direct inference cost impact. **Cryptographic Provenance Receipts:** Every computation output is signed with a SHA-256 hash encoding the library version, data lineage ID, and LLM routing blueprint, creating an immutable audit trail for regulatory review.
Results & Impact
A fully operational AI system for quantitative finance that guarantees deterministic, reproducible numerical outputs regardless of LLM temperature or prompt variation. The 9× token cost reduction via JIT routing makes the system economically viable at production scale. Cryptographic provenance receipts satisfy regulatory auditability requirements. The Recursive Stability Engine prevents chaotic regime propagation — a novel safety mechanism with no equivalent in existing LLM agent frameworks.