---
title: "Claude Sonnet 5 on Pydantic AI Accounting"
description: "Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 60%, code mode 60%; rank 27 of 32."
canonical: https://models.pydantic.dev/models/claude-sonnet-5/accounting_platform/
---

# Claude Sonnet 5 on Pydantic AI Accounting

> Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 60%, code mode 60%; rank 27 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/claude-sonnet-5/accounting_platform/. Index for agents: https://models.pydantic.dev/llms.txt

**Agents: use the API for model information.** It answers a question in one request, where the pages need several.

- Choose a model for an agent: `POST https://models.pydantic.dev/api/select` with a JSON body such as `{"description": "what the agent does"}`. It returns up to five ranked models with reasons. Format: https://models.pydantic.dev/select.md
- Search models by name: `GET https://models.pydantic.dev/api/search?query=<text>`
- List, filter and sort models: `GET https://models.pydantic.dev/api/models`, for example `?weights=open&max_price=2&sort=efficiency`
- One model in full: `GET https://models.pydantic.dev/api/models/<slug>`
- Any other question about the models: `GET https://models.pydantic.dev/api/ask?query=<question>`

Add `intent=<intent>&stack=<stack>&harness=<harness>` to the query string of all but the single model. An `OPTIONS` request to any endpoint returns its schema. The same five are tools of the MCP server at `https://models.pydantic.dev/mcp`. More: https://models.pydantic.dev/usage.md

About the benchmark: https://models.pydantic.dev/benchmarks/accounting_platform.md. The model on every Pydantic AI benchmark: https://models.pydantic.dev/models/claude-sonnet-5.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 60%   | 6 of 10      | $6.03 | 72       | 567        | 28.4 min |
| Code mode    | 60%   | 6 of 10      | $0.94 | 135      | 125        | 6.9 min  |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gateway/anthropic:claude-sonnet-5` passed 12/20 runs: 6/10 in each mode. These paired cases show dependable execution of narrow accounting tasks, but incomplete application of rules in broader audits. None of the eight failures was provider-caused.

#### Where it does well

Both modes passed invoice correction, payment recording, invoice-total lookup, duplicate detection, and billed-missed detection: 10/10 runs across those five tasks. Corrections produced the exact expected attendance, invoice, allocation, and ledger changes. Payments correctly allocated `50126` as `37626 + 12500`, oldest due date first.

Code mode demonstrated useful recovery in the large margin case: after fetching client tax status, it corrected `116741` to `120741`. Its explicit rounding and aggregation also made the calculation inspectable.

#### Mistakes it makes

All four general invoice-audit runs failed. Tools mode inspected too little supporting data, finding 3/12 large-case errors and 3/4 small-case errors. Code mode fetched the data but encoded incomplete rules: both audits counted duplicate invoice lines as legitimate expected charges; the large audit also failed to exclude individual missed students. It found 6/12 and 3/4 errors respectively.

Three of four margin runs failed. Both small runs omitted tax exemptions, understating margin by `3668`; tools mode's large result was `750` low despite retrieving the necessary records. Code mode also calculated invoice debt correctly, then reversed its sign in the final response.

Some passes were fragile: tools-mode missed-billing detection left two rejected 101-ID attendance batches unresolved. Code mode exceeded its 100 nested-call limit in two cases, recovering with extra calls.

#### Tool calling compared with code mode

Code mode cost `$0.9434` versus `$6.0302`, about 84% less, but used 135 requests versus 72. Most savings came from duplicate and missed-billing searches: together `$0.2525` versus `$5.0029`.

Code mode fixed the large margin failure but introduced the debt-sign failure, leaving accuracy unchanged. It supports cheaper exhaustive retrieval and explicit arithmetic; it does not ensure that every accounting rule is represented. Engineering controls should check attendance eligibility, pair uniqueness, tax exemptions, and final-answer signs independently.

## Runs

### small-invoice_total-1

**Tool calling: passed.** Correctly returned `89700` pence for `INV-00084` in two requests. ($0.018, 2 requests, 4 s)
- Right: Used one `get_invoice` call and returned its tax-inclusive `total`.
- Right: The record showed net `74752` plus tax `14948`, matching `89700`.

**Code mode: passed.** Correctly returned `89700` pence after one `get_invoice` call inside `run_code`. ($0.021, 2 requests, 5 s)
- Right: Read `INV-00084` and returned its tax-inclusive total without introducing unnecessary arithmetic.
- Mistake: Printed the entire invoice using `json.dumps(r, indent=2)` when only `r['total']` was needed.

### small-owed_on_invoices-1

**Tool calling: passed.** Correctly returned `85204` pence still owed by Emeka Brown. ($0.024, 5 requests, 7 s)
- Right: `search_clients` found `CL-0007`; `list_invoices(status="unpaid")` returned `INV-00155` and `INV-00192`.
- Right: Queried allocations for both invoices and correctly calculated `(39452 - 3563) + 49315 = 85204`.
- Right: Reported the amount owed as positive, rather than applying the account-balance sign convention.
- Mistake: Called `get_settings` after retrieving the allocations, although settings were unnecessary for calculating existing invoice debt.

**Code mode: failed.** Calculated the correct debt of `85204` pence but returned `-85204`, failing on the final answer's sign. ($0.027, 5 requests, 9 s)
- Right: `search_clients`, `list_invoices`, and `list_allocations` retrieved the necessary records for `CL-0007`.
- Right: The final code cell explicitly calculated `total_owed = (39452-3563) + (49315-0)` and returned `85204`.
- Mistake: The final response changed the successfully computed positive amount to negative. The question asked how much was owed on invoices, so it should have returned `total_owed` unchanged.

### large-tutor_margin-3

**Tool calling: failed.** Returned `119991` pence for Chen Mensah's October margin, `750` below the correct `120741`. ($0.30, 5 requests, 3.3 min)
- Right: `search_tutors`, `list_lessons`, and `list_attendance` retrieved the relevant October records for `TU-002`, including 67 billable lessons.
- Right: Called `get_client` for all three clients attached to billable gross-priced lessons, correctly obtaining `CL-0097`'s tax exemption.
- Mistake: After the client lookups, the final aggregation was wrong: the retrieved records give net charges `360316` minus tutor pay `239575`, or `120741`.
- Mistake: No intermediate arithmetic was recorded, so the specific line responsible for the `750` discrepancy cannot be identified. It should have calculated and checked per-lesson subtotals before answering.

**Code mode: passed.** Correctly returned `120741` pence after detecting and correcting an initial omission of client tax exemptions. ($0.10, 13 requests, 42 s)
- Right: Filtered 75 lessons to 67 billable lessons and retrieved 79 attendance records.
- Right: Implemented hourly, one-off, split charging, tutor pay, and per-line `Decimal`/`ROUND_HALF_UP` rounding.
- Right: After initially calculating `116741`, fetched 18 clients with `get_client` and added the `if not taxable` branch.
- Right: The corrected calculation was `360316 - 239575 = 120741`.
- Mistake: The first calculation treated every gross-priced line as taxable; this was repaired before the final answer.
- Mistake: Used separate cells for type inspection, sample attendance, and several counts, increasing the run to 13 requests.

### small-tutor_margin-3

**Tool calling: failed.** Returned `61377` pence for Kai Iyer's October margin instead of `65045`, understating it by `3668`. ($0.11, 4 requests, 67 s)
- Right: Retrieved October lessons for `TU-001`, tax settings, and attendance for 37 billable lessons.
- Right: The returned figure matches the calculation obtained when gross-priced charges are treated as taxable throughout.
- Mistake: After `list_attendance`, answered without any `get_client` lookup, leaving client tax exemptions unchecked.
- Mistake: The discrepancy corresponds to four charged gross-priced History lessons for `CL-0037`: subtracting `917` tax on each incorrectly removes `3668` from net revenue.
- Mistake: It should have checked `is_taxable` and retained the full `5500` cost as net revenue for those exempt-client lines.

**Code mode: failed.** Returned `61377` pence instead of `65045`, reproducing tools mode's `3668` understatement by ignoring client tax exemptions. ($0.067, 11 requests, 29 s)
- Right: Filtered 39 lessons to 37 billable lessons, excluded `missed` attendance from revenue, and retained tutor pay for billable lessons.
- Right: Used `Decimal` and `ROUND_HALF_UP`, calculating tutor pay of `122390`.
- Mistake: The third code cell used `lessons[0]['items']`, causing `KeyError: 0`; it recovered by using `lessons['items']`.
- Mistake: The calculation's gross-price branch always deducted tax and never called `get_client` or checked `is_taxable`.
- Mistake: Four charged `5500`-pence gross lessons for exempt client `CL-0037` each lost `917` incorrectly. Correct net revenue is `187435`, giving `187435 - 122390 = 65045`.
- Mistake: The final check only compared lesson counts, so it could not detect the missing tax-exemption rule.

### large-duplicate_lines-1

**Tool calling: passed.** Correctly identified `INV-06060`, `INV-06073`, and `INV-06097`, but required 27 requests and cost `$2.5837`. ($2.58, 27 requests, 10.7 min)
- Right: Retrieved all four October invoice pages and found repeated `(lesson_id, student_id)` pairs.
- Right: The duplicates were `LS-044150`/`ST-0461`, `LS-042250`/`ST-0483`, and `LS-044126`/`ST-0515`.
- Mistake: After listing October invoices, investigated ten clients' invoice histories and fetched September invoices unnecessarily.
- Mistake: Made 401 `get_invoice` calls for 395 distinct invoices, including repeated retrievals and out-of-period records.
- Mistake: Called `get_settings` immediately before answering, although tax settings cannot affect duplicate-pair detection.

**Code mode: passed.** Correctly found the three duplicate-line invoices in 17 requests, costing `$0.1257`, after recovering from a nested-call-limit error. ($0.13, 17 requests, 53 s)
- Right: Collected 394 October invoices, excluded ten void invoices, and ultimately inspected all 384 remaining invoices.
- Right: Counted `(lesson_id, student_id)` occurrences with `seen[key] = seen.get(key, 0) + 1` and selected invoices where `any(v > 1 for v in seen.values())`.
- Mistake: The fifth code cell looped over all remaining 50-invoice batches within one `run_code`, exceeding the 100 nested-tool-call limit.
- Mistake: After the error, re-fetched `ids[50:100]` despite retained results, then spent several cells checking dictionary sizes and coverage. It should have tracked completed batches and resumed with only missing invoices.

### large-missed_billed-1

**Tool calling: passed.** Returned all three correct invoices: `INV-05821`, `INV-05846`, and `INV-06080`. The pass concealed incomplete attendance retrieval and a restricted search strategy. ($2.42, 9 requests, 8.1 min)
- Right: Used `list_lessons` and `list_attendance` to find missed students, then client-filtered `list_invoices` and `get_invoice` to confirm the billed lines.
- Right: Distinguished `missed` from `missed_chargeable`.
- Mistake: Two `list_attendance` calls each supplied 101 lesson IDs and returned `at most 100 lesson ids per call`; neither was retried. It should have split and completed those batches.
- Mistake: Searched September lessons rather than deriving all relevant lesson IDs from October invoice lines, leaving older lessons on October invoices outside its search.
- Mistake: The final `get_settings` call was unnecessary. Despite only nine requests, the extensive records cost `$2.4192`.

**Code mode: passed.** Correctly identified all three billed-missed invoices with a complete invoice-line-to-attendance comparison. ($0.13, 20 requests, 50 s)
- Right: Retrieved 384 non-void invoice details containing 3108 lines and 2655 distinct lesson IDs.
- Right: Fetched attendance in 27 batches of at most 100 lessons and mapped `(lesson_id, student_id)` to status.
- Right: Selected exactly `status == "missed"`, returning `INV-05821`, `INV-05846`, and `INV-06080`.
- Mistake: The first code cell defined a function but assigned `r = asyncio.run(main()) if False else None`, performing no retrieval.
- Mistake: Re-fetched invoice page 1 when collecting all pages, and used separate cells for several simple length checks and final sorting.

### large-wrong_invoices-1

**Tool calling: failed.** Found only three of the twelve overcharged invoices, reporting the tax-exemption errors and missing nine others. ($0.22, 5 requests, 85 s)
- Right: Retrieved all four October invoice pages.
- Right: `get_invoice` and `get_client` correctly established overcharges of `1050` on `INV-05851`, `1150` on `INV-06016`, and `1875` on `INV-06105`.
- Mistake: After pagination, inspected only those three invoices and their clients, then stopped without retrieving lesson or attendance records.
- Mistake: Missed three rate errors, three billed missed attendances, and three duplicate-line errors. It should have reconstructed every non-void invoice from unique eligible student/lesson pairs, rates, durations, attendance, and client tax status.
- Mistake: Fetched historical invoice lists for the three selected clients instead of completing the requested October audit.

**Code mode: failed.** Retrieved the full audit dataset but reported only six of twelve overcharged invoices because its reconstruction preserved invalid and duplicate charges. ($0.25, 32 requests, 1.8 min)
- Right: Collected all 384 non-void invoices, 2655 distinct lessons, attendance records, and client tax statuses.
- Right: Correctly implemented charge rates, durations, split counts, tax exemptions, and half-up rounding.
- Right: Found all three rate errors and all three exempt-client tax errors with correct amounts.
- Mistake: In the discrepancy loop, computed a charge for every existing invoice line without checking that particular student's attendance. `if charged_count == 0: charged_count = 1` concealed non-chargeable lessons rather than assigning zero.
- Mistake: Accumulated expected totals once per existing line without deduplicating `(lesson_id, student_id)`, accepting all three duplicate charges.
- Mistake: Consequently omitted `INV-05821` (`4875`), `INV-05846` (`11700`), `INV-06080` (`4050`), `INV-06060` (`3563`), `INV-06073` (`4500`), and `INV-06097` (`9900`). Expected totals should include each eligible pair once.
- Mistake: Exceeded the 100 nested-call limit twice by combining 90- and 24-item batches in one cell, and attempted unsupported `dir()`. These errors were recovered before the incorrect calculation.

### small-wrong_invoices-1

**Tool calling: failed.** Correctly reported three overcharges but omitted `INV-00176`, overcharged by `6000` pence. ($0.30, 6 requests, 3.1 min)
- Right: Fetched all 37 October invoices and identified the duplicate on `INV-00158` (`4050`), exempt-client tax on `INV-00162` (`863`), and rate error on `INV-00172` (`600`).
- Mistake: Only requested attendance for four lessons on `INV-00149`; it never checked attendance for `INV-00176`.
- Mistake: The omitted line was `LS-001346`/`ST-0046`, marked `missed` but billed `6000`. It should have checked attendance for every invoiced student/lesson pair.

**Code mode: failed.** Correctly found the tax, rate, and missed-attendance errors but omitted the `4050`-pence duplicate charge on `INV-00158`. ($0.14, 21 requests, 70 s)
- Right: Fetched all 37 invoices, 280 distinct lessons, attendance, and 37 clients.
- Right: Applied client tax exemptions and half-up rounding, correctly reporting `INV-00162: 863`, `INV-00172: 600`, and `INV-00176: 6000`.
- Right: Used the individual student's attendance to exclude the missed line `LS-001346`/`ST-0046`.
- Mistake: The discrepancy loop iterated over `inv['lines']` and added a recomputed total for every occurrence, so the repeated `LS-001226`/`ST-0016` line was included twice in the expected total.
- Mistake: It should have deduplicated eligible `(lesson_id, student_id)` pairs before summing. Repeating the same line-level comparison near the end did not test this missing invariant.

### large-correction-2

**Tool calling: passed.** Correctly removed Yara Baker's missed lesson, voided `INV-06372`, and created paid replacement `INV-06548` for `17100` pence. The recorded changes matched the expected result. ($0.018, 4 requests, 13 s)
- Right: `get_invoice` identified `LS-045235` and `ST-0332`; `update_attendance` marked the attendance `missed`.
- Right: `void_invoice` and `create_invoice` used `2026-11-13`; the replacement contained exactly the three remaining lessons, with net `14250`, tax `2850`, and due date `2026-11-27`.
- Right: Released credit automatically covered the replacement invoice.
- Mistake: The final summary expressed the total as `£171.00`, contrary to the handbook's integer-pence answer format.
- Mistake: The initial `search_clients` was redundant because `get_invoice` supplied the client and student identifiers.

**Code mode: passed.** Correctly performed the attendance correction, void, and replacement invoice, producing the same expected changes as tools mode. ($0.021, 5 requests, 16 s)
- Right: Used `run_code` to call `get_invoice`, `update_attendance`, `void_invoice`, and `create_invoice` with the correct identifiers and date.
- Right: Created `INV-06548` for the three remaining lessons, total `17100`, automatically paid from released credit.
- Mistake: The second code cell used `asyncio.gather` for `update_attendance` and `void_invoice`, rather than enforcing the user's requested 'mark ... then void' order; both completed successfully.
- Mistake: Ran an additional cell containing only `1` after completing the work.
- Mistake: The final summary used `£171.00` instead of integer pence.

### large-record_payment-1

**Tool calling: passed.** Correctly recorded Jane Kelly's `50126`-pence payment dated `2026-11-13` and allocated it oldest-due-date first. ($0.035, 5 requests, 21 s)
- Right: `search_clients` resolved `CL-0294`; `list_invoices` and `list_allocations` established the outstanding amounts.
- Right: `record_payment` allocated `37626` to `INV-02840` and `12500` to `INV-03247`, exactly exhausting the payment.
- Right: The first invoice became `paid`; the second remained partially paid and `unpaid`.
- Mistake: The final summary mixed pounds and pence and expressed the allocation amounts only in pounds, rather than consistently using integer pence.

**Code mode: passed.** Correctly recorded and allocated the `50126`-pence payment, then confirmed the resulting invoice statuses. ($0.056, 9 requests, 33 s)
- Right: Summed only allocations with `released_on is None` and sorted outstanding invoices by due date.
- Right: Calculated `58778 - 21152 = 37626` outstanding on `INV-02840`, allocating the remaining `12500` to `INV-03247`.
- Right: `record_payment` used `2026-11-13`; subsequent `get_invoice` calls confirmed `paid` and `unpaid` respectively.
- Mistake: Fetched client details and recent ledger entries that were not used in the allocation calculation.
- Mistake: Ran an empty-string code cell after verification, contributing to nine requests versus five in tools mode.
- Mistake: The final summary expressed allocation amounts in pounds rather than integer pence.
