---
title: "Claude Fable 5.2 on Pydantic AI - SQL data analysis"
description: "Planning journeys by querying a real Dresden public transport timetable with SQL, with an SVG map of each answer. Tool calling 100%, code mode 100%; rank 1 of 44."
canonical: https://pydantic.dev/models/list/claude-fable-5.2/sql_data_analysis/
---

# Claude Fable 5.2 on Pydantic AI - SQL data analysis

> Planning journeys by querying a real Dresden public transport timetable with SQL, with an SVG map of each answer. Tool calling 100%, code mode 100%; rank 1 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/claude-fable-5.2/sql_data_analysis/. 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/sql_data_analysis.md. The model on every Pydantic AI benchmark: https://pydantic.dev/models/list/claude-fable-5.2/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $7.88 | 132      | 207        | 21.4 min |
| Code mode    | 100%  | 10 of 10     | $5.82 | 132      | 124        | 16.8 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

Claude Fable 5.2 passed all 20 cases: 10 in tools mode and 10 in code mode. Both modes gave the same answer in every case, so the results are consistent. Both used 132 requests in total. Tools mode cost $7.88 and code mode cost $5.82.

#### Where it does well

- **Reading the rules.** Every run read `DATA.md` first. It then applied the trickier rules correctly:
  - interpolating untimed calls by distance;
  - naming repeated runs `+k`;
  - offsets for the previous service day (`after_midnight` arrives at 5280 and 6420);
  - start walks within 400 m (`one_vehicle` boards at Strehlener Platz after a 399 m walk, departure 29541);
  - the 120 s + walk change margin.
- **Building real routing algorithms.**
  - In tools mode it wrote a round-based earliest-arrival search and a bitmask DP over visit order entirely in DuckDB (`ready`/`best`/`dp` tables) for `tour`.
  - In code mode it wrote a Connection Scan (`csa`) with a grid-bucketed walking graph.
- **Defensive checks.** It counted rows and checked convergence. In code-mode `one_vehicle` it spotted `truncated: true` on batched fetches, refetched in smaller batches and confirmed 866 rows.

#### Mistakes it makes

None of these changed a result.

- **Small SQL slips.** It forgot to quote the reserved word `at` (a parser error in tools-mode `one_vehicle`).
- **Hand-transcribed SVG coordinates in tools mode.** In `walking_change`, platform `P6e794064` is drawn at x=346.57 instead of 347.43 (its east is 12160). The grader tolerated it.
- **High cost on the multi-stop tasks in tools mode.** `tour` took 22 requests and $1.94, `timed_tour` 20 and $1.36, `departure_profile` 19 and $1.21. The SQL rounds were copied out as long statements.
- **Bypassing `run_sql`.** Code-mode `tour` read `calls.txt` directly in Python instead of loading it with `run_sql` as the handbook says.

#### Tool calling compared with code mode

Accuracy was the same. Cost was not:

- **Hard cases:** code mode was clearly cheaper. `tour` cost $0.94 against $1.94, `departure_profile` $0.66 against $1.21, `timed_tour` $0.87 against $1.36.
- **Simple single-journey cases:** tools mode was as cheap or cheaper and often took fewer requests. `arrive_by` took 9 requests against 13, `one_change` 9 against 13.
- **SVGs:** code mode computed coordinates in Python, which avoided the transcription error seen in tools mode.

For search-heavy questions code mode is the better choice. For simple lookups the two modes cost about the same.

## Runs

### one_vehicle

**Tool calling: passed.** Loaded the tables with typed `read_csv`, built a `c1` table that interpolates untimed calls with window functions, and found `R27f8d4b1+2` from Strehlener Platz after a 399 m walk (departure 29541, arrival 30480). Passed. ($0.37, 10 requests, 56 s)
- Right: Spotted that boarding at another station 399 m away (under the 400 m limit) gives the earliest arrival
- Right: Interpolated every untimed call in one SQL pass and checked the row counts
- Mistake: Its first `run_sql` failed with a parser error because `at` was not quoted; it fixed this on the next call
- Mistake: Wrote several redundant check queries, such as re-reading the repeats for `R27f8d4b1`

**Code mode: passed.** Loaded the tables with `all_varchar`, scanned candidate runs in Python, including the previous service day with a −86400 offset, and found `R27f8d4b1+2` (29541→30480). Passed in 9 requests. ($0.34, 9 requests, 50 s)
- Right: Noticed that `run_sql` results were truncated when fetching calls in batches of 10 runs, then refetched in batches of 3 and checked the count (866)
- Right: Considered the previous service day's runs
- Mistake: The first batched call fetch was truncated and had to be repeated

### saturday_direct

**Tool calling: passed.** Took tram 9 `Rb28d92d7` from 33484 to 34560 and drew the run's stops as a dashed polyline plus a straight `data-run` line. Passed. ($0.50, 10 requests, 82 s)
- Right: Applied the Saturday service day correctly

**Code mode: passed.** Same tram 9 answer; drew the leg as a `path` with `data-run` through all intermediate stops. Passed. ($0.44, 12 requests, 77 s)
- Right: The path runs from the boarding platform to the alighting platform as required

### one_change

**Tool calling: passed.** Tram 10 `Rafeef850` then tram 12 `R620ec7d9`, with a 72 m walk at Straßburger Platz; 27669→28440. Passed. ($0.42, 9 requests, 65 s)
- Right: The 120 s + walk change margin was respected (27960 + 120 + 72 ≤ 28200)

**Code mode: passed.** Same two-leg answer (27669→28440). Passed. ($0.46, 13 requests, 76 s)
- Right: SVG labels include platform ids

### walking_change

**Tool calling: passed.** Took bus 62 `R76d2117b+4`, walked 78 m at Pirnaischer Platz, then tram 2 `R3a0dccd4+54`; 61560→63480. Passed. ($0.43, 9 requests, 72 s)
- Right: Correct journey, matching code mode
- Mistake: The hand-written SVG puts `P6e794064` at x=346.57, but the queried east is 12160, which gives x=347.43. This was a transcription error that the grader tolerated

**Code mode: passed.** Same bus 62 + tram 2 journey (61560→63480), with SVG coordinates computed exactly (`P6e794064` at 347.43). Passed. ($0.50, 13 requests, 84 s)
- Right: Correct SVG placement where tools mode was slightly off

### after_midnight

**Tool calling: passed.** Found the 01:28→01:47 journey (`R93fefd15` then `R900bf42f+2` with a short walk at Südhöhe), departure 5280, arrival 6420, and wrote a correct SVG. Passed. ($0.61, 11 requests, 1.6 min)
- Right: Times after midnight were given in seconds from the question date's midnight (5280, 6420), as the rules require
- Right: Two-leg answer matches code mode exactly

**Code mode: passed.** Same answer as tools mode (5280→6420, `R93fefd15` then `R900bf42f+2`), with an SVG built in Python. Passed and cost less ($0.53). ($0.53, 12 requests, 86 s)
- Right: SVG coordinates computed in code, not typed by hand

### arrive_by

**Tool calling: passed.** Returned `R1aabe4da+29` then `Rfd6f9e2d+67` via Straßburger Platz, departing 63360 and arriving 64440. Passed in 9 requests. ($0.41, 9 requests, 69 s)
- Right: Same answer as code mode
- Right: Cheap run at $0.41

**Code mode: passed.** Same journey as tools mode (63360→64440). Passed in 13 requests, slightly more than the 9 in tools mode. ($0.47, 13 requests, 77 s)
- Right: Correct latest-departure answer
- Mistake: Used 4 more requests than tools mode

### departure_profile

**Tool calling: passed.** Produced the full list of two-leg journeys (`R77afbc0f+k`/`R45005fd8+k` feeders etc.) and passed, but used 19 requests and $1.21. ($1.21, 19 requests, 3.2 min)
- Right: Profile matches code mode journey for journey
- Mistake: Used 19 requests against 13 in code mode, costing about twice as much

**Code mode: passed.** Produced the same profile as tools mode in 13 requests for $0.66, about half the tools-mode cost. ($0.66, 13 requests, 1.9 min)
- Right: Efficient: did its iteration in Python, not in many SQL calls

### meeting_point

**Tool calling: passed.** Chose Albertplatz `Sbb9212fa` at 33701, with one direct leg for each traveller (`Rc0124950`, `Rfa439a34`). Passed. ($0.62, 13 requests, 1.5 min)
- Right: Correct meeting time is the later of the two arrivals (33701)

**Code mode: passed.** Same meeting answer (Albertplatz, 33701). Passed. ($0.60, 14 requests, 1.8 min)
- Right: Identical to tools mode

### timed_tour

**Tool calling: passed.** Planned a 6-leg round trip from Pirnaischer Platz, back at 44160, with four visits. Passed, but cost $1.36 over 20 requests. ($1.36, 20 requests, 4.0 min)
- Right: Same itinerary as code mode
- Mistake: Cost about 1.6× the code-mode run of the same case

**Code mode: passed.** Same 6-leg round trip back at 44160, in 15 requests for $0.87. ($0.87, 15 requests, 2.6 min)
- Right: Cheaper than tools mode by $0.49

### tour

**Tool calling: passed.** Implemented a round-based earliest-arrival search (RAPTOR-like) plus a bitmask DP over visit order entirely in DuckDB SQL (`ready`/`best`/`dp` tables). Got an 11-leg tour back at 48660. Passed, but this was the most expensive case at $1.94 over 22 requests. ($1.94, 22 requests, 5.4 min)
- Right: The SQL formulation of multi-source rounds and a subset DP was correct
- Right: Checked convergence with a `hist` table of per-round sums
- Mistake: Each round was copied out as a long statement, so requests and tokens added up; it was the costliest case

**Code mode: passed.** Read `calls.txt` directly in Python, interpolated untimed calls, built a sorted connection list with a 400 m walking grid, and ran a Connection Scan (`csa`) per visit state. Got the same 11-leg tour back at 48660. Passed for $0.94, half the tools-mode cost. ($0.94, 18 requests, 2.9 min)
- Right: Classic CSA with a grid-bucketed walking graph
- Right: Sanity-checked that timed calls were monotone (`bad` count)
- Mistake: Bypassed `run_sql` for the calls file, against the handbook's 'Load what you need with run_sql'. This did no harm
