---
title: "Grok 4.7 on Pydantic AI Accounting"
description: "Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 90%, code mode 80%; rank 2 of 32."
canonical: https://models.pydantic.dev/models/grok-4.7/accounting_platform/
---

# Grok 4.7 on Pydantic AI Accounting

> Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 90%, code mode 80%; rank 2 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/grok-4.7/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/grok-4.7.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 90%   | 9 of 10      | $9.90 | 112      | 701        | 23.4 min |
| Code mode    | 80%   | 8 of 10      | $1.14 | 101      | 102        | 8.5 min  |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gateway/openrouter:x-ai/grok-4.7` passed 17/20 runs: 9/10 in tools mode and 8/10 in code mode. All three failures were incomplete general invoice audits; none was a provider failure. This sample supports routine accounting work more strongly than comprehensive anomaly detection.

#### Where it does well

Both modes passed all four mutation runs, correctly dating payments and corrections, allocating payments oldest-due first, releasing voided-invoice allocations, and applying credit to replacements.

All four margin runs passed. Code mode explicitly handled per-student half-up rounding, gross-tax extraction, chargeable cancellations, and tutor pay when no student was charged. Both modes also passed invoice totals, outstanding debt, duplicate-only detection, and missed-attendance detection: eight further runs.

#### Mistakes it makes

General audits passed only 1/4 runs. The large tools audit inspected just 21 invoice details and returned 6/12 discrepancies. Both code audits omitted duplicate charges, returning 9/12 and 3/4 discrepancies. The small code audit reveals why: it recalculated every existing line, allowing duplicates into its expected total. Repeating that calculation did not test invoice-line uniqueness.

Unnecessary settings lookups, repeated retrievals, and lengthy verification added overhead. One small code audit encountered a diagnostic sandbox `TypeError` but continued. Three retrieved code conversations end before their final steps; their outcomes are established by supplied results, and unseen implementations cannot be assessed directly.

#### Tool calling compared with code mode

Tools mode used 112 requests and cost $9.9043; code mode used 101 and cost $1.1390, approximately 88.5% less. These are model requests, not underlying tool-call counts.

Code mode’s strongest advantage was large-scale retrieval and joins: duplicate detection cost $0.0647 versus $2.5481, and missed-attendance detection $0.0759 versus $2.9561. However, code did not improve audit completeness reliably. Tools mode passed the small general audit that code failed. For simple lookups, mutations, and margins, code often used more requests and cost more. Engineers should pair either mode with explicit completeness and uniqueness checks for broad audits.

## Runs

### small-invoice_total-1

**Tool calling: passed.** Retrieved `INV-00084` and correctly returned its tax-inclusive total of `89700` pence. ($0.013, 2 requests, 4 s)
- Right: One `get_invoice` call supplied `net=74752`, `tax=14948`, and `total=89700`; it then called `final_result` directly.

**Code mode: passed.** Correctly returned `89700` pence after retrieving `INV-00084` and summing its line totals. ($0.022, 3 requests, 4 s)
- Right: Used `sum(line["total"] for line in invoice["lines"])`, which agreed with the stored invoice total.
- Mistake: The separate summation execution increased requests from two to three for a value already returned by `get_invoice`.

### small-owed_on_invoices-1

**Tool calling: passed.** Correctly calculated Emeka Brown’s unpaid-invoice debt as `85204` pence. ($0.018, 4 requests, 6 s)
- Right: Combined `list_invoices(status="unpaid")` with `list_allocations` for `CL-0007`.
- Right: Applied only the relevant `3563` allocation: `39452 - 3563 + 49315 = 85204`.
- Mistake: Fetched `get_settings` alongside the invoices although settings were irrelevant to outstanding recorded debt.

**Code mode: passed.** Correctly returned `85204` pence owed on Emeka Brown’s unpaid invoices. ($0.021, 4 requests, 17 s)
- Right: Retrieved unpaid invoices and allocations, then evaluated `(39452 - 3563) + 49315`.
- Mistake: Fetched unnecessary `get_client` details and hard-coded the retrieved amounts into the arithmetic rather than aggregating the records.

### large-tutor_margin-3

**Tool calling: passed.** Correctly returned `120741` pence for Chen Mensah’s October margin in six requests. ($0.15, 6 requests, 1.8 min)
- Right: Used `search_tutors`, `get_settings`, and October `list_lessons` for `TU-002`.
- Right: Retrieved attendance for 67 billable lessons and taxability for 18 clients, supplying the records needed for attendance, split-charge, and gross-tax adjustments.

**Code mode: passed.** Correctly calculated `360316 - 239575 = 120741` pence across 67 billable lessons. ($0.19, 10 requests, 1.6 min)
- Right: Excluded eight cancelled lessons while retaining four `cancelled_chargeable` lessons.
- Right: Rounded split student charges individually: `5250 / 4` became `1313` each, totaling `5252`.
- Right: Paid the tutor for four billable lessons with no charged students and removed gross tax per line.
- Mistake: After computing the correct total, fetched four clients’ invoice histories and four invoice details for spot checks, adding work unrelated to the lesson-date definition of margin.

### small-tutor_margin-3

**Tool calling: passed.** Correctly returned `65045` pence for Kai Iyer’s October margin in five requests. ($0.078, 5 requests, 54 s)
- Right: Retrieved October lessons for `TU-001`, attendance for 39 lessons, and seven clients’ taxability.
- Right: Worked from lesson and attendance records rather than treating invoice totals as margin.

**Code mode: passed.** Correctly calculated `187435 - 122390 = 65045` pence for 37 billable lessons and 33 charged student lines. ($0.17, 11 requests, 74 s)
- Right: Used `Decimal` with `ROUND_HALF_UP`, excluded cancelled lessons, and handled taxable gross prices separately.
- Right: Confirmed the total with an independent integer-arithmetic calculation.
- Mistake: Used 11 requests versus five in tools mode, including several diagnostic and repeated-total executions.
- Mistake: The final independent recalculation assumed every lesson was hourly; that check was valid for this dataset, whose charge types had already been inspected, but was narrower than the general calculation.

### large-duplicate_lines-1

**Tool calling: passed.** Correctly identified all three duplicate-charge invoices: `INV-06060`, `INV-06073`, and `INV-06097`. The exhaustive inspection required 24 requests and cost $2.5481. ($2.55, 24 requests, 3.3 min)
- Right: Fetched four `list_invoices` pages and 384 non-void invoice details with `get_invoice`.
- Right: Found repeated student–lesson pairs worth `3563`, `4500`, and `9900` pence respectively.
- Mistake: During invoice inspection, two `get_lessons` calls and one `list_attendance` call added work beyond checking duplicate `(lesson_id, student_id)` pairs.

**Code mode: passed.** Correctly returned the three duplicate-charge invoices for $0.0647. The retrieved conversation stops after accumulating 160 invoice details, so the final duplicate-detection implementation is not visible. ($0.065, 11 requests, 13 s)
- Right: Established that October contained 394 invoices, including ten void invoices, and selected 384 non-void IDs.
- Right: Used `asyncio.gather` to fetch invoice details in batches of 80.
- Mistake: Initially fetched irrelevant settings and later fetched invoice page 1 again instead of reusing `page1`.
- Mistake: Spent separate executions inspecting dictionary keys and copying `batch1` into `details`.

### large-missed_billed-1

**Tool calling: passed.** Correctly returned `INV-05821`, `INV-05846`, and `INV-06080`. It reached the answer through a broad attendance scan costing $2.9561. ($2.96, 20 requests, 4.3 min)
- Right: Confirmed billed students marked `missed` on `LS-044224`, `LS-041761`, and `LS-043071`.
- Right: Used invoice details and client-specific October invoice lists to verify the matches.
- Mistake: The retrieval sequence used 35 `list_attendance` calls, including overlapping initial checks and long consecutive lesson-ID ranges.
- Mistake: Queried earlier lessons and October lessons, then fetched an August page immediately before answering; deriving the required lesson IDs from invoice lines would give a clearer completeness check.

**Code mode: passed.** Correctly found all three invoices using a complete invoice-to-attendance join. It cost $0.0759 across 12 requests. ($0.076, 12 requests, 41 s)
- Right: Fetched 384 paid or unpaid invoices containing 3108 lines and 2655 unique lessons.
- Right: Retrieved 3148 attendance records in 27 batches and joined on `(lesson_id, student_id)` with zero missing matches.
- Right: Selected exactly `status == "missed"`, excluding 345 `missed_chargeable` lines.
- Mistake: After the complete join found three matches, it fetched those three lessons’ attendance again without resolving any missing data.

### large-wrong_invoices-1

**Tool calling: failed.** Returned six correct overcharges but missed six of the 12 required invoices. It concluded that the errors were limited to three tax errors and three missed-attendance charges. ($3.58, 30 requests, 8.1 min)
- Right: Correctly reported `INV-05821: 4875`, `INV-05846: 11700`, `INV-05851: 1050`, `INV-06016: 1150`, `INV-06080: 4050`, and `INV-06105: 1875`.
- Mistake: After fetching all four invoice-list pages, it inspected only 21 invoice details, including void invoices, rather than systematically auditing all 384 non-void invoices.
- Mistake: The final answer omitted `INV-05791: 600`, `INV-05877: 750`, `INV-06017: 500`, and duplicate charges `INV-06060: 3563`, `INV-06073: 4500`, `INV-06097: 9900`.
- Mistake: It should have reconstructed each invoice from unique charged `(lesson_id, student_id)` pairs, applying lesson rates and tax, then compared that total with the recorded total.

**Code mode: failed.** Returned nine correct overcharges but omitted all three duplicate-charge invoices. The retrieved conversation ends after data collection, so the exact faulty calculation expression is unavailable. ($0.29, 22 requests, 1.9 min)
- Right: Collected all 384 non-void invoice details, 2655 lessons, 3148 attendance records, and 384 clients.
- Right: Reported the three additional `600`, `750`, and `500`-pence discrepancies missed by tools mode.
- Mistake: The final output omitted `INV-06060: 3563`, `INV-06073: 4500`, and `INV-06097: 9900`, despite their invoice details being collected.
- Mistake: The audit needed to enforce one charge per `(lesson_id, student_id)` before calculating expected totals. The omission matches the visible small-case duplicate bug, but the large-case calculation itself is not recorded in the retrieved messages.
- Mistake: Refetched invoice page 1 and a sample invoice subsequently included in a full batch.

### small-wrong_invoices-1

**Tool calling: passed.** Correctly identified all four overcharged invoices, including the duplicate that code mode missed. ($0.52, 12 requests, 4.2 min)
- Right: Fetched all 37 invoice details, 37 clients, four lesson pages, and four attendance batches.
- Right: Returned `INV-00158: 4050`, `INV-00162: 863`, `INV-00172: 600`, and `INV-00176: 6000`.
- Right: Recognized the repeated `LS-001226`/`ST-0016` line on `INV-00158` as an extra `4050`-pence charge.

**Code mode: failed.** Correctly found tax, rate, and missed-attendance overcharges, but omitted the `4050`-pence duplicate on `INV-00158`. ($0.17, 14 requests, 1.6 min)
- Right: Fetched all 37 invoices, 280 unique lessons, 331 attendance records, and client taxability.
- Right: Correctly calculated `INV-00162: 863`, `INV-00172: 600`, and `INV-00176: 6000` using per-line half-up rounding.
- Mistake: In the ninth `run_code` call, `for line in inv["lines"]` followed by `correct_total += correct["total"]` counted duplicate lines as legitimate expected charges. It needed a per-invoice set of `(lesson_id, student_id)` pairs.
- Mistake: The later verification repeated the same flawed aggregation, so it could not expose the missing duplicate check.
- Mistake: A diagnostic `next(i for i in invoices if i["id"] == iid)` raised `TypeError: 'list' object is not an iterator` in the sandbox. The run continued, but that invoice-detail check did not finish.

### large-correction-2

**Tool calling: passed.** Correctly marked Yara Baker missed, voided `INV-06372`, and created a paid replacement for `17100` pence dated `2026-11-13`. All expected accounting changes matched. ($0.021, 5 requests, 12 s)
- Right: Used `get_invoice` to identify `LS-045235` and `ST-0332`, then called `update_attendance`, `void_invoice`, and `create_invoice` with the remaining three lessons.
- Right: Checked `auto_pay_from_credit`; voiding released `22800`, and the replacement consumed `17100`.
- Mistake: At the initial lookup, `search_tutors(name="French")` searched a subject as a tutor name and returned nothing; it was unnecessary.

**Code mode: passed.** The supplied change set exactly matches the required correction and `17100`-pence paid replacement. The retrieved conversation ends after `void_invoice`, so the reissue is confirmed by the result rather than a visible final tool call. ($0.063, 8 requests, 24 s)
- Right: Resolved `CL-0234` and `ST-0332`, located the October 7 lesson with `list_lessons`, and checked attendance and invoice details.
- Right: Sequentially awaited `update_attendance(status="missed")` and `void_invoice(date="2026-11-13")`.
- Mistake: Used eight requests versus five in tools mode, with separate lookup steps despite the supplied invoice containing the lesson and student identifiers.

### large-record_payment-1

**Tool calling: passed.** Correctly recorded Jane Kelly’s `50126`-pence payment on `2026-11-13`. It cleared `INV-02840` and part-paid `INV-03247`. ($0.024, 4 requests, 25 s)
- Right: Read unpaid invoices and existing allocations before calling `record_payment`.
- Right: Calculated `58778 - 21152 = 37626` for the oldest invoice and allocated the remaining `12500` to the next.
- Mistake: The opening `get_settings` call was unnecessary for recording this explicitly allocated payment.

**Code mode: passed.** Correctly recorded `50126` pence and allocated `37626` to `INV-02840` and `12500` to `INV-03247`, leaving nothing unallocated. ($0.068, 6 requests, 29 s)
- Right: Checked existing allocations and explicitly calculated the remaining balances before mutation.
- Right: Called `record_payment` once with the correct date, client, amount, and allocations.
- Mistake: Fetched settings, client details, and all 18 client invoices when the ten unpaid invoices and allocations were sufficient.
- Mistake: Manually transcribed invoice amounts into calculation code instead of deriving them from the fetched records.
