---
title: "Claude Sonnet 5.5 on Pydantic AI - Billing ops"
description: "Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 80%, code mode 90%; rank 18 of 44."
canonical: https://pydantic.dev/models/list/claude-sonnet-5.5/billing_ops/
---

# Claude Sonnet 5.5 on Pydantic AI - Billing ops

> Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 80%, code mode 90%; rank 18 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/claude-sonnet-5.5/billing_ops/. Index for agents: https://pydantic.dev/models/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://pydantic.dev/models/api/select` with a JSON body such as `{"description": "what the agent does"}`. It returns up to five ranked models with reasons. Format: https://pydantic.dev/models/select.md
- Search models by name: `GET https://pydantic.dev/models/api/search?query=<text>`
- List, filter and sort models: `GET https://pydantic.dev/models/api/models`, for example `?weights=open&max_price=2&sort=efficiency`
- One model in full: `GET https://pydantic.dev/models/api/models/<slug>`
- Any other question about the models: `GET https://pydantic.dev/models/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://pydantic.dev/models/mcp`. More: https://pydantic.dev/models/usage.md

About the benchmark: https://pydantic.dev/models/benchmarks/billing_ops.md. The model on every Pydantic AI benchmark: https://pydantic.dev/models/list/claude-sonnet-5.5/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 80%   | 8 of 10      | $3.32 | 87       | 566        | 10.0 min |
| Code mode    | 90%   | 9 of 10      | $0.41 | 68       | 66         | 3.1 min  |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`claude-sonnet-5-5` passed 17 of 20 runs: 8/10 with tool calling and 9/10 in code mode. Lookups, margin calculations and the void-and-reissue correction were right in both modes. The failures were the large invoice audit (both modes) and a payment where it made unrequested writes.

#### Where it does well

- **Handbook rules.** Margin was exact in all four runs (120741, 65045), including half-up rounding, gross/net tax, non-taxable clients and paying the tutor for lessons where the only student was `missed`.
- **Write ordering.** Both `large-correction-2` runs read first, then did `update_attendance`, `void_invoice`, `create_invoice` dated today, and reported the 5700 credit left over.
- **Efficient shortcuts.** In `large-tutor_margin-3` (tools) it fetched only the 3 clients on `gross` lessons out of 18. In `large-missed_billed-1` (tools) it used the `invoiced` flag on attendance instead of opening 384 invoices.
- **Honest summaries.** It disclosed its own stray 1p payment and refund.

#### Mistakes it makes

- **Incomplete audit at scale (tools).** `large-wrong_invoices-1` opened 6 of 384 invoices, never called `list_attendance`, and returned 3 of 12 rows. The same task on 37 invoices was done in full.
- **A checker bug (code mode).** `large-wrong_invoices-1` summed expected amounts per line, so duplicated lines looked correct; 3 of 12 invoices missed. Its small-variant script had the duplicate check.
- **Probing with writes.** In `large-record_payment-1` (tools), after a correct `record_payment`, it called it again with `amount: 0`, then `amount: 1`, then `record_refund` of 1, adding two ledger entries.
- **Sandbox friction.** Code mode hit the 100-nested-call limit in 3 runs, tried the unavailable `fractions` module twice, and spent requests on `print(1)` and a one-line sum. All recovered.

#### Tool calling compared with code mode

Code mode was more accurate (9/10 against 8/10) and far cheaper: about $0.41 total against $3.32. The gap is almost all in the three large scans: `large-duplicate_lines-1` cost $1.14 with tools and $0.03 in code, `large-missed_billed-1` $1.19 against $0.04. With tools the model reads every record itself, and on the hardest scan it sampled instead. Code mode always loaded everything; its one failure was a logic bug, not missing data. For small lookups the two modes are equivalent (2 to 5 requests, under $0.07).

## Runs

### small-invoice_total-1

**Tool calling: passed.** One `get_invoice` call for `INV-00084`, answered 89700. Correct in 2 requests. ($0.019, 2 requests, 3 s)
- Right: Read the `total` field directly

**Code mode: passed.** One script calling `get_invoice` for `INV-00084`, answered 89700. Correct in 2 requests. ($0.020, 2 requests, 3 s)
- Right: Read the `total` field directly

### small-owed_on_invoices-1

**Tool calling: passed.** Found client `CL-0007`, pulled unpaid invoices and allocations in parallel, and answered 39452 - 3563 + 49315 = 85204. Correct in 3 requests. ($0.019, 3 requests, 4 s)
- Right: Subtracted the 3563 credit allocation on `INV-00155` rather than summing totals

**Code mode: passed.** Looked up the client, printed unpaid invoices and allocations, then ran `print(39452-3563+49315)` to get 85204. Correct in 4 requests. ($0.0084, 4 requests, 9 s)
- Right: Subtracted the 3563 allocation on `INV-00155`
- Mistake: Used a separate `run_code` request just to add three numbers typed in by hand, instead of computing from the data in the previous script

### large-tutor_margin-3

**Tool calling: passed.** Listed 75 lessons, fetched attendance for the 67 billable ones, looked up only three clients, and produced 120741 with no calculator. Correct in 5 requests. ($0.097, 5 requests, 30 s)
- Right: Excluded the 8 `cancelled` lessons from the `list_attendance` call
- Right: Only called `get_client` for `CL-0097`, `CL-0269`, `CL-0065`: taxability only changes the net on `gross` lessons, so the other 15 clients were not needed
- Right: Still paid the tutor on the four lessons where the only student was `missed`
- Mistake: All arithmetic over 67 lessons was done without a tool; it was right, but there is no visible check

**Code mode: passed.** Listed lessons, attendance and 18 clients, then computed net 360316 less tutor pay 239575 = 120741 with integer half-up rounding. Correct in 9 requests. ($0.064, 9 requests, 23 s)
- Right: Used integer rounding `(2*n+d)//(2*d)`, avoiding float error
- Right: Checked the four lessons with no charged student and confirmed they were `missed`
- Mistake: One request wasted on `from fractions import Fraction if False else None` (syntax error)
- Mistake: Next script failed with `NameError: name 'datetime' is not defined` because the import was in the failed script

### small-tutor_margin-3

**Tool calling: passed.** Listed 39 lessons, fetched attendance for the 37 billable ones and all seven clients, then answered 65045. Correct in 5 requests. ($0.067, 5 requests, 22 s)
- Right: Dropped the two `cancelled` lessons before `list_attendance`
- Right: Seven `get_client` calls in one parallel request
- Right: Handled two non-taxable clients and four all-`missed` lessons correctly without a calculator

**Code mode: passed.** Loaded 39 lessons, attendance and seven clients, computed 187435 - 122390 = 65045. Correct in 7 requests. ($0.026, 7 requests, 19 s)
- Right: Integer half-up rounding helper `rd(n,d)`
- Right: Confirmed the four lessons with no charged student before answering
- Mistake: `from fractions import Fraction` failed with `ModuleNotFoundError`, costing one request
- Mistake: Seven sequential `get_client` calls inside a dict comprehension rather than `asyncio.gather`

### large-duplicate_lines-1

**Tool calling: passed.** Paged `list_invoices` (4 pages) and then called `get_invoice` for roughly all 384 non-void invoices in parallel batches of 10 to 50, spotting the three duplicates by reading. Correct, but cost $1.14. ($1.14, 12 requests, 2.3 min)
- Right: Covered every invoice rather than sampling
- Right: Found `INV-06060`, `INV-06073`, `INV-06097` by eye in about 630k characters of results
- Mistake: Batches were issued out of order (after `INV-05851`.. it jumped to `INV-06145`.. then back to `INV-05901`..), which makes coverage hard to verify; it happened to be complete
- Mistake: Brute force cost $1.1355 against $0.0322 in code mode

**Code mode: passed.** Paged invoices, fetched all 384 with `asyncio.gather` in batches of 95, and found duplicates with a `Counter` over `(lesson_id, student_id)`. Correct in 5 requests, $0.03. ($0.032, 5 requests, 12 s)
- Right: Recovered from the 100-nested-call limit by splitting into four `run_code` calls of 95
- Right: Printed `len(res)` (95, 190, 285, 384) to confirm coverage
- Mistake: Second request asked for 384 `get_invoice` calls in one script and hit `Code mode allows 100 nested tool calls`
- Mistake: Left a dead line in one script: `for a in range(95,384,95): await go(...) if False else None`

### large-missed_billed-1

**Tool calling: passed.** Skipped fetching invoices and instead swept `list_attendance` over consecutive lesson ID ranges from `LS-041722` to about `LS-044731`, looking for `missed` with `invoiced: true`, then confirmed three invoices with `get_invoice`. Correct in 17 requests, $1.19. ($1.19, 17 requests, 3.3 min)
- Right: Used the `invoiced` flag on attendance to avoid 384 `get_invoice` calls
- Right: Verified candidates with `get_lessons` and `get_invoice` on `INV-05846`, `INV-06080` and a third before answering
- Mistake: Lesson IDs were generated as consecutive ranges rather than taken from invoice lines; it relies on September IDs being contiguous and on October invoices only covering September lessons
- Mistake: Eleven sequential `list_attendance` requests with growing batch sizes made this the most expensive case at $1.1905

**Code mode: passed.** Fetched all 384 invoices and attendance for 2655 lessons, then joined lines to attendance and found three `missed` lines. Correct in 8 requests. ($0.041, 8 requests, 20 s)
- Right: After the call limit error it rebuilt a `todo` list of invoices not yet in `full`, so nothing was fetched twice or skipped
- Right: Printed a status `Counter` (2760 attended, 345 missed_chargeable, 3 missed) as a sanity check
- Mistake: First script guessed the keys `invoices` and `next_page` and collected 0 rows; the real keys are `items` and `pages`
- Mistake: Looped four batches of 95 in one script and hit the 100-nested-call limit

### large-wrong_invoices-1

**Tool calling: failed.** Paged the 394 invoice summaries, then opened only six invoices and one page of September lessons, and reported 3 of the 12 wrong invoices. Failed. ($0.22, 7 requests, 54 s)
- Right: Spotted `INV-05851`, `INV-06016`, `INV-06105` from the summaries (tax on mostly untaxed invoices) and confirmed with `get_client` that those clients are not taxable
- Right: The three amounts it gave (1050, 1150, 1875) are correct
- Mistake: Called `get_invoice` for only `INV-05851`, `INV-05821`, `INV-06016`, `INV-06021`, `INV-06105`, `INV-05993`; the other 378 non-void invoices were never opened
- Mistake: Never called `list_attendance`, so the three missed-but-billed invoices could not be found, even though it had `INV-05821` open
- Mistake: Called `list_lessons` for September once and did not page, so wrong rates and duplicate lines went unchecked; nine invoices missed (`INV-05791`, `05821`, `05846`, `05877`, `06017`, `06060`, `06073`, `06080`, `06097`)
- Mistake: It should have fetched every invoice, its lessons and attendance, as it did in the small variant

**Code mode: failed.** Fetched all 384 invoices, lessons, attendance and clients and recomputed every line, but reported 9 of 12: the three invoices with duplicate lines were missed. Failed. ($0.074, 11 requests, 39 s)
- Right: Full data load, recovering from the 100-nested-call limit
- Right: Found six price or tax errors and three missed-but-billed lines, each with the correct amount
- Mistake: The check script looped `for ln in f['lines']` and added the expected amount once per line, so a line that appears twice was expected twice and `ee == f['total']`; `INV-06060` (3563), `INV-06073` (4500) and `INV-06097` (9900) passed the check
- Mistake: It never counted `(lesson_id, student_id)` pairs per invoice; in the small variant it keyed expected amounts by that pair and ran an explicit `Counter` check, which is what was needed here
- Mistake: The three missed-billed amounts were added by hand (`out['INV-05821']=4875` etc.) instead of from the computed difference

### small-wrong_invoices-1

**Tool calling: passed.** Opened all 37 invoices, paged September lessons, fetched attendance and clients, and found all four wrong invoices with the right amounts. Correct in 13 requests, $0.49. ($0.49, 13 requests, 1.8 min)
- Right: Full coverage: every invoice, lesson page and attendance batch
- Right: Caught four different fault types: duplicate line (`INV-00158`), tax on a non-taxable client (`INV-00162`), wrong rate (`INV-00172`), missed student billed (`INV-00176`)
- Mistake: Called `search_clients` with `name: ""` to try to list every client, then fell back to individual `get_client` calls
- Mistake: Invoices were fetched in small sequential batches (3, then about 12 at a time) rather than one parallel request

**Code mode: passed.** Loaded 37 invoices, 280 lessons, attendance and clients, recomputed expected lines per invoice, and found all four wrong invoices. Correct in 9 requests. ($0.082, 9 requests, 31 s)
- Right: When the first check flagged 19 invoices, it saw that shared lessons include other clients' students and filtered by `a['client_id']==f['client_id']`, leaving the 4 true errors
- Right: Ran an explicit `Counter` duplicate check that confirmed `INV-00158`
- Mistake: First script failed the type check on `invs+=items` (`Any | None`)
- Mistake: One request spent on `print(1)` before the final answer

### large-correction-2

**Tool calling: passed.** Marked the student missed, voided `INV-06372` and reissued the three remaining lessons as `INV-06548` (17100) in 5 requests; all changes matched. ($0.017, 5 requests, 11 s)
- Right: Read `get_invoice`, `list_attendance` and `list_allocations` before writing anything
- Right: Ran `update_attendance` and `void_invoice` before `create_invoice`, all dated `2026-11-13`
- Right: Summary correctly reported the 5700 left as unallocated credit

**Code mode: passed.** Read the invoice, attendance and allocation, then did `update_attendance`, `void_invoice` and `create_invoice` in one script and checked the ledger. Correct in 5 requests. ($0.023, 5 requests, 13 s)
- Right: All three writes in one `run_code` call in the right order
- Right: Checked `list_allocations` and `list_ledger_entries` afterwards and reported the 5700 unallocated credit

### large-record_payment-1

**Tool calling: failed.** Recorded the 50126 payment with the right allocations on the fourth request, then kept going for 14 more requests, created a stray 1p payment and a 1p refund, and failed on the two extra ledger entries. ($0.059, 18 requests, 35 s)
- Right: Worked out 58778 - 21152 = 37626 still owed on `INV-02840` and put the remaining 12500 on `INV-03247`
- Right: The first `record_payment` call was exactly the expected change
- Right: Summary admitted the 1p payment `LE-013561` and refund `LE-013562`
- Mistake: Right after the successful payment it called `record_payment` with `amount: 0` and empty `allocations` (rejected: `amount must be positive`), then five requests later called it again with `amount: 1`, which succeeded as `LE-013561`
- Mistake: Undid it with `record_refund` of 1 (`LE-013562`), leaving two extra ledger entries; it should have stopped after verifying with `list_allocations`
- Mistake: Redundant reads afterwards: `get_client` three times, `get_settings` twice more, `get_invoice` for `INV-03247` twice

**Code mode: passed.** Recorded one `record_payment` of 50126 with allocations 37626 to `INV-02840` and 12500 to `INV-03247`, then verified. Correct in 8 requests. ($0.042, 8 requests, 17 s)
- Right: Checked the ledger and noticed today's earlier 56252 payment `LE-013542` before allocating, and left it alone
- Right: Verified afterwards that `INV-02840` moved to `paid`
- Mistake: Summary contains a stray aside: `(5012600 is wrong; the amount is 50126 pence)`
- Mistake: Three verification requests after the write where one would do
