---
title: "Claude Opus 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 80%; rank 15 of 32."
canonical: https://models.pydantic.dev/models/claude-opus-5/transit_planner/
---

# Claude Opus 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 80%; rank 15 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/claude-opus-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-opus-5.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 80%   | 8 of 10      | $8.41 | 241      | 270        | 41.9 min |
| Code mode    | 80%   | 8 of 10      | $5.40 | 188      | 178        | 28.9 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gateway/anthropic:claude-opus-5` passed 16/20 runs on `transit_planner 0.2`: 8/10 in each mode. Seven cases passed in both modes; `tour` failed in both. There were no recorded provider failures.

#### Where it does well

Both modes handled overnight service offsets, repeated runs, vehicle limits, walking transfers, latest departures, meeting points, and opening-time-constrained tours. They generally supplied complete vehicle legs and the required SVGs.

Useful checks included verifying transfer arithmetic, comparing additional routing rounds, and inspecting selected calls. Tool mode caught an impossible negative arrival in `saturday_direct`, traced it to mixing service days under one run identifier, and repaired the internal trip keys.

#### Mistakes it makes

All ten tool-mode runs encountered SQL parser errors involving unquoted `at`. Several retries then assumed tables from failed batches existed. These were recoverable but costly.

The most consequential recurring code defect was interpolation against mutated arrays: previously interpolated stops became anchors for subsequent stops. It appears in seven code-mode runs, including five passes. In `departure_profile`, it produced observable one-second errors such as 25326 instead of 25327. Passing examples therefore conceal a reusable preprocessing bug.

Tool-mode `walking_change` initialized 61200 instead of 61500 and returned a vehicle leaving before the requested start. The tour searches exposed unsupported search bounds, questionable state pruning, and unresolved platform modelling. Their exact grader rejection is unavailable because no reference optimum or diagnostic was supplied.

Seven code-mode runs also loaded timetable data directly from files despite the instruction to use `run_sql`.

#### Tool calling compared with code mode

Code mode used 188 requests and $5.3974, versus 241 requests and $8.4085 for tools: approximately 22% fewer requests and 36% lower cost, with equal pass rates. It improved `walking_change` but regressed `departure_profile`.

Python enabled reusable searches, batching, and programmatic SVG generation. It also introduced unsupported-library calls, tuple-unpacking errors, and the recurring interpolation defect. For engineering selection, code mode offers lower observed cost here, but neither mode demonstrated reliable tour optimization or consistently correct preprocessing.

## Runs

### one_vehicle

**Tool calling: passed.** Passed by walking 399 metres to Strehlener Platz and taking `R27f8d4b1+2` from 29940 to 30480. It correctly reported journey departure as `29940 - 399 = 29541`. ($0.42, 19 requests, 2.1 min)
- Right: Searched boarding and alighting platforms reachable by permitted endpoint walks.
- Right: Preserved the one-vehicle constraint and verified the 399-metre walk against other origin platforms.
- Right: Drew the walk separately from the vehicle leg.
- Mistake: Two SQL calls failed on unquoted `at`.
- Mistake: An intermediate `CREATE TABLE ct` ended with `SELECT 1` and an unused `f_dummy` CTE, producing a placeholder table rather than the timetable. The next call dropped and rebuilt it.
- Mistake: A multi-statement read returned only the final result, requiring another query for the omitted information.

**Code mode: passed.** Passed with the 399-second initial walk and `R27f8d4b1+2`, arriving at 30480. It correctly reported departure at 29541. ($0.42, 20 requests, 2.1 min)
- Right: Fetched relevant run calls through `run_sql`, including batched asynchronous queries.
- Right: Enumerated single-vehicle choices with endpoint walks.
- Right: Checked the origin-platform distances and corrected the SVG's walking-time caption before finishing.
- Mistake: A query used unquoted `at`; the following Python code assumed a successful result and raised `KeyError: rows` instead of checking for the SQL error.
- Mistake: The initial SVG caption contained inconsistent walking times and placeholder text, requiring a replacement call.
- Mistake: Used 20 requests, one more than tool mode, with nearly identical cost.

### saturday_direct

**Tool calling: passed.** Passed with `Rb28d92d7`, departing at 33484 and arriving at 34560. It recovered from an internal service-day identity bug before finalizing. ($0.66, 25 requests, 3.1 min)
- Right: Investigated an impossible arrival of -11580 instead of accepting it.
- Right: Rebuilt the timetable with service-day-specific trip identifiers such as `Rb28d92d7#0`.
- Right: Rechecked one-, two-, and three-vehicle results, all yielding 34560.
- Mistake: Initially joined current- and previous-day instances by run alone, allowing cross-day rides.
- Mistake: Earlier calls also failed on unquoted `at`, a `ready` alias reference, and an already-existing `brd2` table.

**Code mode: passed.** Passed with `Rb28d92d7` from 33484 to 34560, using 14 requests. No runtime error was recorded. ($0.30, 14 requests, 1.6 min)
- Right: Expanded services and repeats, built walking neighbours, and performed a connection scan.
- Right: Checked the selected run's calls before producing the answer.
- Right: Used a simple SVG line with the required run identifier and endpoint markers.
- Mistake: In `interp`, searched the mutated `res` array for timing anchors, allowing consecutive untimed calls to compound rounding. The selected endpoint times happened to match the passing result.
- Mistake: Read the main timetable directly through `Path.read_text()` after exploratory SQL calls, bypassing the required `run_sql` loading workflow.

### one_change

**Tool calling: passed.** Passed with two vehicles, `Rafeef850` and `R620ec7d9`, arriving at 28440. This improved on the best one-vehicle arrival of 29160. ($0.42, 19 requests, 2.0 min)
- Right: Explicitly compared one- and two-vehicle options.
- Right: Applied the 72-second walk and transfer margin: `27960 + 72 + 120 = 28152`, before boarding at 28200.
- Right: Returned the interpolated first departure of 27669 and wrote the required SVG.
- Mistake: The service-selection call produced `Subquery returns 3 columns - expected 1`.
- Mistake: The interpolation batch failed on `at IS NOT NULL`; the next call assumed `c1` existed and failed again. It then rebuilt the prerequisite tables.

**Code mode: passed.** Passed with the same two-leg journey as tool mode, departing at 27669 and arriving at 28440. ($0.37, 18 requests, 2.0 min)
- Right: Used `run_sql` to interpolate calls and expand repeated runs.
- Right: Compared one-vehicle results with two-vehicle results and reconstructed the 72-second transfer.
- Right: Generated a compact SVG with both runs and all four endpoint platforms.
- Mistake: The table-loading batch ended with unquoted `at IS NULL`, causing a parser error. It retried with a safe column name.

### walking_change

**Tool calling: failed.** Failed because it planned from the wrong start time. Its first vehicle departed at 61440, which is 17:04, before the requested 17:05. ($0.52, 25 requests, 2.5 min)
- Right: Correctly calculated the selected connection's 55-second walk and transfer readiness of 62811 for departure at 62820.
- Right: Produced complete vehicle legs and the corresponding SVG.
- Mistake: The `ready0` query initialized the origin with `61200::BIGINT`, or 17:00, instead of `17*3600 + 5*60 = 61500`. It should have rebuilt and rerun the search with 61500.
- Mistake: The final SVG explicitly labelled the invalid 17:04 departure, but no final start-time check caught it.
- Mistake: Earlier SQL retries also encountered unquoted `at`, missing `act`, and an already-existing placeholder `alight2`.

**Code mode: passed.** Passed with departure at 61560 and arrival at 63480 using `R76d2117b+4` and `R3a0dccd4+54`. Unlike tool mode, it respected the 17:05 start. ($0.40, 16 requests, 2.3 min)
- Right: Explicitly initialized `start=17*3600+5*60`, giving 61500.
- Right: Verified the 341-second walk from `P86f9a261` to `P9cd5b9a9`: `61920 + 120 + 341 = 62381`, before boarding at 62458.
- Right: Drew both rides and the transfer walk, with all endpoint markers.
- Mistake: The `build` interpolation function reused filled `arr` entries as anchors; the reported route nevertheless passed.
- Mistake: Loaded the main timetable directly from files after preliminary `run_sql` queries, contrary to the prescribed loading workflow.

### after_midnight

**Tool calling: passed.** Passed with `R93fefd15` followed by `R900bf42f+2`, departing at 5280 and arriving at 6420. It expanded Friday and Saturday services and applied the previous-day offset of `-86400`. ($0.63, 23 requests, 3.3 min)
- Right: Read `/data/DATA.md`, interpolated calls with `run_sql`, and checked additional routing rounds.
- Right: Verified the transfer: `5492 + 120 + 76 = 5688`, before the second departure at 5700.
- Right: Used `write_file` to create the required SVG with both runs and four endpoint markers.
- Mistake: The initial untimed-call count used unquoted `at IS NULL`, causing a parser error.
- Mistake: The `ev` construction reused `runid` across service days. A reconstruction query returned both 91680 and 5280 as boarding times for the same arrival at 5492; it selected the valid result, but should have keyed internal trips by service day as well as run.

**Code mode: passed.** Passed with the same two runs and 6420 arrival as tool mode. Python orchestrated `run_sql` calls and generated the SVG. ($0.52, 20 requests, 2.6 min)
- Right: Expanded both service days and applied `dayoff=-86400`.
- Right: Used a reusable `round_step(k)` and checked four routing rounds plus destination walks.
- Right: Verified the 76-second transfer walk and reconstructed both legs.
- Mistake: Two successive interpolation queries failed on unquoted `at` before it consistently quoted or aliased the column.
- Mistake: Internal `inst` identifiers omitted the service day even though `dayoff` was stored separately. Grouping only by `inst` remains unsafe when both days' instances are present.

### arrive_by

**Tool calling: passed.** Passed with the latest departure at 63360 and arrival at 64500, before the 64800 deadline. The journey used `R1aabe4da+29` and `R54c1ee76+5`. ($0.44, 20 requests, 2.1 min)
- Right: Used backward `run_sql` labels and checked that additional rounds did not improve the origin departure.
- Right: Included the 64-second platform walk and 120-second transfer margin.
- Right: Correctly optimized departure time; the earlier arrival found in code mode does not make this answer wrong.
- Mistake: During interpolation-table construction, an unquoted `at` in `SELECT run,n,place,access,s,at,dwell` caused a parser error; the replacement used `a0`.

**Code mode: passed.** Passed with departure at 63360 and arrival at 64440 using `R1aabe4da+29` and `Rfd6f9e2d+67`. It used 13 requests, versus 20 in tool mode. ($0.37, 13 requests, 2.1 min)
- Right: Performed backward latest-departure routing with endpoint walks and transfer margins.
- Right: Reconstructed a valid alternative arriving 60 seconds earlier than the tool-mode answer.
- Right: Generated the SVG programmatically.
- Mistake: In `timeline`, wrote interpolated values into `arr` and then searched that mutated array for earlier timed anchors. Consecutive untimed stops can therefore use previously rounded interpolations; the reported journey nevertheless passed.
- Mistake: After initializing SQL tables, loaded timetable files directly with `Path.read_text()` instead of following the instruction to load needed data through `run_sql`.

### departure_profile

**Tool calling: passed.** Passed with 12 nondominated journeys, departing from 25327 through 28620. All used two vehicles and arrived between 27420 and 30780. ($1.06, 28 requests, 5.6 min)
- Right: Generated 311 candidate departure times extending beyond 08:00, allowing later departures to dominate candidates inside the requested window.
- Right: Used routing rounds and `lead(A) over (order by T)` to identify the retained departure/arrival pairs.
- Right: Reconstructed all 12 journeys and drew their runs and endpoint platforms.
- Mistake: The first interpolation query failed on unquoted `at`; a later reconstruction query failed on unquoted `to`.
- Mistake: The search stopped after checking four-vehicle alternatives, with 8890 frontier labels remaining. The answer passed, but the trace does not establish exhaustive convergence.

**Code mode: failed.** Failed despite finding 12 journeys with the same arrival sequence as tool mode. Several reported boarding and departure times were one second early. ($0.81, 23 requests, 4.2 min)
- Right: Implemented a backward connection scan and departure/arrival dominance filtering.
- Right: Considered departures beyond the requested window before selecting the 12 results.
- Right: Generated all journey paths and platform markers.
- Mistake: In `interp`, `arr[i]=t; dep[i]=t` made an interpolated stop eligible for the next `while arr[a] is None` anchor search. It should have located anchors using the original nonempty timetable fields.
- Mistake: Consequently reported `R77afbc0f+4` departing at 25326 instead of 25327, `Re2a12a4f+3` boarding at 27113 instead of 27114, and `R023e7fca+2` boarding at 27316 instead of 27317.
- Mistake: Two `run_code` calls failed on unsupported `time.time()` and unavailable `OrderedDict`; both were removed.
- Mistake: Loaded the main timetable directly from files rather than through `run_sql`.

### meeting_point

**Tool calling: passed.** Passed by selecting Albertplatz, `Sbb9212fa`, at 33701. The friends arrived on `Rc0124950` at 33701 and `Rfa439a34` at 33692. ($0.77, 22 requests, 3.9 min)
- Right: Computed reachability separately from both origins and compared station-level arrival times.
- Right: Checked additional routing rounds and reconstructed two direct rides.
- Right: Drew both journeys with the boarding and alighting platforms marked.
- Mistake: The first interpolation-table query failed because `at` was unquoted; the retry renamed it `a`.

**Code mode: passed.** Passed with the same Albertplatz meeting at 33701 and the same two direct rides as tool mode. ($0.49, 16 requests, 2.7 min)
- Right: Searched from both origins and minimized the maximum of their station arrival times.
- Right: Repeated the search with ten rounds after initially using six.
- Right: Checked the selected runs and generated both SVG polylines.
- Mistake: The interpolation loop reused already-filled `times` entries as anchors; this latent defect did not invalidate the reported result.
- Mistake: SVG preparation attempted to unpack five-value tuples into four variables, causing `ValueError`; it recovered by selecting tuple element zero.
- Mistake: Loaded timetable files directly with Python after preliminary SQL counts, contrary to the prescribed loading workflow.

### timed_tour

**Tool calling: passed.** Passed with five vehicle legs and return at 44160. The visit order was Prohlis, Technische Universität, Pohlandplatz, then Mickten. ($1.26, 21 requests, 6.7 min)
- Right: Compared visit orders using opening-time-constrained departure states.
- Right: Returned visit intervals satisfying the 900-second stays and opening windows.
- Right: Included the walk before boarding `Rf679205e+8` and drew all five vehicle legs.
- Mistake: An initialization batch failed on `at IS NULL`; the next call referenced the consequently missing `c1` table.
- Mistake: The search was spread across large, manually repeated SQL blocks, contributing to the $1.2645 cost.

**Code mode: passed.** Passed with the same visit order and 44160 return as tool mode. It boarded the first run earlier at Altmarkt, at 32743. ($0.73, 23 requests, 4.1 min)
- Right: Used visit-state dynamic programming with opening windows and 900-second stays.
- Right: Reconstructed and checked five vehicle legs and visit departure times.
- Right: Recovered from a service absent from `services.txt` by checking changes and using `svc.get`.
- Mistake: Service expansion initially raised `KeyError: V3db19490`; a later timing measurement failed because `time.time()` was unsupported.
- Mistake: The interpolation loop reused filled `arr` entries as anchors. The final answer passed despite this preprocessing defect.
- Mistake: Loaded the timetable directly from files rather than through `run_sql`.

### tour

**Tool calling: failed.** Failed after returning an 11-leg tour arriving at 50012. It checked the selected rides and visit durations, but its search used restrictions that did not establish the requested earliest return. ($2.22, 39 requests, 10.6 min)
- Right: Built subset-based visit states and retained platform information.
- Right: Checked all 11 selected legs against timetable times, access flags, and stop order.
- Right: Verified transfer distances and produced an SVG containing every leg and endpoint.
- Mistake: In `arr0` and subsequent routing blocks, imposed unrequested limits including `d.bt<=r.rdy+1800`, four ride rounds, and 4200/5400-second segment horizons. These can discard valid alternatives; it should have used proven bounds or searched to convergence.
- Mistake: In `st1` and later state pruning, treated `earlier_arrival + platform_walk <= later_arrival` as sufficient dominance without preserving whether another walk would be needed before boarding. Under the single-walk rule, that is not a generally safe replacement.
- Mistake: The first interpolation query failed on unquoted `at`. The supplied result has no reference optimum or grader explanation, so the exact rejecting condition cannot be isolated.

**Code mode: failed.** Failed with a 12-leg tour returning at 48660. It explored several routing formulations, but finalized the original station-based result without resolving the differences or independently validating interpolated times. ($0.99, 25 requests, 5.2 min)
- Right: Implemented subset dynamic programming over all five visits.
- Right: Checked access flags, repeat indices, transfer distances, and reported visit durations.
- Right: Investigated platform-sensitive routing after observing different walking distances within a station.
- Mistake: In `build`, reused newly interpolated `arr` entries as timing anchors, the same defect that demonstrably corrupted `departure_profile`. Later `check(L)` validated against that same `built` timetable, so it could not detect the error.
- Mistake: The original visit validation used `minwalk_station`: 288 seconds before boarding at 38400, although its diagnostic found 339 seconds from the actual arrival platform. The platform-specific search returned 50012, but the final answer retained the original `alllegs` without resolving the modelling discrepancy.
- Mistake: Should have rebuilt times from original timed anchors and reconciled visit-platform semantics before selecting and independently checking the final route. The supplied result does not identify the exact grader rejection.
- Mistake: Also encountered unsupported `time.time()` and loaded the timetable directly instead of through `run_sql`.
