# Which model reads this document? Failover, quality telemetry and caching

> Pick a model from measured quality telemetry, fail over when a reading fails a check not just when a call throws, and never let code rewrite a bad number silently.

- Canonical: https://www.alpacamango.com/docs/choosing-models-and-falling-back
- Author: Space Toucan
- Published: 2026-11-24 · Updated: 2026-11-23
- Topics: Fintech, building-taxadoo, AI & Agents

*Building Taxadoo, part 5 of 7. Lessons from building the statement engine behind Taxadoo, a UK bookkeeping product — the decisions and the failures, not the internals. *[*The whole series*](/docs/tag/building-taxadoo)*.*

**Choose a model because its recent quality numbers say it reads your documents reliably, and switch when a reading fails a check — not only when a call throws.** A model that returns valid output with the numbers wrong is the failure no outage-handler sees, and most fallback chains are built for outages.

## Measure before you choose

Record a few quality numbers on every run: the share of rows that arrived with a running balance, the corrections made, and a verdict of readable, unreliable or unverifiable. Then the question "which model is reliable on this kind of document?" is one query, answered from recorded behaviour rather than a memory or an archived event log. When someone assigns a model to a layout, show its recent refusal rate and let them override the choice. The data should inform, not block.

Pinning a primary and secondary model per bank is seductive because reliability really does differ by layout. It turns sour as the number of pins grows: settings accumulate for document types and readers that no longer exist. The stable alternative is to store measured results and choose the model chain order from a corpus.

## Use arithmetic before spending a call

A running-balance column reveals sign flips for free. If a step changes direction but the chain still closes, that is a coherent sign error and arithmetic can fix it without a retry. Spend the model again only on dropped rows, misread amounts and merged lines — the errors you cannot derive. Retry the same model before trying another: identical runs can diverge, and one fresh attempt at the failing part often comes back clean. Keep one shared retry budget across every reason for retrying.

Long documents need joins checked where parts meet. A wrong-direction payment at the start of a later part has no earlier balance inside that part to contradict it. Check each join in the convention most parts closed in, and re-read the later part first with the balance it should start from.

## Let code keep the verdict

Fail over when a reading fails the balance check. Try models until one passes. If none do, keep the reading that got furthest and hold the statement for a person. That costs more in calls and time, and it measurably raises the share read correctly while cutting the share held for staff. Measure the trade-off; do not assume it improves.

The case where this inverts: do not correct a number silently to make the books close. A wrong sign should break the chain and hold the row, with the row named. Rewriting the sign hides the reader's mistake from whoever could fix the reader. The check's job is to make bad readings visible, not to conceal them.

## Swap backends and cache against a measured plan

Build every model client behind one interface, selected by a runtime setting, so a backend can move in preview while production stays unchanged. Use federated, keyless credentials and confirm where the runtime actually delivers the identity token; it has not always been an environment variable. Confirm structured output, image handling and embedding sizes behave the same before the switch.

Treat prompt caching as a plan with cost reasoning, not a free saving. Only the unchanged opening of the input is discounted; output and reasoning are not cached, and a miss can cost more than no cache at all. Put static content first, keep it byte-for-byte identical, and re-read documents incrementally.
