A synthetic Brazilian tax-audit benchmark that prices agent errors in statutory fines finds that deterministic rules, especially with a one-call-per-page VLM transcriber, are cheaper than any LLM agent loop tested. All results are exploratory.
Going deeper
Imagine you run a small company in Brazil and must file tax documents every year. The government can fine you for errors: miss a mismatch and you owe a percentage of your revenue; flag a problem that is not there and you waste staff hours chasing it. You need to decide whether to hire a human, use a rules-checking program, or let an AI do it.
This paper builds a pretend company with a full year of invoices and books, secretly hides errors in the records, then lets AI agents, keyword-matching programs and simple OCR pipelines try to find them. Instead of scoring right or wrong, it tallies up what each option would actually owe in government fines and wasted labour. The AI agents do find some errors the rules programs miss, but they also miss errors the rules would catch and sometimes flag problems that do not exist.
After three rounds of testing and retesting — including throwing out earlier claims that did not hold up — the cheapest option turns out to be using the AI just once per page to read the document clearly, then handing the clean text to the rules program. The AI as an independent auditor costs more in every test. But all of this is on a pretend company with pretend errors, with one inexpensive AI model, and nobody has tried it on a real company's books.
The abstract, word for word, with the five densest phrases unpacked.
Agent evaluations score tasks as passed or failed, or grade answers against a rubric. The economy prices errors in currency, and asymmetrically1: a missed defect in a Brazilian tax filing costs its statutory fine times the probability of audit, and a false finding costs the hours spent chasing it. malha generates a synthetic company’s complete fiscal year — NF-e XMLs, double-entry journal, trial balances, rendered scanned source documents, and the statutory ECD and EFD-Contribuições filings — injects defects from a frozen taxonomy (15 classes in v1; 19 classes including 4 physical-scan classes in v2), re-derives every downstream artifact so the world stays consistent, and prices an agent’s audit in the fines the law charges (Lei 8.218/1991, art. 12). The oracle recomputes artifact evidence rather than trusting agent output2; injected defect metadata is used to target gate validation, not as a model-visible answer. Three studies are reported, and the evidence supports a narrower verdict than earlier drafts. The first two use n=30 locked worlds (k=3 for the primary API cells, k=1 for deterministic and local 8B cells; paired bootstrap over worlds). First, standalone frontier agents in the v1 surface beat trivial floors yet fail to beat the deterministic rules engine; those v1 rows are exploratory because the pre-correction filesystem exposed world.json3, which contained defect-class metadata. Audited v2 agent_v2_* trajectories did not read that file. Second (v2 / v2.1, D033), moving malha_rules into a mandatory pre-pass, adding a read-only SQL index and a fail-closed hash-chained Trust Ledger, and wiring real scan pixels into inspect_scan puts agent_v2_vlm+glm-flash ahead of the original malha_rules floor across all three noise regimes. A stronger deterministic floor reverses the reading: ocr_rules_book4, four visible-artifact auditor rules added to the OCR floor, prices at R108/R1,858/R4,937acrossclean/mild/noisyversusR5,699/R6,447/R5,986 for the best agent. Third (v2.2, prereg-v3), the worlds were regenerated with a defect-independent scan inventory (60 worlds) and stateless transcription floors and a rules-plus-agent hybrid were added. v2.2 is exploratory: its oracle guard failed, so by its own registration no claim on the new pool is confirmatory, although every registered cell was eventually run in full (60 of 60 worlds; 30 of 30 on the subtle-wording slice). Within that limit it changes four things. (i) Two v2.1 scan claims made in earlier drafts did not replicate and are retracted4 as general claims. On the legacy pool, whose scan inventory could cue defect presence, pixel vision was ahead of the naive ocr_rules floor on noisy_scan (+5,084 BRL [+1,476, +9,531]) and ahead of the same model without pixels on the scan-class slice (+2,163 BRL [+157, +5,465]); on the regenerated pool the same contrasts are $-$ 888 [$-$ 3,896, +1,824] and $-$ 3 [$-$ 1,904, +2,051]. (ii) The hybrid is cheaper than the strong floor on the mean (+679 BRL [$-$ 95, +1,609], not resolved) but dearer in 45 of 54 non-tied worlds: it adds 9 true and 123 false positives to the rules’ findings, and the mean favours it only while a false positive is priced below about R$581. (iii) The same model used once per page as a transcriber feeding the deterministic rules is cheaper than that hybrid in 54 worlds and dearer in 0. (iv) On a 30-world slice whose defect wording was written after the rules’ keyword lists were frozen, with clean scans, the registered contrast favours the text agent over the strong floor (+7,514 BRL [+3,481, +11,841]; cheaper in 18 of 30 worlds, 47 false positives against 2), while with the original wording the same contrast is $-$ 6,452 [$-$ 9,470, $-$ 3,918]. That margin is one class, and its rewording is a date format, not a meaning: a delivery stamp printed as day, month name and year, which the floor’s stamp pattern does not parse (floor 0 of 15, agent 15 of 15; +8,441 of the difference). On the three semantically reworded classes the agent finds 20 of 45 defects, and without the date-format class the contrast is $-$ 927 [$-$ 3,455, +1,190] (post hoc; floor cheaper in 18 worlds, agent in 11). The slice therefore does not show that the agent reads meaning the rules miss; a rule written against the new lexicon recovers all of these defects. malha does not show agents exceeding strong deterministic automation5; on these synthetic worlds scan noise breaks the reading step, and repairing the reading step restores the rules. Separately (8B trainability), current SFT/GRPO evidence is diagnostic only: corrected ledger-shaped GRPO trains mechanically but its locked-test policy emits zero model-origin findings in 30/30 episodes, exactly matches SFT priced loss, and fails the pre-registered horizon-shape gate. Worlds, code, trajectories and the Gate-4 analysis artifacts of the first two studies (2,329 scored episodes) are prepared for release with the corrected submission package; the v2.2 artifacts are described in §9.
Two lines of prior work converge on this paper: agent benchmarks that score pass/fail and accounting NLP that does not price audit outcomes.
Read five parts, in this order.
Skip Appendix A (registration bookkeeping) and Appendix B (8B training diagnostics) unless you care about the failed RL pilot.
If the strong-floor advantage is smaller than it looks, or the agent disadvantage is overstated, these are where to check.
H5 by defect class (subtle slice, clean; strong floor against the text agent). BRL per world over the 30 worlds. “Recovered by agent” is the exposure the agent recovers over the floor, “FP cost” the difference in false-positive cost, and the last column their sum; the rows add up to the registered contrast. The date-format class is its own row and is not part of the semantic total (registration §9.1). Descriptive (§9.4). class | kind | defects | exposure | floor TP | floor FP | agent TP | agent FP | recovered by agent | FP cost | Δ share scan_cutoff_delivery | date format (surface form) | 15 | 8,441 | 0/15 | 0 | 15/15 | 0 | +8,441 | +0 | +8,441 scan_personal_expense | semantic | 15 | 162 | 0/15 | 0 | 14/15 | 1 | +154 | -8 | +146 scan_ineligible_credit_desc | semantic | 15 | 3,484 | 0/15 | 0 | 4/15 | 5 | +1,075 | -42 | +1,033 expense_personal_mixed | semantic | 15 | 3,323 | 0/15 | 0 | 2/15 | 1 | +24 | -8 | +15 semantic classes, total | s.9.1 aggregate | 45 | 6,968 | 0/45 | 0 | 20/45 | 7 | +1,253 | -58 | +1,194 cutoff_violation | not reworded | 1 | 849 | 1/1 | 0 | 0/1 | 5 | -849 | -42 | -890 nfe_value_mismatch | not reworded | 1 | 78 | 1/1 | 0 | 1/1 | 11 | +0 | -92 | -92 pis_cofins_ineligible_credit | not reworded | 1 | 73 | 1/1 | 0 | 0/1 | 16 | -73 | -133 | -206 scan_value_alteration | not reworded | 1 | 517 | 1/1 | 0 | 0/1 | 5 | -517 | -42 | -558 transitoria_parking | not reworded | 1 | 366 | 1/1 | 0 | 0/1 | 1 | -366 | -8 | -374 10 other classes, same counts in both arms | not reworded | 10 | 6,325 | 10/10 | 2 | 10/10 | 2 | +0 | +0 | +0 all classes (registered H5) | | 75 | 23,617 | 15/75 | 2 | 46/75 | 47 | +7,889 | -375 | +7,514
Nothing on this page was recomputed. Every claim points to the paper so you can check it.
The code, the analysis scripts and the text were written with an AI coding assistant, under the authors’ direction and review. Caio Theodoro works on a commercial AI gateway; nothing from that product is used, every component is open source and all data is synthetic. The corrected public artifact package — analysis tables and JSON, this PDF, the slim source/analysis snapshot, compressed locked-pool and trajectory archives, and SHA-256 checksums — is under corrected/ in the public Hugging Face dataset https://huggingface.co/datasets/caiotheodoro/malha-benchmark/tree/main/corrected. The broader Hugging Face collection caiotheodoro/malha contains the benchmark, traces, and diagnostic adapter repositories. That package predates v2.2: the v2.2 episodes, analysis files and generated tables are under results/v22/ in the development repository and are not yet part of it. The paper is CC BY 4.0; the code is Apache-2.0.
More latest news
Read all