---
title: "Claude Sonnet 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 40%, code mode 60%; rank 24 of 32."
canonical: https://models.pydantic.dev/models/claude-sonnet-5/transit_planner/
---

# Claude Sonnet 5 on Pydantic AI Transit Planner

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

| Mode         | Score | Tasks passed | Cost   | Requests | Tool calls | Time      |
| ------------ | ----- | ------------ | ------ | -------- | ---------- | --------- |
| Tool calling | 40%   | 4 of 10      | $10.89 | 471      | 588        | 87.1 min  |
| Code mode    | 60%   | 6 of 10      | $12.38 | 542      | 534        | 111.6 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gateway/anthropic:claude-sonnet-5` passed 10/20 runs. Four failures exhausted the 80-request budget; six returned rejected answers. None of the supplied failures was a provider error. It can construct useful timetable searches, but completeness and request efficiency are inconsistent.

#### Where it does well

Both modes passed `arrive_by`, `meeting_point`, and `one_vehicle`. Successful searches handled service calendars, repeated-run identifiers, transfer margins, and vehicle-leg output. Tools mode also produced the accepted 12-journey departure profile, including dominance checks against later departures.

Code mode's broader routing recovered important alternatives: `saturday_direct` arrived 900 seconds earlier than tools mode, `walking_change` 300 seconds earlier, and `timed_tour` 1200 seconds earlier. These improvements came from resolving untimed stops and considering walking links beyond the named transfer stations.

#### Mistakes it makes

The recurring correctness problem is incomplete modeling. Both `one_change` runs excluded untimed calls. Tools-mode `saturday_direct` missed an interpolated boarding time even after retrieving the relevant run. Tools-mode walking and tour searches narrowed candidates prematurely.

Code-mode `tour` treated platforms within a visited station as interchangeable without walking. Its actual stays at two visits were only 897 and 819 seconds, below the required 900.

SQL errors repeatedly involved unquoted `at`; code mode added sandbox mistakes such as unsupported `time.time()` and a memory-limit reset. Long sequences of counts, individual-run inspection, and manual reconstruction consumed budget. Both midnight runs, tools-mode `tour`, and code-mode `departure_profile` never submitted answers.

A pass is not a complete quality guarantee: the tools-mode meeting SVG has incorrect y-coordinates for both endpoints of one leg.

#### Tool calling compared with code mode

Code mode passed 6/10 versus 4/10 with tools. It fixed three tools-mode failures but lost the passing departure-profile case to budget exhaustion. Total requests increased from 471 to 542, and cost from $10.8879 to $12.3752.

Python helped automate routing rounds, visit-order evaluation, and SVG generation, but many cells merely wrapped one SQL query. Code mode improved coverage more reliably than efficiency; neither mode consistently preserved enough budget for reconstruction and final submission.

## Runs

### one_vehicle

**Tool calling: passed.** Passed with a walk to `P0091960a`, then `R27f8d4b1+2` from `29940` to `30480`, using one vehicle. ($0.28, 18 requests, 2.9 min)
- Right: Recognized that the one-vehicle restriction still permits an initial walk.
- Right: Checked services, access letters, and repeat offsets before selecting bus 66.
- Mistake: The nearby-platform query measured distances from only `P0a9e487a` and `P6e8c05a2`, rather than all origin and destination platforms. The winning route survived this restriction.
- Mistake: The SVG marked station `S6f32bdc5` using platform coordinates `(12446,8649)` rather than the station's `(12359,8715)`. Required vehicle endpoints were drawn correctly.

**Code mode: passed.** Passed with the same one-vehicle route as tools mode: `R27f8d4b1+2`, boarding at `29940` and arriving at `30480`. ($0.38, 23 requests, 4.2 min)
- Right: Queried nearby platforms against all origin and destination platforms.
- Right: Calculated the initial walk to `P0091960a` as `399` seconds, feasible from start time `29400`.
- Right: Verified the base run, service, and repeat definition before generating the SVG.
- Mistake: Used an unnecessary `select 1` while considering the already-specified weekday.
- Mistake: Candidate searches filtered raw `b.at` and did not implement general interpolation, leaving the optimality check incomplete despite the accepted answer.

### saturday_direct

**Tool calling: failed.** Returned `Ra7402f8f`, arriving at `35460`, missing the faster `Rb28d92d7` arrival at `34560`. ($0.58, 32 requests, 4.5 min)
- Right: Identified five active Saturday services and checked repeat definitions.
- Right: Returned a direct journey with the required platform and run attributes.
- Mistake: The departure queries used raw `c.at between ...`, excluding untimed boarding calls. `Rb28d92d7` appeared in the results with a null boarding time and was later included in a route-detail query, but its boarding time was never resolved.
- Mistake: It should have interpolated `Rb28d92d7` at `P7fa04a55` to `33484` and selected its `34560` arrival, saving `900` seconds.

**Code mode: passed.** Passed by resolving the untimed boarding call on `Rb28d92d7`: departure `33484`, arrival `34560`. ($0.55, 37 requests, 6.2 min)
- Right: Applied Saturday service rules, cumulative rounded segment distances, interpolation, and repeat expansion.
- Right: Compared direct candidates and ran a second vehicle-routing round to check for an improvement.
- Right: Generated the SVG from the correct platform coordinates.
- Mistake: Encountered an unquoted-`at` parser error and later queried nonexistent `runs.run` instead of `runs.ref`.
- Mistake: Spent several requests recounting services and runs before constructing the routing tables.
- Mistake: Initial walks to other stations were seeded from the station centre; the winning direct route did not depend on this incorrect shortcut.

### one_change

**Tool calling: failed.** Returned a two-vehicle journey arriving at `28740`, but failed the benchmark's earliest-arrival requirement. ($0.17, 15 requests, 1.7 min)
- Right: Expanded repeats and correctly calculated the selected transfer: a `72`-second walk plus the `120`-second margin fits between `28260` and `28500`.
- Right: Wrote the two legs and four platform markers to the SVG.
- Mistake: In `calls_exp`, used `where c.at is not null`, dropping untimed stops instead of applying the required interpolation.
- Mistake: The final search only boarded at the two origin platforms and alighted at destination platforms; it omitted initial and final walking alternatives. It should have compared all permitted zero-, one-, and two-vehicle journeys over the complete timetable before selecting `28740`.

**Code mode: failed.** Returned the same rejected `28740` arrival as tools mode, taking 45 requests instead of 15. ($0.46, 45 requests, 3.7 min)
- Right: Expanded repeats and eventually considered both initial and final platform walks.
- Right: Applied `dep2 >= arr1 + 120 + CEIL(wp.dist)` and produced the required SVG elements.
- Mistake: In `leg1`, `leg2`, and their expanded versions, required non-null arrival and dwell values instead of interpolating untimed calls.
- Mistake: Reversed access checks: boarding used `LIKE '_Y'` and alighting used `LIKE 'Y_'`. These should test the first and second letters respectively; the selected calls being `YY` concealed this error.
- Mistake: Lost requests to unquoted `at`, an unprinted failed table creation, and the typo `BETWEENeight`.

### walking_change

**Tool calling: failed.** Returned a transfer at Zwinglistraße arriving at `63780`; missed the accepted Prager Straße–Altmarkt walking transfer arriving at `63480`. ($0.98, 39 requests, 7.8 min)
- Right: The selected transfer from `Pddd797f4` to `Pa9d865a5` satisfies the walking and transfer-margin rules.
- Right: Correctly applied repeat offsets to `R2d3055ed+34` and `Rd49d751b+60`.
- Mistake: The search concentrated on named transfer stations, first Postplatz and then Zwinglistraße, rather than enumerating all platform pairs within `400` metres.
- Mistake: It should have considered `R76d2117b+4` to `P86f9a261` at `61920`, walked to `P9cd5b9a9`, and boarded `R3a0dccd4+54` at `62458`, arriving `300` seconds earlier.

**Code mode: passed.** Passed with `R76d2117b+4`, a Prager Straße–Altmarkt walk, and `R3a0dccd4+54`, arriving at `63480`. ($1.17, 48 requests, 11.5 min)
- Right: Resolved untimed calls and searched platform walking links rather than restricting transfers to a shared station.
- Right: The `339`-second walk plus `120`-second margin permits boarding at `62458` after arrival `61920`.
- Right: Retained predecessor identifiers in `all_arrivals` and checked the selected runs before rendering.
- Mistake: An initial query failed on unquoted `at`.
- Mistake: Repeated several counts of `expanded_calls` and `all_calls`, and drafted then abandoned a complicated `round_query`, adding overhead to the 48-request run.

### after_midnight

**Tool calling: error.** Investigated Friday-night and Saturday services but exhausted all 80 requests without returning a journey or SVG. ($1.82, 80 requests, 12.3 min)
- Right: Read `DATA.md`, checked both service dates, expanded repeats, and subtracted `86400` from previous-day times.
- Right: Eventually included `src` in joins between `board_events` and `alight_events`, separating service-day instances.
- Mistake: When constructing `day_calls`, filtered out untimed calls with `at2 is not null` instead of interpolating them first.
- Mistake: Early expanded-call joins mixed service-day instances: one result paired departure `95580` with arrival `9240`. The later `src` joins corrected this.
- Mistake: Spent much of the budget inspecting individual runs and reconstructing routes through successive queries; the final request still inspected `Rb196178b`. It should have built a complete, interpolated event table and retained predecessors during the search.

**Code mode: error.** Eventually computed an arrival of `6420`, but reached the 80-request limit before reconstructing and returning the journey. ($1.94, 80 requests, 13.7 min)
- Right: Kept service day in the run identity and correctly shifted Friday times by `-86400`.
- Right: Late in the run, constructed `calls_interp` and reran routing; the destination label stabilized at `6420`.
- Mistake: Early `run_code` calls attempted unavailable `import duckdb` and unsupported `time.time()`; another compared `None` with numbers.
- Mistake: Built `calls_win` using only non-null times and postponed general interpolation until message `149`. This required rebuilding the routing graph near the request limit.
- Mistake: The last cell ran eight rounds even though `6420` was unchanged after the second. It should have interpolated first, stopped on convergence, and retained route predecessors.

### arrive_by

**Tool calling: passed.** Passed with departure `63360` and arrival `64500`, using `R1aabe4da+29` followed by `R54c1ee76+5`. Required 51 requests. ($1.29, 51 requests, 9.0 min)
- Right: Applied Thursday service filtering and repeat offsets.
- Right: Returned both vehicle legs and wrote `/out/journey.svg` with the boarding/alighting markers and run attributes.
- Mistake: Throughout the candidate queries, repeatedly required `a.at is not null and b.at is not null`, excluding usable untimed calls rather than interpolating them.
- Mistake: Explored individual lines and transfer stations through many repeated CSV queries instead of a systematic latest-departure search. The restricted search nevertheless found the accepted departure.

**Code mode: passed.** Passed with departure `63360` and arrival `64440`, using `R1aabe4da+29` and `Rfd6f9e2d+67`. ($0.92, 47 requests, 9.3 min)
- Right: Interpolated calls, expanded repeats, and implemented backward latest-departure propagation.
- Right: Used `do_round()` with a change count and stopped when no labels changed.
- Right: Checked the walking transfer from `P3b6efaff` to `P6ea0167f` before reconstructing the journey.
- Mistake: Repeated unquoted-`at` parser errors during interpolation setup, then queried `rc5` before it existed.
- Mistake: The final nearby-origin check measured from the station centre rather than all origin platforms. The accepted departure did not require that shortcut.

### departure_profile

**Tool calling: passed.** Passed with 12 journeys, departing from `25327` through `28620`, after 41 requests. ($1.01, 41 requests, 9.2 min)
- Right: Implemented distance-based interpolation and expanded repeated runs.
- Right: Built `dep_frontier` using `min(arr) over (order by dep desc rows between unbounded preceding and 1 preceding)`, checking later departures before restricting the reporting window.
- Right: Applied the transfer condition `board_time >= alight_time + 120 + ceil(distance)`.
- Mistake: The interpolation query initially failed on unquoted `at`; a subsequent query corrected it.
- Mistake: Restricted the search to selected lines and two vehicle legs, although the question imposed no vehicle limit. This happened to produce an accepted profile.
- Mistake: Used separate `t_test` creation/read calls to test persistence and an unnecessary final `select 1`.

**Code mode: error.** Built a profile and wrote an SVG, but exhausted 80 requests before submitting the answer. ($2.34, 80 requests, 20.3 min)
- Right: Implemented reverse profile scanning and recovered from a sandbox memory reset with more compact data structures.
- Right: Corrected an initially inconsistent reconstructed route to use `R77afbc0f+4`, a `42`-second walk, and `R61625888`.
- Mistake: After substantial SQL preprocessing, rebuilt the timetable directly from files in Python; the profile scan exceeded the `268435456`-byte memory limit and reset the session.
- Mistake: The first reconstruction boarded `R61625888` at `26751` after an alleged arrival at `26862`; this was corrected in the next cell.
- Mistake: Computed origin walks from the station centre, subtracting `55` seconds even for its own platform `P8e65d0ee`. Prepared departure `25272` should have been `25327` because passengers may start at any origin platform.
- Mistake: The last request wrote `/out/journey.svg`; no request remained for the final answer.

### meeting_point

**Tool calling: passed.** Passed with meeting station `Sbb9212fa` at `33701`, reached using `Rc0124950` and `Rfa439a34`. Took 63 requests. ($1.36, 63 requests, 11.6 min)
- Right: Computed reachable platform times for both passengers and minimized `greatest(s1.time,s2.time)` over shared stations.
- Right: Resolved untimed calls and returned arrivals `33701` and `33692`.
- Mistake: During interpolation setup, repeated SQL errors involving unquoted `at` and `IGNORE NULLS`, including a query against nonexistent `calls_s`.
- Mistake: In `write_file`, placed `Pb4e674b9` at y=`262.91` instead of approximately `337.06`, and `Pcb3f34ed` at y=`328.60` instead of approximately `271.40`. The second leg inherited these incorrect endpoints despite the benchmark pass.
- Mistake: Repeated routing rounds through separate calls rather than stopping automatically when labels stabilized.

**Code mode: passed.** Passed with Albertplatz at `33701`, using arrivals `33701` and `33692`, in 44 requests. ($0.92, 44 requests, 9.1 min)
- Right: Interpolated calls, expanded service-day instances, and propagated ride and walk reachability for both passengers.
- Right: Compared shared-station arrival times and explicitly checked for any meeting before `33701`.
- Right: Verified the initial walk from `P6239000d` to `P3035f403` and generated the SVG programmatically.
- Mistake: Interpolation setup repeated unquoted-`at` errors.
- Mistake: `run_round()` referenced missing column `c.n`; the model added the column and rebuilt `connections`.
- Mistake: Executed fixed batches of 15 and 16 routing rounds rather than using a convergence test.

### timed_tour

**Tool calling: failed.** Returned a six-leg tour ending at `45360`; the accepted code-mode tour ends at `44160`, twenty minutes earlier. ($1.50, 52 requests, 13.1 min)
- Right: Built interpolated, repeated calls and reported visits with opening-window-compatible stays.
- Right: Accounted for walking before departures from TU, Pohlandplatz, and Mickten.
- Mistake: After creating `cf_target` from only the named stations' platforms, searched connections largely within that restricted table. This missed walking to nearby `P40aaf538` for `Rf679205e+8`.
- Mistake: Chose Prohlis–Pirnaischer Platz–TU via `R77afbc0f+22` and `R36bae333+1`, reaching TU at `37980`. Walking to `Rf679205e+8` reaches TU at `37080` and enables the earlier return.
- Mistake: Should have searched all permitted platform walks and visit orders instead of selecting the tour through individual line queries.

**Code mode: passed.** Passed with five vehicle legs and return at `44160`, twenty minutes earlier than tools mode, after 72 requests. ($1.97, 72 requests, 17.5 min)
- Right: Used `max(arr, open) + 900` for visit readiness and rejected arrivals later than `close - 900`.
- Right: Carried the arrival platform into subsequent searches and included walking to nearby boarding platforms.
- Right: Found `Rf679205e+8` from `P40aaf538` to TU, then reconstructed walk-adjusted visit departures.
- Mistake: A batch evaluating visit orders exceeded the per-cell limit after 100 tool calls; subsequent cells resumed smaller batches.
- Mistake: Spent many later requests manually tracing the already-found `44160` solution rather than retaining predecessors during routing.
- Mistake: `eval_order()` kept only `res[0]`, the earliest platform arrival at each visit, rather than preserving alternative platform states. This pruning was sufficient here but was not a general optimality guarantee.

### tour

**Tool calling: error.** Prepared routing tables and explored station-to-station travel, but exhausted 80 requests without a final tour or SVG. ($1.91, 80 requests, 14.8 min)
- Right: Implemented interpolation, repeat expansion, platform walks, and successive vehicle-routing rounds.
- Right: Computed arrival candidates for all five visit stations.
- Mistake: Early table construction failed on unquoted `at` and invalid `lag(1) ignore nulls` syntax, followed by a query against missing `c3`.
- Mistake: Spent dozens of requests inspecting individual routes and manually repeating `ready2`, `arr2`, and later rounds.
- Mistake: Repeated searches from stations at fixed time `37800` without completing a visit-order optimization. It should have tracked visited subsets and actual arrival times, reserving budget for reconstruction and rendering.

**Code mode: failed.** Completed a nine-leg tour returning at `49560`, but failed because its visit handling omitted required platform walks. ($1.73, 66 requests, 16.1 min)
- Right: Implemented interpolation, repeat expansion, and dynamic programming over `(frozenset(visited), last)`.
- Right: Reconstructed all nine legs and generated station and platform markers.
- Mistake: In `start_walk`, assigned zero walking time to every platform belonging to a visit station and measured external walks from its centre. Subsequent searches therefore lost the actual arrival platform.
- Mistake: At Waldschlößchen, `P50445d2a` to `Pda4a5390` takes `57` seconds. Boarding at `38280` means setting off at `38223`, only `897` seconds after arrival `37326`.
- Mistake: At Marienberger Straße, `P9e29d07a` to `P8e65d0ee` takes `123` seconds. Boarding at `46800` means setting off at `46677`, only `819` seconds after arrival `45858`.
- Mistake: Should have preserved arrival-platform state through the tour optimization and validated each stay after subtracting its actual outgoing walk.
