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

# Claude Sonnet 5.5 on Pydantic AI Transit Planner

> Journey planning over a real Dresden public transport timetable, with an SVG map of each answer. Tool calling 80%, code mode 100%; rank 15 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/claude-sonnet-5.5/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-sonnet-5.5.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 80%   | 8 of 10      | $1.73 | 204      | 208        | 17.2 min |
| Code mode    | 100%  | 10 of 10     | $1.86 | 174      | 164        | 18.1 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`claude-sonnet-5-5` passed 18 of 20 runs: 8/10 with tool calling and 10/10 in code mode. Both failures are in tool calling and are reasoning slips, not tool or provider problems. Total cost was $1.73 (tools, 204 requests) and $1.86 (code mode, 174 requests).

#### Where it does well

- **Timetable construction.** Every run correctly rebuilt the timetable: distance-based interpolation of untimed calls, `<run>+<k>` repeat expansion, `Y`-only boarding/alighting, 400 m walks, and the 120 s + walk change margin.
- **Right algorithm per question.** Backward latest-departure search for `arrive_by`, round-based earliest arrival for point-to-point, and a subset DP for `tour` (both modes) and `timed_tour` (code mode).
- **Service days.** `after_midnight` pulled in the previous service day with a `-86400` offset in both modes.
- **Verification.** It usually ran one or two extra rounds to confirm the answer was stable.

#### Mistakes it makes

- **Time conversion (`meeting_point`, tools).** 09:00 was seeded as `36000` instead of `32400`, giving Postplatz at 37440 instead of Albertplatz at 33701.
- **Minimum-stay rule (`timed_tour`, tools).** Ready times were hard-coded as window-open + 900 (`39600` for Pohlandplatz), ignoring the 39480 arrival. It boarded at 39962 after an 8-minute stay. It also tried only one visit order.
- **Reserved word `at`.** All 10 tool runs and at least 6 code-mode runs hit a DuckDB parse error on the unquoted `at` column, each costing one or more requests.
- **Multi-statement `run_sql`.** Only the last statement's result is returned, so `services`/`service_changes` were re-queried in most tool runs. A failure mid-batch produced follow-on "table does not exist" errors.
- **Skipped `service_changes`.** At least 5 tool runs filtered active services without it. This was harmless on these dates.
- **Inconsistent `departure`.** The field was sometimes the start time and sometimes the board time (4200 vs 5280 on `after_midnight`); both passed.

#### Tool calling compared with code mode

Code mode was more reliable (10/10 vs 8/10) at about 8% higher cost.

- **Where code mode helped.** Loops and Python state suited the search problems. `tour` took 22 requests and $0.27 against 47 and $0.42, because legs were rebuilt in a loop rather than one `run_sql` per hop. `timed_tour` used a real DP and derived stays from actual arrivals.
- **Where it cost more.** Simple cases were similar or dearer (`walking_change` $0.18 vs $0.13, `departure_profile` $0.35 vs $0.20). Unchecked SQL errors inside helpers, plus sandbox limits (`__import__`, `OrderedDict`, `time`), wasted turns.
- **Caveat.** The code-mode `timed_tour` prompt had an extra sentence defining set-off time, so that pair is not strictly like for like.

## Runs

### one_vehicle

**Tool calling: passed.** Restricted to runs calling at Technische Universität, found `R27f8d4b1+2` boarded at `P0091960a` (a 399 m walk from Lennéplatz) at 29940, arriving 30480. Passed in 13 requests. ($0.11, 13 requests, 59 s)
- Right: Considered boarding platforms within walking distance of the origin, not only the origin's own platforms
- Right: Handled both `+` and `-` service changes in `act`
- Mistake: `try_cast(c."at" as int) at` parse error
- Mistake: Queried `lines` without having loaded it (`Table with name lines does not exist`)
- Mistake: Wrote `/out/journey.svg` twice; the first version had wrong path coordinates and an empty second `<path>`
- Mistake: `departure` given as 29400 (start time) rather than board time minus the 399 s walk; not penalised

**Code mode: passed.** Pulled candidate runs into Python, interpolated untimed calls with its own `times()` function and returned `R27f8d4b1+2` from `P0091960a`, arriving 30480. Passed in 15 requests. ($0.11, 15 requests, 59 s)
- Right: Implemented the untimed-call interpolation in Python and expanded repeats itself
- Right: Checked walk distances from each Lennéplatz platform (399 m from `P0a9e487a`) before accepting the boarding stop
- Mistake: `near()` first returned `7 0` and no candidates because the platform dictionary was incomplete
- Mistake: Unquoted `at` in `select run,n,place,at,dwell,access` failed, first as a runtime error then as a parser error
- Mistake: Leg drawn as a single straight line

### saturday_direct

**Tool calling: passed.** Found the direct run `Rb28d92d7` from `P7fa04a55` at 33484 to `P1093f876` at 34560 and checked that one- and two-change options (34971) were no better. Passed in 18 requests. ($0.13, 18 requests, 74 s)
- Right: Used the Saturday bit (`days&32`) and the `-` change check for 2026-339
- Right: Verified the direct answer against extra rounds `rd2` and `rd3`
- Right: Drew the leg through all 14 intermediate stops
- Mistake: `cast(c."at" as int) at` parse error, then `Table with name act does not exist` because the failed batch rolled everything back; the same long statement was sent three times
- Mistake: `select min(at_+w) from rd3 ...` was run twice because the first was not the last statement of its batch
- Mistake: SVG written twice

**Code mode: passed.** Built the timetable for days 339 and 338, ran a chained search from 33300 and returned the direct run `Rb28d92d7`, arriving 34560. Passed in 10 requests, the cheapest case at $0.10. ($0.10, 10 requests, 58 s)
- Right: Fewest requests of any run
- Right: Handled `+`/`-` changes and the previous service day
- Mistake: `case when at is not null` parse error; the first batch's failure surfaced only as `Table with name c3 does not exist`

### one_change

**Tool calling: passed.** Built direct and two-vehicle candidate tables (`direct`, `two`) and returned `Rafeef850` then `R620ec7d9` with a 72 m walk, arriving 28440. Passed in 16 requests. ($0.11, 16 requests, 60 s)
- Right: Compared direct against two-vehicle options and honoured the at-most-2-vehicles limit
- Right: Applied the 120 s + walk change margin (27960 + 120 + 72 \<= 28200)
- Mistake: `at::int at` in the first `create table calls` failed to parse; the whole load was redone
- Mistake: `ceil(sqrt((e-pe)^2...))` on varchar coordinates raised `No function matches '-(VARCHAR, VARCHAR)'`
- Mistake: `active` handled `-` changes but not `+` changes (no effect on 2026-337)
- Mistake: Places lookup was issued twice because the first was the non-final statement of a batch

**Code mode: passed.** Loaded typed tables, built the timetable and returned `Rafeef850` then `R620ec7d9`, arriving 28440. Passed in 13 requests. ($0.10, 13 requests, 55 s)
- Right: Same journey as tools for fewer requests (13 vs 16)
- Right: SVG coordinates computed in code
- Mistake: `at is not null` parse error hit twice (`cs`, then `ctt`), and `print(r)` was needed as its own call to see the error
- Mistake: `calls` had to be recreated with `"at"::int ta`
- Mistake: SVG labels are bare platform ids

### walking_change

**Tool calling: passed.** Ran rounds `a2`/`a3` carrying a path string and returned `R76d2117b+4` to `P86f9a261`, a 341 m walk, then `R3a0dccd4+54` arriving 63480. Passed in 14 requests. ($0.13, 14 requests, 64 s)
- Right: Found the cross-station walk change (341 m, 61920 + 120 + 341 \<= 62458)
- Right: Carried the path in the label so no separate reconstruction was needed
- Right: Drew the walk as a dashed line without a `data-run`
- Mistake: `try_cast(at as int) at` parse error
- Mistake: `Cannot concatenate types VARCHAR and BIGINT[]` on the first path-building attempt
- Mistake: Active services ignored `service_changes` (no effect on 2026-338)

**Code mode: passed.** After several turns recreating tables that had silently failed, ran rounds `A1`/`A2` and returned the same walk-change journey arriving 63480. Passed in 17 requests at $0.18, more than tools ($0.13). ($0.18, 17 requests, 1.5 min)
- Right: Found the 341 m walk change
- Right: Checked for runs active on both service days (3775) and rebuilt `ev` with the offset
- Mistake: Helper `q` did not surface errors, so `try_cast(at as int) at` failed unseen and about five calls went on `Table with name c3/ev/c0 does not exist` and `show tables` before the parser error was printed
- Mistake: SVG coordinates were typed into the code as literals rather than queried
- Mistake: Labels are bare platform ids

### after_midnight

**Tool calling: passed.** Built the timetable in DuckDB for service days 339 and 338 (offset `-86400`), ran three boarding rounds and returned `R93fefd15` then `R900bf42f+2`, arriving 6420. Passed in 18 requests. ($0.12, 18 requests, 65 s)
- Right: Included the previous service day (`select 339 dn, 32 wd, 0 off union all select 338,16,-86400`) so after-midnight runs were found
- Right: Ran rounds 2 and 3 (`rd2`/`a2`, `rd3`/`a3`) and confirmed 6420 did not improve
- Right: Respected the 120 s + walk margin (`min(a.arr+120+w.w)`) for the 76 m change at Südhöhe
- Mistake: First `run_sql` packed three `select`s into one call; only the last result came back, so `select * from sv; select * from sc;` and then `select * from sv;` were re-run separately
- Mistake: `cast(nullif(c.at,'') as int) at` hit `ParserException` because `at` is reserved; whole batch had to be re-sent
- Mistake: Reported `departure` 4200 (the start time) while code mode reported 5280 for the same legs; both passed, so the field looks unchecked here

**Code mode: passed.** Computed active services for days 338 and 339 in Python, built labels `lab0`..`lab5` in a loop and returned the same two legs arriving 6420. Passed in 16 requests. ($0.14, 16 requests, 80 s)
- Right: Loop over `K=6` rounds in one call showed 6420 stable from round 1 onward
- Right: Included previous-day runs
- Right: SVG generated from queried coordinates
- Mistake: `No function matches` error from arithmetic on varchar coordinates, fixed with a string `replace` on the query
- Mistake: A helper that raises on SQL error aborted one call midway (`create table ready0`)
- Mistake: Ambiguous `ref` in the final places join cost one more call

### arrive_by

**Tool calling: passed.** Did a backward latest-departure search (`lb0`..`lb3`) from Lennéplatz with deadline 64800 and returned `R1aabe4da+29` at 63360 then `Rfd6f9e2d+67`, arriving 64440. Passed in 14 requests. ($0.13, 14 requests, 68 s)
- Right: Searched backwards from the destination (`max(dep)` labels) rather than forwards, which is the right shape for an arrive-by question
- Right: Checked that the answer was stable across `lb1`, `lb2`, `lb3` (all 63360)
- Right: Drew the legs as multi-stop paths through intermediate calls
- Mistake: `act` was built from `days&8` and the date range only, ignoring `service_changes`; harmless here because no change applies to 2026-344
- Mistake: `try_cast(c."at" as int) at` parse error on the reserved word cost one request
- Mistake: Multi-statement first call returned only the places result, forcing two extra calls for `svc`/`chg`

**Code mode: passed.** Backward search with `F{k}`/`L{k}` tables in a Python loop, returning the same journey as tools (leave 63360, arrive 64440). Passed in 14 requests. ($0.12, 14 requests, 65 s)
- Right: Handled both `+` and `-` service changes in `act`
- Right: Cross-checked the connection at Straßburger Platz (64 m walk, `Rfd6f9e2d+67` at 64260) before answering
- Mistake: `c.at::int at` parse error; because the first failure was not checked, later statements failed with `Table with name ev does not exist` and a `show tables` call was needed to see what existed

### departure_profile

**Tool calling: passed.** Built per-departure label tables `L1`..`L4` in SQL, filtered dominated journeys and returned 12 journeys from 25327 to 28620. Passed in 22 requests. ($0.20, 22 requests, 2.6 min)
- Right: Produced one journey per departure time in order, with dominated ones removed
- Right: Recovered from a 30-second query stop on `L4` by rewriting the query
- Right: All 12 journeys' legs were drawn in the SVG
- Mistake: `cast(c.at as int) at` parse error on first timetable build
- Mistake: `create table L4` join with a `+3600` window and a correlated `select A from fin2` was stopped after 30 seconds
- Mistake: Active services filter ignored `service_changes` (no effect on 2026-342)
- Mistake: SVG with 12 journeys was typed by hand in `write_file`

**Code mode: passed.** Ran a per-departure frontier expansion (`brd`, `alt`, `frontier`, `dest`) for 108 candidate departures, filtered dominated ones and returned the same 12 departure/arrival pairs as tools. Passed in 27 requests at $0.35, the costliest code-mode case. ($0.35, 27 requests, 4.2 min)
- Right: Noticed implausible durations (`dur` 103 for departure 25277) in a first result, traced it to the label tables and reran
- Right: Dominance filter done in one window query (`min(arr) over (... 1 following ...)`)
- Right: Journeys and SVG generated from data rather than typed
- Mistake: Named a table `full` (reserved word) and had to rename it
- Mistake: `import time` and `from collections import OrderedDict` both failed in the sandbox
- Mistake: `Table with name ... does not exist` after a batch with an unchecked error
- Mistake: Intermediate `alt` table reached 4,994,798 rows in one round

### meeting_point

**Tool calling: failed.** Ran a correct two-origin earliest-arrival search but seeded it with 36000 instead of 32400 for 09:00, so it answered Postplatz `Sb62a8cc4` at 37440; code mode found Albertplatz `Sbb9212fa` at 33701. Failed. ($0.18, 20 requests, 1.6 min)
- Right: Search structure was sound: `rdy0` start labels with walks, five boarding rounds, then `greatest(a.t,b.t)` per station
- Right: Verified the chosen legs against `tt` before answering
- Mistake: In `create or replace table rdy0 ... select k, p.ref q, 36000 r` and `ttb2 ... where dep>=36000` it used 36000 (10:00) for a 09:00 start; it should have used 32400. Every later step inherited the hour's error and both journeys report `departure` 36000
- Mistake: `try_cast(at as int) at` parse error, then a follow-up `Table with name actr does not exist` because the failed batch had not created it
- Mistake: Several calls ended in throwaway statements (`select count(*) from ttb, tta where false`) so no useful output came back

**Code mode: passed.** Wrote a reusable `run_origin(tag, st, K=6)` seeded with 32400, joined both origins per station and returned Albertplatz `Sbb9212fa` at 33701. Passed in 18 requests. ($0.23, 18 requests, 2.0 min)
- Right: Correct start time 32400 (the tools run used 36000)
- Right: One function ran both origins; `recon()` rebuilt legs from the label tables
- Right: Included day 338 as well as 339
- Mistake: First call used `__import__`, rejected by the sandbox type check
- Mistake: `window function calls cannot be nested`, then varchar subtraction error, on the timetable build
- Mistake: SVG step raised `KeyError: P3035f403` on first try

### timed_tour

**Tool calling: failed.** Chained five single-leg journeys using pre-fixed ready times and returned at 44160, but the Pohlandplatz visit lasts only from 39480 to a board at 39962, under the required 15 minutes. Failed; code mode kept the same return time with a valid 40560 departure. ($0.22, 22 requests, 2.2 min)
- Right: Final return time 44160 on `R20f18e60+34` matches the passing code-mode answer
- Right: Opening windows for TU and Mickten were respected
- Mistake: `insert into q values (1,'S28d8da90',39600),(2,'Sd3f1948f',37800),(3,'S2b179bf4',43200),(4,'S6fa3fbd1',35340)` fixed each station's ready time at window-open + 900 before knowing arrivals. Arrival at Pohlandplatz was 39480, so the earliest set-off was 39480 + 900 = 40380, yet it queried `('S28d8da90',39600,'S2b179bf4')` and boarded `Rcc990042+9` at 39962
- Mistake: Reported visit `S28d8da90` as arrival 39480, departure 39600 (120 s) without noticing it broke the 15-minute rule
- Mistake: No search over visit orders: one hand-picked order from a single matrix query, not a permutation or subset DP
- Mistake: `try_cast(at as int) at` parse error and a `union all` with mismatched column counts early on

**Code mode: passed.** Ran a subset DP in Python (`best[(frozenset, last)]`, `process(k, budget=12)`) over a SQL `journey()` routine and returned a valid tour back at 44160, leaving Pohlandplatz at 40560 on `R1aabe4da+10`. Passed in 22 requests. ($0.25, 22 requests, 2.4 min)
- Right: Ready time at each stop derived from the actual arrival and the window, giving a 1080 s stay at Pohlandplatz (39480 to 40560)
- Right: All 24 subset/last states explored
- Right: Visit departures are real set-off times (35523, 38312, 40560, 43260)
- Mistake: Early batch failed silently, leading to `Table with name cc does not exist` and a `show tables` call
- Mistake: This run's prompt had an extra sentence defining set-off as vehicle departure minus the walk, which the tools prompt lacked, so the two modes are not strictly like for like

### tour

**Tool calling: passed.** Precomputed station-to-station profiles for every candidate departure (`qry`, `Prof`) and ran a bitmask DP `L1`..`L6` in SQL, returning an 11-leg tour back at 48660. Passed, but took 47 requests and $0.42, the most expensive case. ($0.42, 47 requests, 4.2 min)
- Right: Proper subset DP over the five stations (`l.mask|g.bit`) with the `q.T>=l.t+900` stay rule
- Right: Result matches code mode leg for leg
- Mistake: Path reconstruction was done one `run_sql` per hop with `lastride(...)` and `prevlab(...)` macros, roughly 20 single-row calls
- Mistake: First statement used a `?` placeholder (`(d.day-1+? ) % 7`) and failed; then the `at` parse error; then `struct_pack(arr:p.arr)` syntax error
- Mistake: Visit departures reported as arrival + 900 (e.g. 38100) rather than the actual set-off time (code mode gave 38112); not penalised

**Code mode: passed.** Ran a layered subset DP in Python (`frontier`, `layer(L, scens)`) with SQL doing the per-layer routing, then `recon()` to rebuild the 11 legs; back at 48660. Passed in 22 requests versus 47 with tool calling. ($0.27, 22 requests, 2.7 min)
- Right: Same 11 legs as tools at about two thirds of the cost ($0.27 vs $0.42)
- Right: Reconstruction done in loops inside two calls instead of one call per hop
- Right: Visit departures are actual set-off times (38112, 41280, 43380)
- Mistake: `at is null` parse error, then `Table with name cs does not exist`, then `show tables` to recover
- Mistake: DP loop raised a runtime error on layer 6 (return leg) and that layer was redone by hand
- Mistake: A first-layer result contained a non-integer time (`37326.107652874`) before integer division was substituted
