AP Automation: GL coding for invoice lines
Last updated 29 November 2026. Evaluated on public data only.
What it does
A governed, model-agnostic agentic system that suggests general-ledger (GL) coding for accounts-payable invoice lines. It auto-posts a coding only when several independent checks agree; everything else is routed to human review. Every decision is written to a hash-chained, tamper-evident audit trail.
Stack: Python, FastAPI, Pydantic, Qdrant (hybrid dense + BM25 retrieval with reranking), Postgres, AWS (Terraform, Bedrock in-region), Langfuse, RAGAS, GitHub Actions CI with Gitleaks, Semgrep, Bandit and pip-audit.
How it's tested
Data. Spend lines from the City of Los Angeles Checkbook (public), split into a development set and a locked holdout. The eval harness refuses to touch the holdout, and leakage tests guard the split.
Offline decision gate (every pull request). Runs all 4,449 development questions with a deterministic stand-in embedder, so it is free and exactly reproducible. Results must match a committed baseline exactly (auto-post count, correctness, precision) or CI fails.
RAGAS diagnostic. A fixed 300-line development sample (seed 20260121) run against the live decision endpoint, reporting faithfulness, response relevancy, context precision and context recall with 95% confidence intervals. It is diagnostic, not a pass/fail gate, by design. Reports are written atomically, incomplete runs are marked partial, and running out of API credit fails loudly rather than producing bad numbers.
Other tests. About 590 unit and integration tests across contracts, retrieval, middleware, evals and infrastructure, plus security scanning in CI.
Results
Offline decision gate (29 Nov 2026)
| Lines | Auto-posted | Correct | Incorrect | Precision | To human review |
|---|---|---|---|---|---|
| 4,449 | 758 | 752 | 6 | 0.9921 | 3,691 |
RAGAS (300-line sample)
| Metric | First run | Baseline (28 Nov 2026) | 95% CI (baseline) |
|---|---|---|---|
| Faithfulness | 0.515 | 0.941 | 0.929–0.952 |
| Response relevancy | 0.527 | 0.646 | 0.641–0.651 |
| Context precision | 0.862 | 0.875 | 0.852–0.897 |
| Context recall | 0.366 | 0.807 | 0.772–0.841 |
With gates switched off, 3 lines in the sample were wrongly auto-posted: 2 look like labelling errors in the source data, 1 is a genuine retrieval miss.
Limitations
- Response relevancy (0.646) is the weakest metric.
- Part of the jump from the first run to the baseline came from a revised judge-facing answer/reference prompt, so the recall gain shouldn't be read as purely a retrieval improvement until the two are separated.
- All results are on public data. There is no live or shadow-mode evidence yet; shadow mode (scoring live decisions against human outcomes without writing anything back) is in progress.
- The offline gate uses a stand-in embedder, so it tests decision logic and regressions, not embedding quality.
- RAGAS uses an LLM as judge, so its scores are indicative rather than definitive.
- Not built yet: ERP posting, authentication and multi-tenancy, LangGraph orchestration, and a reviewer UI.