Autonomous Enterprise Finance AI Agent
Problem
Finance teams spent days manually reading transaction documents, running variance analysis and SOX 404 control testing by hand, and hand-formatting the results into leadership-ready reports — a mix of unstructured-document extraction and structured accounting reasoning that no single off-the-shelf tool covered end to end.
Architecture
This isn’t one pipeline — it’s two, chosen deliberately for the shape of each problem:
Document extraction runs as an async, queued job: classify the document type with one LLM call, then run a type-specific extraction prompt in JSON mode against a typed schema (journal lines, invoice line items, bank transactions). A separate, deterministic fuzzy-matching pass — no LLM involved — reconciles extracted vendor and company names against a tenant-supplied master list. I split identity-matching out of the LLM step because fuzzy string matching is cheaper, faster, and more auditable than asking a model to do it, and it lets the LLM focus purely on extraction accuracy.
Variance analysis and SOX testing run as a real-time, session-based agentic chat: uploaded files are embedded into a per-session vector store and retrieved via RAG on each turn, and the model calls deterministic tools (variance decomposition, accounting-equation validation, statistical sampling, materiality calculation) instead of doing arithmetic itself. A verification pass after generation independently checks every reported figure against the tool outputs before it reaches the user — added after early testing showed the model could describe a calculation correctly in prose while getting the actual number wrong.
Key engineering decisions
- LLM reasons, code computes. Variance analysis decomposes budget-vs-actual into volume and price/rate effects that must reconcile exactly to the total variance. I don’t trust a model to get that exact under prompting alone, so the decomposition is a callable tool with deterministic output, not a hope that the model “shows its work” correctly.
- Structured output all the way to the report. The model is required to emit its findings as a well-defined JSON block, not freeform prose, which gets parsed into typed tables/findings/recommendations and turned into real Excel/PowerPoint/Word files downstream — the schema is the contract between “the LLM said something” and “this is a document a controller can hand to their CFO.”
- Escalation is a first-class state, not an afterthought. SOX findings above a severity threshold branch the workflow into a human-approval step rather than letting the agent self-report and move on. For a system touching internal controls, “the AI flagged it, a human decided” was a non-negotiable requirement, not a nice-to-have.
Result
Reached 90% extraction accuracy on complex, real-world transaction documents, and the variance-analysis/SOX-testing chat now produces leadership-ready reports that used to take a finance analyst hours to compile by hand.