---
title: "DeepSeek V4 Pro 0423 on Pydantic AI - Billing ops"
description: "Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 90%, code mode 20%; rank 4 of 44."
canonical: https://pydantic.dev/models/list/deepseek-v4-pro/billing_ops/
---

# DeepSeek V4 Pro 0423 on Pydantic AI - Billing ops

> Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 90%, code mode 20%; rank 4 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/deepseek-v4-pro/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/deepseek-v4-pro/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 90%   | 9 of 10      | $2.33 | 103      | 654        | 47.4 min |
| Code mode    | 20%   | 2 of 10      | $1.14 | 345      | 347        | 12.6 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

DeepSeek-V4-Pro passed 9 of 10 cases in tool calling and 2 of 10 in code mode. Tool calling cost about $2.33 in total, code mode about $1.14. In tool calling it is careful and correct but does all arithmetic and scanning by reading. In code mode it mostly breaks down: 7 of 8 failures are the model resending one identical `run_code` call until it stops or runs out of requests.

#### Where it does well

- **Write tasks in tool calling.** `large-correction-2` (6 requests) and `large-record_payment-1` (5 requests) matched the expected changes exactly, including noticing an existing same-day allocation of 21152 on `INV-02840`.
- **Rule handling.** Both tutor-margin cases passed in tool calling with `is_taxable` checked for every client, split-lesson rounding and tutor pay for lessons with a `missed` student.
- **Exhaustive audits when it commits to them.** `small-wrong_invoices-1` recomputed all 37 invoices; `large-duplicate_lines-1` read all 384 non-void invoices; `large-missed_billed-1` found the `missed` + `invoiced: true` signal in `list_attendance`.

#### Mistakes it makes

- **Repeating the same call (6 code-mode cases).** Four cases hit the 60-request limit: `await get_settings()` 59 times, the same paging snippet about 56 times, the same `list_allocations` about 56 times, and a snippet reading the wrong keys (`invoices`, `results` instead of `items`) 60 times. Two more looped and then submitted a placeholder (`pence: 0`, `INV-00149: 0`).
- **Giving up with a made-up answer (3 code-mode cases).** `large-wrong_invoices-1` wrote correct helpers, never ran them, and named an invoice it had just verified as correct.
- **Shortcut instead of a full audit.** In tool calling, `large-wrong_invoices-1` used the tax/net ratio from `list_invoices` only and found 3 of 12 invoices.
- **Missed rule.** Code-mode `small-tutor_margin-3` never called `get_client`, so it removed tax from gross lessons of non-taxable clients (61377 against 65045).
- **Cost.** The large tool-calling scans cost $0.62 and $0.90 each because every record was read in context.

#### Tool calling compared with code mode

Tool calling is much the better mode for this model: 9/10 against 2/10. The two code-mode passes were the simplest lookups, and one took 6 requests against 4. Where code mode did produce a real script (`small-tutor_margin-3`), the arithmetic was sound and the error was a missing lookup. The dominant problem is not the code but the model failing to move to the next step after a `run_code` result.

## Runs

### small-invoice_total-1

**Tool calling: passed.** One `get_invoice` call for `INV-00084`, then answered 89700. Passed in 2 requests. ($0.0071, 2 requests, 5 s)
- Right: Read `total` directly from the invoice.

**Code mode: passed.** One `run_code` with `await get_invoice(invoice_id="INV-00084")`, then answered 89700. Passed in 2 requests. ($0.0073, 2 requests, 3 s)
- Right: Same single lookup as tools mode, at the same cost ($0.007).

### small-owed_on_invoices-1

**Tool calling: passed.** `search_clients`, `list_invoices` with `status: unpaid`, `list_allocations`, then 39452 + 49315 - 3563 = 85204. Passed in 4 requests. ($0.0054, 4 requests, 14 s)
- Right: Subtracted the unreleased credit allocation of 3563 on `INV-00155`.

**Code mode: passed.** Five separate `run_code` calls: `search_clients`, `get_client`, `list_invoices`, two `list_allocations`, and one that only evaluated `39452 - 3563 + 49315`. Passed with 85204 in 6 requests. ($0.022, 6 requests, 14 s)
- Right: Filtered `list_allocations` by `invoice_id` for each unpaid invoice.
- Mistake: Used one tool call per `run_code` and a separate call for a three-term sum; 6 requests and $0.022 against 4 requests and $0.005 in tools mode.
- Mistake: The `get_client` call was not needed.

### large-tutor_margin-3

**Tool calling: passed.** Fetched 75 lessons for `TU-002`, attendance for all of them in one `list_attendance` call, and 18 `get_client` calls in parallel, then worked out the margin lesson by lesson in its reasoning. Passed with 120741 in 5 requests. ($0.095, 5 requests, 4.7 min)
- Right: Checked `is_taxable` for every client and found `CL-0113`, `CL-0267`, `CL-0097` non-taxable.
- Right: Handled `hourly_split` rounding per student (5250 / 4 = 1312.5 -> 1313) and paid the tutor for billable lessons where the student was `missed`.
- Mistake: All arithmetic for 75 lessons was done by hand in one long reasoning step; correct here, but nothing checked it.

**Code mode: failed.** Fetched the tutor, 75 lessons and settings, then sent a `run_code` whose code was the literal `...` (result `Ellipsis`), and after that mostly repeated `search_tutors(name="Chen Mensah")`. After 19 requests it submitted `pence: 0`; expected 120741. ($0.053, 19 requests, 40 s)
- Right: One call in the middle did fetch lessons and attendance (75 lessons, 90 attendance rows).
- Mistake: Message 5: the code argument was just `...`, a placeholder rather than a program.
- Mistake: Messages 7-35: about 13 identical `search_tutors` calls, even after its own notes said 'I already have everything I need' and 'I need to stop looping'.
- Mistake: Never fetched clients or computed anything; the final `0` is not derived from any data.
- Mistake: It should have run one script over the lessons, attendance and `get_client` results, as in the small code-mode case.

### small-tutor_margin-3

**Tool calling: passed.** Fetched 39 lessons for `TU-001`, attendance for all, and 7 `get_client` calls, then computed the margin by hand. Passed with 65045 in 5 requests. ($0.046, 5 requests, 2.3 min)
- Right: Found `CL-0030` and `CL-0037` non-taxable and treated the gross lesson `LS-001398` for `CL-0037` as net = cost = 5500 with no tax removed.
- Right: Excluded the two `cancelled` lessons and still paid the tutor for complete lessons with a `missed` student.
- Mistake: Hand arithmetic over 37 lessons in one reasoning step, unchecked.

**Code mode: failed.** Fetched lessons and attendance for `TU-001` and computed the margin in a script, but never looked up the clients. Answered 61377; expected 65045. ($0.035, 8 requests, 18 s)
- Right: The script handled billable status, charged attendance, hours, half-up rounding with `Decimal`, and tutor pay once per lesson.
- Right: Re-ran the calculation a second way and got the same 183767 - 122390 = 61377.
- Mistake: No `get_client` call, so `is_taxable` was never checked. The script removed tax from every `gross` lesson, including those of non-taxable clients such as `CL-0037` (e.g. `LS-001398`), where net should equal cost. The tools run found `CL-0030` and `CL-0037` non-taxable.
- Mistake: Its second pass only repeated the same logic, so it could not catch the missing rule.

### large-duplicate_lines-1

**Tool calling: passed.** Paged `list_invoices` for October (394 invoices), then fetched all 384 non-void invoices with `get_invoice` in parallel batches of about 20-25 and read the lines by eye for repeated `(lesson_id, student_id)` pairs. Passed with `INV-06060`, `INV-06073`, `INV-06097`. ($0.62, 21 requests, 6.9 min)
- Right: Covered every non-void invoice, skipping the 10 void ones it had listed.
- Right: Correctly dismissed same lesson with different students (e.g. `LS-042214` on `INV-05884`) as not a duplicate.
- Mistake: Detection was by reading roughly 600KB of invoice JSON by eye; it passed, but a missed pair would have gone unnoticed. Cost $0.62 over 21 requests.

**Code mode: error.** Paged `list_invoices` into `all_inv` (394 invoices) in its third call, then re-ran that same paging snippet for every remaining request, getting `394` back each time. Hit the 60-request limit without fetching a single invoice's lines. ($0.17, 60 requests, 2.1 min)
- Right: The paging loop `for p in range(1, 5)` was correct and collected all 394 invoices.
- Mistake: First call did `len(inv)` on the paged dict and read the result 4 as 'only 4 invoices'; it corrected this on the next call.
- Mistake: From message 7 onward it resent the identical paging code about 56 times instead of the next step: `get_invoice` for each non-void id and a count of `(lesson_id, student_id)` pairs.

### large-missed_billed-1

**Tool calling: passed.** After sampling a few invoices, it switched to scanning `list_attendance` for every September lesson id `LS-041722` to `LS-044678` in batches of 100, looking for `status: missed` with `invoiced: true`, then confirmed the three invoices with `get_invoice`. Passed in 30 requests. ($0.90, 30 requests, 11.4 min)
- Right: Found a cheaper signal than fetching 384 invoices: `missed` plus `invoiced: true` in `list_attendance`.
- Right: Confirmed each hit against the invoice lines: `LS-041761` on `INV-05846`, `LS-043071` on `INV-06080`, `LS-044224` on `INV-05821`.
- Mistake: Assumed all October invoice lines are September lessons in one contiguous id range; it reasoned about this at the end but did not check it against the invoices.
- Mistake: Most expensive case at $0.897: about 30 `list_attendance` responses of 25KB each read by eye, plus exploratory `list_lessons` and `get_invoice` batches it then abandoned.

**Code mode: error.** Its first snippet read `inv_data.get('invoices', inv_data.get('results', []))` and got 0 items, with the keys shown as `['items', 'page', 'pages', 'total']`. It then resent that same snippet for all 60 requests. ($0.12, 60 requests, 2.0 min)
- Right: Its opening reasoning laid out the right plan: invoice lines joined to attendance for `missed`.
- Mistake: Guessed the keys `invoices` and `results`; the output showed the list is under `items`, and it never changed the code.
- Mistake: Repeated the identical call 59 more times until `UsageLimitExceeded`.

### large-wrong_invoices-1

**Tool calling: failed.** Listed all 394 October invoices, then looked for wrong ones only by comparing `tax` to `net` in the `list_invoices` summaries. It returned 3 of the 12 expected invoices (`INV-05851`, `INV-06016`, `INV-06105`), all tax charged to non-taxable clients, with correct amounts. ($0.33, 15 requests, 10.0 min)
- Right: The three it reported are right: 1050, 1150 and 1875, each verified with `get_invoice`, `get_lessons` and `get_client`.
- Right: Verified that the small deviation on `INV-05834` (tax 3903) was correct per-line rounding.
- Mistake: After the fourth `list_invoices` page it decided that fetching every invoice was too heavy and used the tax/net ratio as the only detector. That cannot see duplicate lines, lines for `missed` students or wrong rates, so it missed 9 invoices, including `INV-06060`, `INV-06073`, `INV-06097`, `INV-05821`, `INV-05846` and `INV-06080`.
- Mistake: In its last reasoning steps it wrote that line-cost errors would be hidden from the summaries and that a full audit might be needed, then answered with three anyway.
- Mistake: It should have fetched all 384 non-void invoices with `get_invoice` and recomputed each line from `get_lessons`, `list_attendance` and `get_client`, as it did in the small version of this case.

**Code mode: failed.** Listed the four pages of October invoices, spot-checked `INV-05761` and `INV-05762`, and defined `compute_cost` and `line_total` helpers. It then stopped after 15 requests and submitted `INV-05762` with `pence: 0`; 12 invoices were expected. ($0.15, 15 requests, 49 s)
- Right: The `line_total` helper encodes net, gross and non-taxable rules correctly, and its test reproduced the `INV-05762` line (4688, 938, 5626).
- Right: Counted 394 invoices, 384 non-void.
- Mistake: Never ran the helpers over the 384 invoices; no loop over `get_invoice`, `get_lessons`, `list_attendance` or `get_client` was written.
- Mistake: The answer names an invoice its own comment had just called correct ('So this invoice is correct'), with an overcharge of 0.
- Mistake: Printed full 14KB invoice pages four times before collecting them in a loop.

### small-wrong_invoices-1

**Tool calling: passed.** Fetched all 37 non-void October invoices with parallel `get_invoice` calls, all their lessons and attendance, and all 37 clients, then recomputed every line by hand. Passed with the four expected invoices and amounts in 10 requests. ($0.30, 10 requests, 10.7 min)
- Right: Full audit instead of a heuristic: every line recomputed from `get_lessons`, `list_attendance` and `get_client`.
- Right: Recovered from the `at most 100 lesson ids per call` error by re-splitting the batch.
- Mistake: One `get_lessons` call was sent with about 119 ids and rejected; one wasted round.
- Mistake: The final reasoning step is about 87KB of hand calculation; cost $0.30.

**Code mode: failed.** Listed the 37 October invoices, then ran `invoices = await asyncio.gather(*(get_invoice(invoice_id=i) for i in ids))` followed by `invoices[0]` about 50 times, with `restart: true` on the later ones. After 55 requests it submitted `INV-00149` with `pence: 0`; four invoices were expected. ($0.21, 55 requests, 2.1 min)
- Right: The `asyncio.gather` over ids `INV-00149` to `INV-00185` was the right way to fetch all invoices in one call.
- Mistake: Repeated `get_settings` and `list_invoices` once each before starting (messages 5-8).
- Mistake: Resent the identical gather snippet from message 11 to message 107, each time seeing only `invoices[0]`; it never fetched lessons, attendance or clients and never computed a line.
- Mistake: Final answer is the first invoice in the list with 0 overcharge, not a result of any check.

### large-correction-2

**Tool calling: passed.** Looked up the client and invoice, checked lessons, attendance and settings, then ran `update_attendance`, `void_invoice` and `create_invoice` in order. Passed in 6 requests with the exact expected changes. ($0.015, 6 requests, 37 s)
- Right: Resolved Yara Baker as student `ST-0332` under client `CL-0234` from the lines of `get_invoice` when `search_clients` returned the parent.
- Right: Parallel `get_lessons`, `list_attendance` and `get_settings` before writing anything.
- Right: Reissued with only `LS-045914`, `LS-046583`, `LS-047246`, dated `2026-11-13`; new invoice total 17100 was auto-paid from the released credit.

**Code mode: error.** Called `run_code` with `await get_settings()` 59 times in a row, receiving the same result each time, and never looked up the client, invoice or lesson. Hit the 60-request limit with no change made. ($0.073, 60 requests, 2.0 min)
- Mistake: From the first request it repeated `await get_settings()` unchanged until `UsageLimitExceeded`; no `search_clients`, `get_invoice`, `update_attendance`, `void_invoice` or `create_invoice` was ever called.
- Mistake: It should have followed the 6-step path the tools run used.

### large-record_payment-1

**Tool calling: passed.** Found client `CL-0294`, listed unpaid invoices and allocations, and called `record_payment` for 50126 with 37626 to `INV-02840` and 12500 to `INV-03247`. Passed in 5 requests. ($0.012, 5 requests, 33 s)
- Right: Noticed the existing same-day allocation of 21152 on `INV-02840` and paid only the remaining 37626 (58778 - 21152).
- Right: Applied oldest due date first and allocated the full amount.

**Code mode: error.** Ran `search_clients`, `get_client`, `list_invoices` and `list_allocations` correctly, which gave everything needed, then repeated the same `list_allocations(client_id="CL-0294")` call about 56 times. Hit the 60-request limit without calling `record_payment`. ($0.30, 60 requests, 2.3 min)
- Right: The first four calls collected the same data the passing tools run used.
- Mistake: From message 9 it resent the `list_allocations` snippet unchanged, each time receiving the same 12 allocations, instead of calling `record_payment` with 37626 to `INV-02840` and 12500 to `INV-03247`.
- Mistake: Most expensive code-mode case at $0.30 because the allocation list was re-read every turn.
