---
title: "Claude Fable 5.2 on Pydantic AI Transit Planner"
description: "Journey planning over a real Dresden public transport timetable, with an SVG map of each answer. Tool calling 100%, code mode 100%; rank 1 of 32."
canonical: https://models.pydantic.dev/models/claude-fable-5.2/transit_planner/
---

# Claude Fable 5.2 on Pydantic AI Transit Planner

> Journey planning over a real Dresden public transport timetable, with an SVG map of each answer. Tool calling 100%, code mode 100%; rank 1 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/claude-fable-5.2/transit_planner/. 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/transit_planner.md. The model on every Pydantic AI benchmark: https://models.pydantic.dev/models/claude-fable-5.2.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $7.18 | 116      | 183        | 20.9 min |
| Code mode    | 100%  | 10 of 10     | $5.43 | 115      | 107        | 16.7 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

20 of 20 cases passed: 10 in tool calling, 10 in code mode. Both modes returned the same journeys except `departure_profile`, where four journeys change at a different stop with identical times. Tool calling cost $7.19 over 116 requests; code mode cost $5.43 over 115.

#### Where it does well

- **Reads the rules closely.** Untimed-call interpolation, the 120 s + walk margin, `Y`-only access and repeat naming (`R…+k`) were implemented correctly in all 20 runs.
- **Start walks.** `one_vehicle` needed a 399 m walk to a platform outside the station; both modes found it and reported `departure` as 29940 − 399.
- **Proves optimality.** It usually checks extra rounds or a second direction: `after_midnight` (code mode) ran forward, backward and brute force.
- **Catches its own bugs.** In `departure_profile` (tools) it noticed every row had `arr = T` and rebuilt the pipeline.

#### Mistakes it makes

- **`at` is reserved in DuckDB.** Unquoted `at` caused a `ParserException` in 6 of 10 tools runs and once in code mode. Tools had 10 SQL errors in 7 runs overall (also a missing `as` after `::int`, a `union all` column mismatch, a macro created before its table).
- **Case-insensitive column clash.** `T` and `t` in `departure_profile` (tools) forced dropping 20 tables and redoing six rounds; that run cost $1.10.
- **Previous service day skipped in 6 tools runs** (`arrive_by`, `saturday_direct`, `walking_change`, `departure_profile`, `tour`, `timed_tour`). Harmless for daytime questions, but it is a shortcut.
- **Hand-driven search in `timed_tour` (tools).** It probed hand-picked orders instead of all 24, at $1.45, the dearest run.
- **Unjustified cut-offs**: `dep<=t0+6000` in `tour`, `+5400` in `departure_profile`.
- **Waste**: a no-op query in `one_change`, duplicated calls in `one_vehicle`, full call dumps of 47–80 rows for verification.

#### Tool calling compared with code mode

- **Different methods.** Tools runs wrote SQL with each search round copy-pasted (up to seven identical statements per call). Code mode read the files with `Path` and wrote a connection scan or round-based search in Python in 9 of 10 runs, ignoring `run_sql`; only `saturday_direct` drove SQL from Python.
- **Code mode is cheaper on hard cases**: `timed_tour` $0.67 vs $1.45, `departure_profile` $0.67 vs $1.10, `tour` $0.84 vs $1.20. On simple cases it is level or slightly dearer (`arrive_by` $0.55 vs $0.48).
- **Code mode is more systematic**: all 120 orders in `tour`, a windowed DFS in `timed_tour`, asserts on every transfer, both service days in 8 of the 9 runs where the setup was read (not `timed_tour`; `tour`'s was not inspected).
- **Code mode errors**: 1 against 10.
- **SVG**: tools typed coordinates by hand into `write_file`; code mode computed them. None were wrong.
- In both modes `timed_tour` swapped a faster leg with a 117 m walk for a station-platform-only route; the answer was unaffected.

## Runs

### one_vehicle

**Tool calling: passed.** Restricted to the 72 runs that call near both stations, interpolated only those, and found bus 66 `R27f8d4b1+2` from Strehlener Platz `P0091960a`, reached by a 399 m walk, arriving 30480. Passed in 8 requests, the cheapest tools run ($0.38). ($0.38, 8 requests, 73 s)
- Right: Allowed the start walk to a platform outside the station (398.1 m to `P0091960a`, just under the 400 m limit) and reported `departure` as 29541 = 29940 - 399.
- Right: Filtered to candidate runs (`cr`) before interpolating, keeping the work small.
- Right: Checked both service days (336 and 335 shifted).
- Mistake: Second `run_sql` failed with `ParserException` at `case when at is not null` (unquoted `at` inside a window expression); rewritten with `c."at" t0`.
- Mistake: Sent a three-statement call expecting three results, got only the last, and had already issued the first two again as separate calls in the same turn (duplicate work).

**Code mode: passed.** Filtered to the 72 runs touching both walk catchments, enumerated board/alight pairs in Python and sorted 162 options; same answer as tools (bus 66 `R27f8d4b1+2`, departure 29541, arrival 30480). Passed in 8 requests, the cheapest run of all ($0.32). ($0.32, 8 requests, 58 s)
- Right: `startw`/`endw` maps gave the 399 m start walk to `P0091960a` and `departure` = 29940 - 399.
- Right: `runs_on()` applies `service_changes`; both day 336 and day 335 checked.
- Right: No errors.
- Mistake: Printed `datetime` weekday checks that were not needed (the question states the weekday).

### saturday_direct

**Tool calling: passed.** Loaded and sanity-checked the data, ran a 4-round SQL search and found the direct tram 9 run `Rb28d92d7` boarding at an untimed call (33484) and arriving 34560. Passed in 12 requests after two failed load attempts. ($0.51, 12 requests, 1.6 min)
- Right: Board time 33484 is an interpolated untimed call at `P7fa04a55`; it printed `s`, `arr` for calls 120-210 to check the interpolation by hand.
- Right: Applied `service_changes` (`+` and `-`) when building `act`.
- Right: Checked rounds 1-4 and showed changing did not beat the direct run (34560 vs 34971).
- Mistake: Load call failed twice: first `ParserException` on `where at is null`, then again on `days::int days` (alias without `as` after a `::` cast). Three attempts to create the tables.
- Mistake: Only day 339 services were loaded; previous-day runs were not considered (harmless at 09:15).
- Mistake: Several integrity probes (`dup`, `nos`, `np`, `nost`) were not needed for this question.

**Code mode: passed.** Unlike the other code-mode runs it drove DuckDB from Python through an `await q(...)` helper, looped six search rounds with f-strings and found `Rb28d92d7` (33484 to 34560). Passed in 10 requests. ($0.51, 10 requests, 1.6 min)
- Right: Looped the rounds in Python (`for k in range(1, 7)`) instead of copy-pasting SQL, which the tools runs could not do.
- Right: Computed interpolation twice (`c2` with `floor` on doubles, `c3` with integer `//`) and confirmed 0 differing rows.
- Right: Drew the leg as a path through the intermediate stops and applied both service days and `service_changes`.
- Mistake: One query failed with `ParserException` on `filter (where at is null)` (unquoted `at`); the error came back as a dict in the result list and the other five queries in that call still ran.
- Mistake: The double interpolation check was extra work for a single direct leg; cost matched tools ($0.51).

### one_change

**Tool calling: passed.** Listed one-vehicle options (best 29160), then joined a second vehicle with walks and the 120 s margin to find `Rafeef850` then `R620ec7d9` arriving 28440. Passed in 10 requests. ($0.44, 10 requests, 79 s)
- Right: Respected the at-most-2-vehicles limit by enumerating exactly one- and two-leg journeys rather than an unbounded search.
- Right: Used the one-vehicle best (29160) as a bound for the two-vehicle query (`a.arr+en.w<=29160`).
- Right: Applied the 72 m walk from `P66c27b1c` to `P3b6efaff` (27960 + 120 + 72 \<= 28200).
- Mistake: First `run_sql` failed with `ParserException` on `where at is null or at=''`; load reissued with `try_cast("at" as int)`.
- Mistake: Request 6 was a throwaway query, `with f as (select place, min(at_) t from l1 group by place_alias) select 1`, which returned `1` and did nothing.
- Mistake: Verification returned all 59 call rows of both runs.

**Code mode: passed.** Precomputed, per boarding point, the best direct arrival at the destination, then enumerated one- and two-leg journeys in Python (4,470 candidates) and sorted by arrival; same answer as tools (28440). Passed in 12 requests. ($0.50, 12 requests, 1.6 min)
- Right: Enforced the two-vehicle cap by construction (direct table plus one transfer).
- Right: Tie-broke on arrival, then later departure, then fewer legs, then total walk.
- Right: Both service days loaded.
- Mistake: Slightly dearer than tools ($0.50 vs $0.44) and two more requests for the same result.

### walking_change

**Tool calling: passed.** Ran a 5-round SQL earliest-arrival search and found bus 62 `R76d2117b+4` to Pirnaischer Platz, a 78 m walk, then tram 2 `R3a0dccd4+54`, arriving 63480. Passed in 8 requests with no SQL errors. ($0.45, 8 requests, 82 s)
- Right: Quoted `"at"` from the start; no failed calls.
- Right: Showed rounds 2-5 all give 63480 and round 1 has no result, so two vehicles is optimal.
- Right: Between two change points for the same pair of runs, chose the 78 m walk at `P6e794064` to `P72ccec8b` over the 341 m alternative.
- Mistake: Only day 338 services were loaded; previous-day runs and `service_changes` were not applied (harmless at 17:05).
- Mistake: Verification dumped all 60 call rows of both runs.

**Code mode: passed.** Loaded with `Path`, built 2,133 trips for a four-hour window and ran a round-based forward search in Python; same answer as tools (61560 to 63480 via a 78 m walk at Pirnaischer Platz). Passed in 11 requests. ($0.43, 11 requests, 85 s)
- Right: Both service days and `service_changes` applied in `active()`.
- Right: Grid-bucketed neighbour search (`e//400`, `n//400`) kept the 400 m walk lookup cheap.
- Right: No errors.
- Mistake: Three more requests than tools for the same answer, at about the same cost ($0.43 vs $0.45).

### after_midnight

**Tool calling: passed.** Loaded the files with `run_sql`, built interpolated call times and a 4-round SQL search over both service days (339 and 338 shifted by `-86400`), and returned `R93fefd15` then `R900bf42f+2`, arriving 6420. Passed in 9 requests. ($0.51, 9 requests, 88 s)
- Right: Handled the previous service day correctly: both legs are Friday-service runs shifted by `-86400` (`R900bf42f+2` is `V479271d1`, days 31).
- Right: Confirmed the optimum by checking rounds 1-4 (`18575`, then `6420` three times) and then enumerating every two-leg journey with `arr<=6420`, which returned one row.
- Right: Applied the 76 m walk between the two Südhöhe platforms `P96dc02de` and `P983fcb99` plus the 120 s margin (5492 to 5700).
- Mistake: First `run_sql` failed with `ParserException` at `where at is null` because `at` is a reserved word in DuckDB; the whole multi-statement load had to be reissued with `"at"` quoted.
- Mistake: The verification query returned all 47 call rows of both runs when only four were needed.
- Mistake: `service_changes` was read but not applied in the `act` CTE (harmless: the only changes are on days 325 and 326).

**Code mode: passed.** Read the files with `Path` in Python, interpolated times in memory, ran a round-based search forward and backward and enumerated two-leg journeys; same answer as tools (arrive 6420). Passed in 11 requests. ($0.44, 11 requests, 88 s)
- Right: `active()` applies `service_changes` and builds both `act339` and `act338`; trips from the previous day are shifted by `-86400`.
- Right: Cross-checked three ways: forward rounds (6420 from round 2), backward latest departure (5280 with 2 legs), and brute-force two-leg enumeration (1 solution).
- Right: SVG coordinates computed by an `xy()` function and the file read back.
- Mistake: Did not use `run_sql` at all; the handbook says to load with `run_sql`, though nothing depended on it.
- Mistake: One step per request: 11 small `run_code` calls where the search and the checks could have been two or three.

### arrive_by

**Tool calling: passed.** Ran a backward search in SQL from the 18:00 deadline (tables `A1`..`B5`), found latest departure 63360, then confirmed with a forward pass that the same departure arrives 64440. Passed in 10 requests with no SQL errors. ($0.48, 10 requests, 89 s)
- Right: Quoted `"at"` from the first call, so no parser error.
- Right: Searched backward (latest boarding per platform) which fits a leave-as-late-as-possible question, and extended to 5 vehicles to show the answer stayed at 63360.
- Right: Picked the earliest arrival among journeys leaving at 63360 (`Rfd6f9e2d+67` at 64440 over `R54c1ee76+5` at 64500).
- Mistake: Only loaded services for day 344 (`days & 8`); the previous service day and `service_changes` were not considered. Harmless for a 17:36 departure.
- Mistake: Backward rounds were written out by hand as near-identical statements (`A2`/`B2` to `A5`/`B5`) rather than looped.

**Code mode: passed.** Built trips in Python for the 16:30-18:00 window and ran a backward round-based search (latest departure 63360), then a forward search to pick the journey; same answer as tools. Passed in 12 requests. ($0.55, 12 requests, 1.8 min)
- Right: Backward search returned `[-inf, 63360, 63360, 63360, 63360]`, showing one vehicle is impossible and more vehicles do not help.
- Right: Both service days loaded (`act_today`, `act_prev`).
- Right: Printed `dup` if a run name appeared twice across service days.
- Mistake: Defined `forward()` twice: the first version (request 6) had no parent tracking and was rewritten two requests later.
- Mistake: More expensive than tools on this case ($0.55 vs $0.48) and two more requests.

### departure_profile

**Tool calling: passed.** Built a per-departure-time earliest-arrival profile in SQL for 108 candidate departures across 6 rounds, filtered to the 12 non-dominated journeys and reconstructed two-leg journeys. Passed, but in 15 requests and $1.10 after rebuilding the whole pipeline once. ($1.10, 15 requests, 2.9 min)
- Right: Added one candidate departure after 08:00 (`min(dep-w) > 28800`) so the last journeys in the window could be tested for dominance by a later departure.
- Right: Noticed the first profile was wrong (every row had `arr` equal to `T` and `dur` 0) and rebuilt it instead of answering from it.
- Right: Dominance filter `arr<nxt and s0<=28800` produced 12 journeys from 25327 to 28620.
- Mistake: Named the departure column `T` alongside an arrival column `t`; DuckDB identifiers are case-insensitive, so the first 6-round pipeline (requests 4-8) produced `arr = T` for all 108 rows. It then dropped 20 tables and re-ran everything with `s0`/`ta`/`rt`, roughly doubling the work.
- Mistake: Only services for day 342 were loaded; no previous-day runs.
- Mistake: Limited boarding to `c.dep<=r.s0+5400` (90 minutes), a horizon cut that was not justified from the data.

**Code mode: passed.** Implemented a connection scan in Python, ran it for each of 107 candidate departures in the window plus 28801, and filtered to the 12 non-dominated journeys. Passed in 11 requests at $0.67 against $1.10 for tools. ($0.67, 11 requests, 1.9 min)
- Right: Ran `csa(28801)` (arrival 31063) so the 28620 journey could be tested against a later departure.
- Right: Asserted transfer legality for every journey (`d<=400 and board_time>=alight_time+120+d`) before printing the JSON.
- Right: No rebuild was needed, unlike the tools run.
- Mistake: Split the 107 scans across two parallel `run_code` calls (`win[:60]`, `win[60:]`), apparently to stay inside a time limit; this relied on sandbox state being shared between the two calls.
- Mistake: Four of the journeys change at Straßburger Platz `P3b6efaff` where tools changed at Altmarkt `P839ef02b`; same departure and arrival times, both accepted.

### meeting_point

**Tool calling: passed.** Ran a 6-round SQL earliest-arrival search from both origins at once (tables `tau1`..`tau6` keyed by `src`), took `greatest(t1,t2)` per station and chose Albertplatz `Sbb9212fa` at 33701. Passed in 12 requests. ($0.66, 12 requests, 1.8 min)
- Right: Computed both origins in one set of tables and ranked all stations by `greatest(x.t,y.t)`, so the meeting station came from the data rather than a guess.
- Right: Included both service days (339 and 338 with `-86400`).
- Right: Reported meeting time as the later arrival (33701) with each friend alighting at a different Albertplatz platform (`P291e54d3`, `Pcb3f34ed`).
- Mistake: First `run_sql` failed with `ParserException` on `where at is null` (unquoted reserved word); load reissued renaming the column to `arr`.
- Mistake: Active services were hard-coded as literal id lists read off `services.txt` by eye rather than computed from `days`/`first`/`last`; correct here but error-prone.
- Mistake: Dumped all 80 call rows of both runs for verification.

**Code mode: passed.** Ran a Python connection scan from each origin, computed the best arrival at every station including walks, and ranked by the later arrival: Albertplatz at 33701, same as tools. Passed in 12 requests. ($0.51, 12 requests, 1.5 min)
- Right: Considered walk-only arrivals at stations as well as vehicle arrivals in `csa()`.
- Right: Both service days loaded; printed the count of previous-day trips in the window (0).
- Right: Top-10 candidate list matches the tools ranking (33701, 33780, 33803, ...).
- Mistake: Many single-purpose requests (load, interpolate, trips, footpaths, scan, reconstruct each in its own call).

### timed_tour

**Tool calling: passed.** Computed earliest arrivals from the start, then from hand-chosen (station, time) sources over three batches, and assembled Prohlis, TU, Pohlandplatz, Mickten returning at 44160. Passed, but it was the most expensive run ($1.45, 16 requests). ($1.45, 16 requests, 4.2 min)
- Right: Used the opening windows to set earliest leave times (`T` 37800, `O` 39600, `M` 43200) and saw that Mickten cannot be left before 43200, so the 43260 tram back (arriving 44160) is the bound.
- Right: Final visits satisfy the windows: TU 37200-38312, Pohlandplatz 39480-40560, Mickten 42300-43260.
- Right: Verified each leg's `access` flags and times against `ev`.
- Mistake: No systematic search over the 24 visiting orders: it probed sources chosen by hand (`P`, `O`, `T`, `M`, then `T37980`, `P40399`, `O40380`, `T41700`). The answer is optimal but the method would not generalise.
- Mistake: Each probe repeated the same `create or replace table av` statement seven times in one call, about 5,000 characters per call, three times over.
- Mistake: Two SQL errors; the one seen was `CatalogException: Table with name ev0 does not exist` because the `direct` macro was created before `ev0`. The initial load was also reissued.
- Mistake: Found a one-bus Prohlis to TU option (`Rf679205e+8`, 117 m walk, arriving 37080) and then replaced it with a two-vehicle route from the station platform arriving 37200; the reason is not recorded and the result is the same.
- Mistake: Only day 343 services were loaded.

**Code mode: passed.** Wrote a Python connection scan and a depth-first search over visiting orders with the opening windows (32 scans), giving 44160 with the next best 45960; same answer as tools at under half the cost ($0.67 vs $1.45). Passed in 13 requests. ($0.67, 13 requests, 1.9 min)
- Right: Searched all feasible orders systematically (`dfs` with `win` and `st+900>c` pruning) and printed five ranked results.
- Right: Verified each leg against `timed` (repeat index within `count`, access flags, service active).
- Right: Windows encoded correctly: Pohlandplatz 38700-42300, TU 36900-42300, Mickten 42300-47700.
- Mistake: After the search found a plan with walks (to `P9cd5b9a9`, and a 117 m walk to `P40aaf538` reaching TU at 37080), it wrote a second `csa_gen` that only boards and alights at station platforms and answered from that (TU at 37200). The final return time is unchanged, but the restriction is not in the rules.
- Mistake: Only the question day's services (`act`) were used; `prev` was computed and ignored.

### tour

**Tool calling: passed.** Wrote a recursive-CTE table macro `search(src)` and ran a subset DP (`dp1`..`dp5`, bitmask per visited station) over the five stations, then reconstructed 12 legs returning at 48660. Passed in 16 requests ($1.20). ($1.20, 16 requests, 3.6 min)
- Right: Used a proper bitmask DP over visited sets rather than trying orders by hand; `res5` gave 48660 with the next best 49877.
- Right: Reported the visit departure from Julius-Vahlteich-Str. as 38112 = 38400 - 288 m walk to `Pb25f298a`, following the question's rule.
- Right: Verified all 12 legs in one query against `tt` with `board`/`alight` flags.
- Mistake: `ParserException` on `cast(c."at" as int) at` (reserved word used as an alias); renamed to `att`.
- Mistake: `BinderException` on a `union all` of `select *` from `dp` tables with different column counts; reissued with explicit columns.
- Mistake: The `search` macro caps boarding at `b.dep<=r.t0+6000` and 6 rounds; a longer leg would have been missed. It did check the largest leg afterwards (`max(r.arr - s.t)` = 2959).
- Mistake: Only day 339 services loaded. Reconstruction needed three separate macros (`direct`, `two`, and a hand-written three-leg query).

**Code mode: passed.** Ran a cached Python connection scan over all 120 visiting orders (149 scans) and got 48660, next best 49560; same 12 legs as tools. Passed in 15 requests at $0.84 against $1.20. ($0.84, 15 requests, 2.6 min)
- Right: Exhaustive `itertools.permutations(targets)` with a cache keyed on (station, time).
- Right: Validated every transfer with asserts and printed slack per segment.
- Right: Tested a no-start-walk variant (`csa2`), saw it gave Altpieschen 40440 instead of 40320, and kept the walking version with the 288 m walk to `Pb25f298a`.
- Mistake: The no-walk sensitivity runs (`csa2`, `ea2`, a second permutation pass) added requests without changing the answer.
- Mistake: Scan horizon fixed at `T+10800` without a check that no leg needed longer.
