---
title: "Qwen3.7 Flash on Pydantic AI - Billing ops"
description: "Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 30%, code mode 60%; rank 40 of 44."
canonical: https://pydantic.dev/models/list/qwen3.7-flash/billing_ops/
---

# Qwen3.7 Flash on Pydantic AI - Billing ops

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

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 30%   | 3 of 10      | $0.17 | 145      | 173        | 30.0 min |
| Code mode    | 60%   | 6 of 10      | $0.12 | 167      | 160        | 27.6 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

Qwen3.7-flash passed 10 of 20 runs: 4 of 10 in tool-calling mode and 6 of 10 in code mode. It is very cheap (no run cost more than about $0.065). It is reliable on direct lookups and the one correction task. It is weak whenever a question needs every record checked or many lessons priced.

#### Where it does well

- **Simple questions:** `invoice_total` and `owed_on_invoices` passed in both modes.
- **The complex correction:** `large-correction-2` passed in both modes, with the exact diff. That meant changing the attendance, voiding the invoice with a credit note, releasing the allocation and re-invoicing three lessons for 17100, paid from credit.
- **Code mode on the large audits:** with code it checked every record and passed `large-duplicate_lines`, `large-missed_billed` and `large-tutor_margin`.

#### Mistakes it makes

- **Sampling, then answering "none" (4 tool-calling runs):** in `duplicate_lines` and `missed_billed` it opened about 12–17 invoices out of hundreds and answered `[]`. In both `wrong_invoices` runs it found only 2 of 12 errors (large) and 2 of 4 (small).
- **Leaving out a handbook rule (5 runs):**
  - In both `record_payment` runs it passed `allocations=[]` instead of applying the payment to unpaid invoices, oldest due date first.
  - In tool-calling `large-tutor_margin` it paid the flat tutor rate on hourly lessons.
  - In code-mode `small-tutor_margin` it decided checking `is_taxable` was "not necessary".
  - In code-mode `small-wrong_invoices` it never checked for duplicate lines.
- **Bad reactions to format errors:** it often replied in plain text and got JSON validation errors. In tool-calling `record_payment` it then called `record_payment` a second time, recording the payment twice. In tool-calling `small-tutor_margin` it treated the format error as a sign that its answer of 77610 was right and submitted it, although its own working never reproduced that figure.

#### Tool calling compared with code mode

Code mode passed 6 runs to tool-calling's 4. The gain comes from audits that need everything checked: code mode passed `duplicate_lines`, `missed_billed` and `large-tutor_margin`, where tool calling sampled invoices or added up 67 lessons by hand. Tool calling won only `small-wrong_invoices`, where it spotted the duplicate line. Code mode has its own failure: in `large-wrong_invoices` it repeatedly tried to fetch all 394 invoices in one snippet, hit the 100-nested-call limit, then assumed variables carried over between `run_code` calls and ran out of retries. Code mode was usually cheaper too: $0.0059 against $0.0285 on `duplicate_lines`, and 5 requests against 14 on `owed_on_invoices`.

## Runs

### small-invoice_total-1

**Tool calling: passed.** Looked up the invoice and returned its total, 89700, in 3 requests. Passed. ($0.0004, 3 requests, 18 s)
- Right: Direct and cheap

**Code mode: passed.** Returned 89700 in 3 requests. Passed. ($0.0003, 3 requests, 8 s)
- Right: Direct

### small-owed_on_invoices-1

**Tool calling: passed.** Added up the unpaid totals less allocations and got 85204. Passed, but took 14 requests where code mode needed 5. ($0.0016, 14 requests, 77 s)
- Right: Correct handling of allocations on part-paid invoices
- Mistake: Fairly many round trips for a simple sum

**Code mode: passed.** Computed 85204 in 5 requests. Passed. ($0.0008, 5 requests, 37 s)
- Right: Efficient: 5 requests where tool-calling mode used 14

### large-tutor_margin-3

**Tool calling: failed.** Worked out the margin on 67 billable lessons in its reasoning, by hand, and answered 134966 against the expected 120741. ($0.018, 9 requests, 7.9 min)
- Right: Left out the 8 `cancelled` lessons and handled split and gross net-of-tax amounts per line
- Mistake: Paid the tutor the flat `tutor_rate` on hourly lessons instead of rate × hours (for example LS-044814: 1.5 h, tutor paid 3200 instead of 4800), which inflated the margin
- Mistake: Summed 67 lessons by hand instead of with a reliable calculation

**Code mode: passed.** Worked out the margin in Python and got 120741. Passed. ($0.0035, 14 requests, 89 s)
- Right: Arithmetic in code avoided the tutor-pay error seen in tool-calling mode

### small-tutor_margin-3

**Tool calling: failed.** Worked through the lessons by hand and went back and forth over what net of tax means, arriving at figures like 54431 and 86640. It then submitted 77610, its earlier plain-text answer, against the expected 65045. ($0.0096, 8 requests, 5.3 min)
- Right: Read the tutor-pay rule correctly (rate × hours)
- Mistake: Treated the JSON-format validation error as a sign that 77610 'MIGHT BE CORRECT' and submitted it, even though it wrote 'I am struggling to reach 77610'
- Mistake: Considered dividing net-priced lessons by 1.2, which misreads the gross/net rule

**Code mode: failed.** Copied the lesson data into Python by hand and computed 61377 against the expected 65045, treating every gross lesson as taxed. ($0.019, 13 requests, 4.1 min)
- Right: Correct tutor pay (rate × hours, half up) and gross net-of-tax for taxable clients
- Mistake: Noted it should check each client's `is_taxable`, then decided it was 'Not necessary'. Gross lessons for non-taxable clients should count the full cost as net
- Mistake: Typed lesson data into the code by hand instead of using what the tools returned

### large-duplicate_lines-1

**Tool calling: failed.** Listed the October invoices and opened about 17 of the several hundred one by one with `get_invoice`. It found no repeated (lesson, student) pair and answered `{"ids": []}`. All three expected invoices were missed. ($0.029, 21 requests, 2.6 min)
- Right: Understood the check correctly: the same `lesson_id` and `student_id` appearing twice on one invoice
- Mistake: Its own reasoning admits it checked only a sample (INV-05761…05764, 05884…05890, 06145…06147), then said it was 'confident there are no invoices'
- Mistake: Relied on an assumption that 'the system is designed' to prevent duplicates instead of checking every non-void invoice

**Code mode: passed.** Fetched the invoices in code and found repeated (lesson, student) pairs: `INV-06060`, `INV-06073`, `INV-06097`. Passed. ($0.0059, 24 requests, 2.1 min)
- Right: Checked all invoices in code instead of sampling them

### large-missed_billed-1

**Tool calling: failed.** Over 41 requests it checked attendance for lines on about 12 invoices, found nothing and answered `[]`. All three expected invoices were missed. ($0.065, 41 requests, 4.6 min)
- Right: Used `list_attendance` with batches of `lesson_ids` to compare line students against `missed` status
- Mistake: Stopped after 'extensive sampling' of about 12 invoices and called `final_result` with `{"ids": []}` without covering the full October list
- Mistake: Took the attendance `invoiced` flag as evidence that the system was working correctly

**Code mode: passed.** Joined invoice lines to attendance in code over 39 requests and returned the three correct invoices. Passed. ($0.027, 39 requests, 3.3 min)
- Right: Checked everything, working around the nested-call limit
- Mistake: Took 39 requests, so it was costly

### large-wrong_invoices-1

**Tool calling: failed.** Found only the two invoices that charge tax to non-taxable clients (`INV-05851` 1050, `INV-06016` 1150). It missed 10 others: duplicate lines, missed students who were billed, and wrong costs. ($0.028, 17 requests, 3.5 min)
- Right: Both rows it reported were correct, after checking client `is_taxable`
- Mistake: Recomputed only a sample of the October invoices
- Mistake: Never checked for duplicate lines or students billed while marked missed

**Code mode: error.** Tried to `get_invoice` all 394 October invoices in one snippet and kept hitting the 100-nested-tool-call limit. It then assumed variables carried over between runs (`NameError: non_void`) and failed after using up the 8 `run_code` retries. ($0.035, 34 requests, 9.1 min)
- Right: Took the right approach of checking all invoices
- Mistake: Did not split the work into calls of fewer than 100 tool calls after the first limit error
- Mistake: Assumed state persisted between `run_code` calls ('Continuing from index 36')

### small-wrong_invoices-1

**Tool calling: failed.** Found `INV-00158` (duplicate line, 4050) and `INV-00162` (tax charged to a non-taxable client, 863). It missed `INV-00172` (600) and `INV-00176` (6000, a missed student who was billed). ($0.015, 17 requests, 3.4 min)
- Right: Spotted the duplicate `LS-001226` line
- Right: Caught its own mistake of assuming net pricing on INV-00177 by checking `net_gross`
- Mistake: Did not check every invoice line against attendance and the lesson's rate before answering

**Code mode: failed.** Recomputed each line and found `INV-00162`, `INV-00172` and `INV-00176`. It missed `INV-00158`, whose duplicate `LS-001226` line is correctly priced on its own. ($0.025, 19 requests, 5.7 min)
- Right: Caught the wrong cost and the missed student who was billed, which tool-calling mode missed
- Mistake: Checked lines one at a time but never checked for duplicate (lesson, student) lines on an invoice

### large-correction-2

**Tool calling: passed.** Changed the attendance on `LS-045235` to `missed`, voided `INV-06372` and re-invoiced the three remaining lessons as one new invoice for 17100. The credit from the released allocation paid it. Passed in 9 requests. ($0.0006, 9 requests, 32 s)
- Right: Followed the void and re-invoice procedure exactly: credit note for 22800, allocation released 2026-11-13, new invoice paid from credit
- Right: Every change matched the expected diff

**Code mode: passed.** Made the same correct set of changes as in tool-calling mode (attendance change, void, credit note, new invoice paid from credit) in 8 requests. Passed. ($0.0008, 8 requests, 32 s)
- Right: Correct diff that matched the tool-calling run exactly

### large-record_payment-1

**Tool calling: failed.** Recorded the 50126 payment with `allocations: []`, which left everything as unallocated credit. After a JSON-format validation error it called `record_payment` again, so the payment was entered twice. Failed. ($0.0006, 6 requests, 39 s)
- Right: Found `CL-0294` and converted £501.26 to 50126
- Mistake: Did not apply the payment to unpaid invoices oldest due date first, as the handbook requires. It should have listed unpaid invoices and allocated 12500 to `INV-03247` and 37626 to `INV-02840`
- Mistake: After the second validation error it re-ran `record_payment` and created duplicate entry `LE-013561`, although its own reasoning said the first call had worked

**Code mode: failed.** Recorded 50126 with `allocations=[]`, so the whole payment became unallocated credit. Failed, but did not record the payment twice. ($0.0007, 8 requests, 32 s)
- Right: Recorded the payment once only
- Right: Fixed the `client_id`→`id` KeyError quickly
- Mistake: Its reasoning quoted 'applied to the client's unpaid invoices, oldest due date first' and planned to fetch unpaid invoices, then passed `allocations=[]` anyway
- Mistake: Spent 3 extra requests on ledger checks that returned nothing (it read the wrong result key) after a format error
