---
title: "GLM 5.3 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 100%; rank 18 of 44."
canonical: https://pydantic.dev/models/list/glm-5.3/billing_ops/
---

# GLM 5.3 on Pydantic AI - Billing ops

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

| Mode         | Score | Tasks passed | Cost   | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ------ | -------- | ---------- | -------- |
| Tool calling | 80%   | 8 of 10      | $11.23 | 177      | 769        | 66.1 min |
| Code mode    | 100%  | 10 of 10     | $0.93  | 117      | 120        | 20.8 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

GLM-5.3 passed 18 of 20 runs: 8 of 10 with tool calling and 10 of 10 in code mode. Both failures were large audit questions in tool calling. Every lookup, calculation and write task passed in both modes.

#### Where it does well

- **Write tasks (4 of 4).** It reads before it writes. In `large-record_payment-1` it called `list_allocations` first and found a same-day 21152 part-payment on `INV-02840`; its first plan would have misallocated the payment.
- **Handbook rules.** Half-up rounding, gross versus net tax, non-taxable clients and split lessons were right in all four margin runs.
- **Self-checking.** It matched tutor pay to payment orders (`PO-0678`, `PO-0041`) and computed lines to real invoice lines.
- **Working round limits.** In code mode it hit `suspension limit 1000 exceeded`, restarted, and inferred taxability by pricing each invoice both ways, then confirmed with spot checks.

#### Mistakes it makes

- **Reading bulk data by eye.** In `large-missed_billed-1` (tools) two `missed` + `invoiced: true` rows were in the results (`LS-043071`, `LS-044224`) and it wrote "no anomalies" both times.
- **Shortcut instead of a full check.** In `large-wrong_invoices-1` (tools) it scanned invoice headers for tax ratios, never read invoice lines, said it would "accept the residual risk", and found 3 of 12.
- **Dropped tool arguments.** In four tool-calling runs, paginated `list_invoices` and `list_lessons` calls were recorded with only `page` (or without `student_id`), while its reasoning said the filters were included. It repeated the identical call up to eight times in a row: about 24 of 44 requests in `large-wrong_invoices-1` and 14 of 59 in `large-duplicate_lines-1`. The transcripts do not show whether the model or the gateway dropped them.
- **Minor code slips.** Wrong result shapes or keys (`att["items"]`, `a["attendance"]`), each fixed in one step.

#### Tool calling compared with code mode

Code mode was better on every large audit and far cheaper overall: $0.93 for ten cases against $11.23, and 117 requests against 177. The three large audit cases cost $9.81 with tool calling and $0.53 in code mode. Code mode kept thousands of records in sandbox variables and compared them exactly; tool calling pulled up to 1 MB of records into context and compared them by reading. The dropped-argument problem did not appear in code mode. For small tasks tool calling was slightly leaner (2 to 6 requests against 3 to 11), because code mode added verification scripts.

## Runs

### small-invoice_total-1

**Tool calling: passed.** One `get_invoice` call for `INV-00084`, then returned its `total` of 89700. Passed in 2 requests. ($0.0074, 2 requests, 3 s)
- Right: Read the total straight from the record without unnecessary steps.

**Code mode: passed.** Fetched `INV-00084`, then ran a second script to sum the line totals, and returned 89700. Passed in 3 requests. ($0.010, 3 requests, 6 s)
- Right: Line totals summed to the invoice `total`.
- Mistake: The second `run_code` call was unnecessary; it had already added the lines in its reasoning.

### small-owed_on_invoices-1

**Tool calling: passed.** Found `CL-0007`, listed two unpaid invoices, fetched allocations for each in parallel and returned 35889 + 49315 = 85204. Passed in 4 requests. ($0.010, 4 requests, 8 s)
- Right: Subtracted the 3563 credit allocation on `INV-00155` (`payment_id` null) instead of summing invoice totals.
- Right: Checked `pages` and `total` on each list to confirm nothing was cut off.

**Code mode: passed.** Found `CL-0007`, fetched unpaid invoices and all the client's allocations in one script, and returned 85204. Passed in 4 requests. ($0.0084, 4 requests, 10 s)
- Right: One script for both lists; noted that no allocation had `released_on` set.
- Mistake: The final script hard-coded the totals and the 3563 allocation as literals instead of computing from the fetched data, so the code added nothing beyond the mental sum.

### large-tutor_margin-3

**Tool calling: passed.** Listed Chen Mensah's 75 October lessons, fetched attendance and 18 clients, and worked out 360316 net less 239575 tutor pay = 120741 in its head. Passed in 6 requests. ($0.15, 6 requests, 3.6 min)
- Right: Fetched settings, attendance and all `get_client` calls in parallel.
- Right: Handled the three non-taxable clients (`CL-0113`, `CL-0267`, `CL-0097`) and gross-priced lessons correctly.
- Right: Cross-checked tutor pay against payment order `PO-0678` (239575 on 2026-11-03), an exact match.
- Mistake: All arithmetic for 67 billable lessons was done in the reasoning text with no tool support; correct here, but the only independent check was on the tutor-pay half.

**Code mode: passed.** Computed 360316 - 239575 = 120741 in code by request 8, then spent 14 more requests checking it against invoices and payment orders. Passed in 22 requests. ($0.15, 22 requests, 2.6 min)
- Right: Integer half-up rounding in code; split lessons gave 1313 per student as the handbook requires.
- Right: Compared three computed lines with real invoice lines on `INV-06193`, `INV-06243`, `INV-06406` and tutor pay with `PO-0678`; all matched.
- Mistake: Message 7: `att["items"]` raised `TypeError` because `list_attendance` returns a list.
- Mistake: Messages 19 to 23: misread its own `n == 0` output as four lessons with no attendance rows, re-queried them, then realised the students were simply `missed`.
- Mistake: Message 35 submitted a half-written loop (`while True: res = None`) that it never used. Verification tripled the request count.

### small-tutor_margin-3

**Tool calling: passed.** Listed Kai Iyer's 39 October lessons, fetched attendance and 7 clients, and computed 187435 - 122390 = 65045 by hand. Passed in 6 requests. ($0.069, 6 requests, 1.7 min)
- Right: Excluded the two `cancelled` lessons (`LS-001463`, `LS-001544`).
- Right: Applied half-up rounding on gross tax (5625 gives tax 938, net 4687) and treated non-taxable `CL-0030` and `CL-0037` correctly.
- Right: Confirmed tutor pay against payment order `PO-0041` (122390).
- Mistake: Long sums done in the reasoning text only; correct here.

**Code mode: passed.** Fetched Kai Iyer's 39 October lessons, attendance and 7 clients, computed 187435 - 122390 = 65045 in code and re-summed per lesson. Passed in 11 requests. ($0.052, 11 requests, 70 s)
- Right: Per-lesson rows printed for 45- and 90-minute lessons and checked by hand against the handbook rounding rule.
- Right: Handled billable lessons with only a `missed` student as zero income with tutor pay still due.
- Mistake: Message 7: used key `attendance` instead of `status`, giving a `KeyError`; fixed after printing two records.
- Mistake: Did not cross-check tutor pay against the payment order, which the tool-calling run did.

### large-duplicate_lines-1

**Tool calling: passed.** Got the right three invoices, but only after about 14 requests of broken pagination and then fetching roughly 384 invoices with `get_invoice` ten at a time and comparing lines by eye. Passed in 59 requests at $4.56. ($4.56, 59 requests, 13.6 min)
- Right: Recovered from the pagination problem by noticing invoice IDs are contiguous, so October is `INV-05761`..`INV-06154`.
- Right: Checked every non-void invoice, including the 10 reissues `INV-06145`..`INV-06154`.
- Right: Spotted the repeated `(lesson_id, student_id)` pairs: `LS-044150`/`ST-0461`, `LS-042250`/`ST-0483`, `LS-044126`/`ST-0515`.
- Mistake: Messages 3 to 29: every `list_invoices` call for pages 2-4 was recorded as `{"page":2}` (or 3, 4) without `sent_from`/`sent_to`, although the reasoning each time said it would include them. It repeated the same call about 14 times.
- Mistake: Duplicate detection was done by reading about 3,100 invoice lines in context, with no programmatic check. It worked here; the same method failed in `large-missed_billed-1`.
- Mistake: Cost was about 80 times the code-mode run of the same case ($4.56 against $0.055).

**Code mode: passed.** Paged the 394 October invoices in a loop, fetched the 384 non-void ones in four batches of 96 `get_invoice` calls, and detected repeated `(lesson_id, student_id)` pairs in code. Passed in 9 requests at $0.055. ($0.055, 9 requests, 45 s)
- Right: Kept the invoice data in sandbox variables and printed only counts and hits.
- Right: Also checked for pairs repeated across different invoices (none), so both readings of the question gave the same three IDs.
- Mistake: First script hit a runtime error after printing the whole first page; it recovered on the next call.
- Mistake: The duplicate-check loop was pasted four times, once per batch, instead of being a function.

### large-missed_billed-1

**Tool calling: failed.** Scanned attendance for all 2,957 September lessons in 30 `list_attendance` batches and read them by eye for `missed` with `invoiced: true`. It reported only `INV-05846` and missed `INV-05821` and `INV-06080`. Failed. ($1.70, 23 requests, 16.9 min)
- Right: Confirmed the September lesson ID range `LS-041722`..`LS-044678` with `get_lessons` on the boundary IDs.
- Right: Found `LS-041761`/`ST-0127` and confirmed it sits on `INV-05846` with `get_invoice`.
- Right: Excluded the 10 void invoices correctly.
- Mistake: Message 34 (batch `LS-043022`..`LS-043321`): the result contained `LS-043071`/`ST-0491`, `status: missed`, `invoiced: true` (client `CL-0334`, invoice `INV-06080`). Message 35 said "no missed+invoiced anomalies".
- Mistake: Message 42 (batch `LS-044222`..`LS-044421`): the result contained `LS-044224`/`ST-0088`, `status: missed`, `invoiced: true` (client `CL-0065`, invoice `INV-05821`). Message 43 again said no anomalies.
- Mistake: It should have fetched the 384 non-void invoices' lines and matched each `(lesson_id, student_id)` to attendance, or at least re-queried attendance for flagged clients. It stopped at one hit without any cross-check.
- Mistake: Messages 3 to 7: three requests wasted on `list_invoices` calls recorded as `{"page":N}` without the date filters, and `list_lessons` calls missing `start` or `status`.

**Code mode: passed.** Fetched all 384 non-void invoices' lines (3,108 lines, 2,655 lessons), loaded attendance in 27 batches, and filtered lines whose attendance `status` is `missed`. Returned all three invoices. Passed in 13 requests at $0.08. ($0.081, 13 requests, 89 s)
- Right: Matched each invoice line to its attendance record in code and confirmed zero lines lacked a record.
- Right: Re-fetched the three hits with `get_invoice` and `get_lessons` before answering.
- Mistake: One sample call to inspect the invoice shape and a final verification script with a muddled dict comprehension; neither affected the answer.

### large-wrong_invoices-1

**Tool calling: failed.** Never read the lines of the 384 October invoices. It looked for odd tax-to-net ratios in the `list_invoices` headers, found three wrongly taxed invoices and returned those. 9 of the 12 expected invoices were missed. Failed after 44 requests and $3.54. ($3.54, 44 requests, 17.2 min)
- Right: The three rows it returned are correct: `INV-05851` 1050, `INV-06016` 1150, `INV-06105` 1875, each confirmed with `get_client` (`is_taxable: false`) and `get_lessons`.
- Right: Verified about 60 clients' taxability with `get_client` in batches of 10.
- Mistake: Method: a header-ratio scan can only catch tax errors. It cannot see duplicate lines (`INV-06060`, `INV-06073`, `INV-06097`), charged `missed` students (`INV-05821`, `INV-05846`, `INV-06080`) or the other three (`INV-05791` 600, `INV-05877` 750, `INV-06017` 500). It should have called `get_invoice` for each non-void invoice and recomputed every line from `get_lessons` and `list_attendance`.
- Mistake: Message 35: it wrote that other error types were "not verifiable without the massive lessons scan" and that it would "accept the residual risk", then answered as if the check were complete.
- Mistake: Messages 3 to 17 and 37 to 69: about 24 of the 44 requests were `list_invoices` calls recorded as `{"page":N}` without `sent_from`/`sent_to`, repeated up to eight times in a row. It never got November pages 3 and 4 and gave up on them at message 71.
- Mistake: Messages 23 to 29: `list_lessons` calls also lost `status` or `start`.

**Code mode: passed.** Recomputed all 3,108 lines of the 384 non-void October invoices in code and returned all 12 overcharged invoices with the right amounts. Passed in 26 requests at $0.39 after one sandbox restart. ($0.39, 26 requests, 9.9 min)
- Right: When it could not afford `get_client` for all 384 clients, it priced each invoice under both taxable and non-taxable assumptions and picked the one that fit, then confirmed with `get_client` for the 12 flagged clients, September and November invoice headers, and 15 spot checks with no mismatch.
- Right: Caught all three error kinds: duplicate lines, charged `missed` students and wrong tax.
- Right: Checked that every billable charged September lesson was on an invoice, ruling out omissions.
- Mistake: Message 19: a loop of 93 `get_client` calls hit `suspension limit 1000 exceeded`. It restarted the sandbox with `restart: true` and re-fetched all 384 invoices, lessons and attendance, roughly doubling the work.
- Mistake: Fetched invoices sequentially in loops of 96 rather than with `asyncio.gather`.

### small-wrong_invoices-1

**Tool calling: passed.** Fetched all 37 October invoices with `get_invoice`, then lessons, attendance and all 37 clients, and recomputed each line by hand to find the four overcharged invoices. Passed in 23 requests at $1.14. ($1.14, 23 requests, 11.7 min)
- Right: Spotted the duplicate `LS-001226` line on `INV-00158` and the stray 863 tax on non-taxable `CL-0014` while reading the invoices.
- Right: Checked 35 lessons missing from the invoices with `get_lessons` and `list_attendance` and confirmed they were all `missed`, so nothing was under-billed.
- Mistake: Messages 9, 23 to 39: about eight `list_lessons` calls were recorded without the intended `start` or `student_id` (for example `{"end":"2026-09-30","page":1}`), returning the unfiltered list each time. It wrongly concluded for a while that the date filter does not work.
- Mistake: About 11 times the cost of the code-mode run ($1.14 against $0.105).

**Code mode: passed.** Loaded all 37 invoices, 280 lessons, attendance and clients, recomputed each line in code and found four overcharged invoices. Passed in 14 requests at $0.105. ($0.11, 14 requests, 2.9 min)
- Right: Added a separate duplicate-line check, which found `LS-001226`/`ST-0016` twice on `INV-00158`.
- Right: Checked header totals against line sums and that all 323 billable September student-lessons were invoiced.
- Mistake: Message 13 to 16: the first line-by-line comparison reported only three wrong lines (863, 600, 6000) because each duplicate line is individually priced correctly. Without the later duplicate check at message 21 the answer would have missed `INV-00158`.
- Mistake: Message 13: `next(...)` over a generator raised `TypeError` in the sandbox; rewritten with a dict lookup.

### large-correction-2

**Tool calling: passed.** Found the client and invoice, marked the 7 Oct lesson `missed`, voided `INV-06372` and reissued the three remaining lessons as `INV-06548` dated 2026-11-13. Passed in 5 requests. ($0.027, 5 requests, 46 s)
- Right: Worked out that Yara Baker is a student of client `CL-0234` from the `search_clients` result and the invoice lines.
- Right: Used `list_attendance` to confirm `LS-045235`/`ST-0332` was `attended` before changing it.
- Right: Issued `update_attendance` and `void_invoice` together, then `create_invoice` with only `LS-045914`, `LS-046583`, `LS-047246`.
- Right: Summary correctly explained the new invoice is already `paid` from the released 22800 credit, leaving 5700 unallocated.
- Mistake: Did not re-read allocations or the ledger after the writes; it inferred the credit application from the `paid` status returned by `create_invoice`.

**Code mode: passed.** Read the client, invoice, lessons, attendance, allocations and ledger, then updated attendance, voided `INV-06372` and created `INV-06548`, and re-read allocations and ledger to confirm. Passed in 8 requests. ($0.038, 8 requests, 57 s)
- Right: Checked that the client has only one student and that the two November lessons should stay off the reissue.
- Right: Verified after the writes: 17100 allocated from credit to `INV-06548`, the old 22800 allocation has `released_on` 2026-11-13, 5700 credit left.
- Mistake: Three more requests than tool calling for the same result, mostly extra reads before acting.

### large-record_payment-1

**Tool calling: passed.** Found `CL-0294`, listed unpaid invoices and allocations, then recorded 50126 split 37626 to `INV-02840` and 12500 to `INV-03247`. Passed in 5 requests. ($0.020, 5 requests, 29 s)
- Right: Stopped before recording to call `list_allocations`, which showed an existing 21152 on `INV-02840` from payment `LE-013542` the same day. Its first plan (all 50126 to `INV-02840`) would have been wrong.
- Right: Allocated oldest due date first and computed the remainder correctly: 58778 - 21152 = 37626, then 12500.
- Right: Summary stated `INV-03247` still has 12504 to pay and no credit is left.

**Code mode: passed.** Read unpaid invoices, allocations and today's ledger entries, computed the split in code, recorded the payment and re-read the result. Passed in 7 requests. ($0.032, 7 requests, 48 s)
- Right: Looked up `LE-013542` to confirm the earlier 56252 payment today was a different payment, not a duplicate of this one.
- Right: Confirmed afterwards that `INV-02840` is `paid` and `INV-03247` has a 12500 allocation.
- Mistake: Two more requests than tool calling, spent on a separate allocation-computing script and a post-write check.
