---
title: "Claude Opus 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 90%, code mode 100%; rank 10 of 32."
canonical: https://models.pydantic.dev/models/claude-opus-5.5/transit_planner/
---

# Claude Opus 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 90%, code mode 100%; rank 10 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/claude-opus-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-opus-5.5.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 90%   | 9 of 10      | $2.64 | 156      | 170        | 13.7 min |
| Code mode    | 100%  | 10 of 10     | $1.97 | 108      | 98         | 11.1 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`claude-opus-5-5` passed 19 of 20 runs: 9/10 with tool calling and 10/10 in code mode. Arrival times were right in all 20 runs, including the one failure, which had the correct arrival (6420) but an invalid leg.

#### Where it does well

- **Real algorithms, not guesses.** It wrote round-based earliest-arrival searches in SQL, connection scans in Python, a backward search for `arrive_by`, and a bitmask dynamic programme in recursive CTEs for the tools `tour`.
- **Checks the result is final.** It re-ran extra rounds until the answer stopped moving (`walking_change`, `meeting_point`, `saturday_direct`) and tested the boundary in code-mode `arrive_by` (63360 works, 63361 arrives 64860).
- **Catches odd data.** Code mode noticed negative arrivals from two service days sharing a run id (`one_change`, `timed_tour`) and a 200-row truncation (`one_vehicle`).

#### Mistakes it makes

- **One silent SQL bug caused the only failure.** In tools `after_midnight`, `select c.*, p.e, p.n` put call position and north under the same name `n`, so the interpolation most likely used the wrong column. The evaluator rejected leg 3 (`R900bf42f+2` from `Pa3fba050` at 5820). The only sanity check was a row count.
- **Reserved words every time.** All 10 tools runs hit a parser error on unquoted `at`; `timed_tour` also hit `days`. Three runs then lost another request because the failed batch had rolled back its tables.
- **Rules skipped when they looked irrelevant.** 5 of 10 tools runs loaded no previous-day runs, and 9 of 10 ignored `service_changes`. None was punished on these dates.
- **Unproven optimum.** Tools `timed_tour` evaluated one of 24 visiting orders; it happened to be the best.
- **Clumsy journeys that still pass.** Code-mode `meeting_point` and `tour` each include an unnecessary extra leg.

#### Tool calling compared with code mode

Code mode was better on every measure: 10/10 against 9/10, 108 requests against 156, and $1.97 against $2.64. Writing the interpolation in Python removed the column-name hazard, and all 10 code runs handled both service days and `service_changes`. Its own failure modes were sandbox limits: `__import__` rejected (3 runs), a 256 MB memory crash (`departure_profile`), `time.time` unsupported (`tour`), and two runs that read `DATA.md` in 43 chunks of 190 characters through `run_sql`. Code mode cost more only on `one_change` and `one_vehicle`, where it mixed `run_sql` with Python.

## Runs

### one_vehicle

**Tool calling: passed.** Restricted `calls` to runs that link an origin-walkable platform to a destination-walkable one, interpolated those, and picked `R27f8d4b1+2` from Strehlener Platz, arriving 30480. Passed in 9 requests, the cheapest tools run. ($0.14, 9 requests, 38 s)
- Right: Pre-filtered to 1,829 calls on candidate runs (`rr`) before interpolating, which kept every query small.
- Right: Included the previous service day (`-86400` offset for day 335).
- Right: Applied the 399 m start walk in the boarding test `c1.dep+i.off>=29400+o2.w`.
- Mistake: Reported `departure` as 29400, the question's start time, rather than board time minus walk (29541, as code mode gave). It passed, but it is inconsistent with its own other answers.
- Mistake: Unquoted `at` parser error; one wasted request.
- Mistake: Added a `data-place="S6f32bdc5"` station marker to the SVG that the handbook does not ask for.

**Code mode: passed.** Mixed `run_sql` and Python: found 72 candidate runs, 34 active, fetched their calls and interpolated in Python, returning `R27f8d4b1+2` arriving 30480. Passed in 12 requests. ($0.14, 12 requests, 42 s)
- Right: Noticed `truncated: True` at 200 rows on the platform query and switched to an aggregate query instead of trusting partial data.
- Right: Reported `departure` 29541, board time 29940 minus the 399 m walk.
- Mistake: Unquoted `at` in SQL returned an error dict, which first showed up as `KeyError: truncated`; it needed an extra request just to print `r`. Two requests lost.
- Mistake: Fetched calls with 34 separate `run_sql` calls through `asyncio.gather` instead of one query.
- Mistake: 12 requests against 9 for the tools run on the same question.

### saturday_direct

**Tool calling: passed.** Built the Saturday timetable with Friday's overnight runs, ran three search rounds and returned the direct run `Rb28d92d7`, 33484 to 34560. Passed. ($0.18, 12 requests, 57 s)
- Right: Covered both service days (339 and 338 with `-86400`).
- Right: Ran rounds 2 and 3 to confirm no journey with changes beat the direct one at 34560.
- Mistake: Unquoted `at` parser error; one wasted request.
- Mistake: Created an unused `create macro dummy() as 1`, and pasted the same long round query three times instead of using a macro; 12 requests for a one-leg answer.

**Code mode: passed.** Loaded files in Python, built 380,170 connections for both service days and ran one scan, returning the direct run `Rb28d92d7` arriving 34560. Passed in 7 requests at $0.11, the cheapest run. ($0.11, 7 requests, 38 s)
- Right: No errors at all; every request advanced the task.
- Right: Checked for a walk-only option (`walkonly` was empty) before answering.
- Mistake: Built connections for every run on both days with no time filter; fine here but the same pattern exhausted memory in departure_profile.

### one_change

**Tool calling: passed.** Listed direct journeys (best 29160), then joined first legs to second legs to find a two-vehicle journey arriving 28440. Passed in 11 requests. ($0.16, 11 requests, 47 s)
- Right: Bounded the two-leg search by the best direct arrival (`a.arr<29160`), keeping the join small.
- Right: Ordered by `fin, d1 desc`, so the latest first departure among the best arrivals came first.
- Mistake: Unquoted `at` parser error, then `Table with name act does not exist` because the failed multi-statement batch had rolled back; it spent a request on `information_schema.tables` before re-running. Three requests lost.
- Mistake: Only day 337 with bit 8 was loaded; previous-day runs and `service_changes` were ignored.

**Code mode: passed.** Used `run_sql` from Python, found the direct best of 29160 and then a two-vehicle journey arriving 28440. Passed, but in 13 requests, more than the tools run. ($0.19, 13 requests, 55 s)
- Right: Spotted negative arrivals (`-57240`) caused by joining the two service days of one run on `run` alone, and fixed it by adding `a.off=b.off`.
- Right: Applied `service_changes` in the `act` table.
- Mistake: Read `DATA.md` through `run_sql` and `read_text`, got truncated output twice, then fetched it in 43 chunks of 190 characters. Three requests spent on what `Path.read_text()` did in one elsewhere.
- Mistake: Unquoted `at` parser error surfaced as `Table with name ev does not exist`; fixed with chained string `.replace()` calls on the SQL, which is brittle.
- Mistake: Final SVG coordinates were hand-typed into a dict rather than read from the data.

### walking_change

**Tool calling: passed.** Ran four search rounds to get the arrival 63480, then a two-leg join to pick the journey changing at Pirnaischer Platz with a 78 m walk. Passed. ($0.20, 13 requests, 59 s)
- Right: Confirmed 63480 held through rounds 2, 3 and 4 before reconstructing.
- Right: The final join tie-breaks `order by fin, d1 desc, w1`, picking the latest first departure and shortest walk.
- Mistake: Unquoted `at` parser error; one wasted request.
- Mistake: Active services were a hand-typed nine-id list for Friday; previous-day runs and `service_changes` ignored.
- Mistake: Created an unused `dummy()` macro and a request that returned nothing.

**Code mode: passed.** Not reviewed. ($0.14, 10 requests, 45 s)

### after_midnight

**Tool calling: failed.** Built the timetable in DuckDB, ran five rounds of a hand-rolled earliest-arrival search and back-traced a three-leg journey arriving 6420. The evaluator rejected it: `R900bf42f+2` does not depart `Pa3fba050` at 5820 and reach `P453df67b` at 6420. ($0.24, 21 requests, 74 s)
- Right: Handled the previous service day correctly with `(values (338,16,-86400),(339,32,0))`, so Friday's after-midnight runs were included.
- Right: Found the right arrival time, 6420, the same as the passing code-mode run.
- Right: Checked the 120 s + walk margin at both changes when back-tracing (`rt` 4713 \<= 4740, 5747 \<= 5820).
- Mistake: In the `c2` interpolation query (5th request) CTE `x` selects `c.*, p.e, p.n`, so the call position `n` and the north coordinate `n` share a name. The next CTE computes `sqrt((e-pe)^2+(n-pn)^2)`, which most likely binds `n` to the call position, so the along-run distance `s` and every untimed-call time are wrong. Every other tools run aliased north as `nn`, `no` or `y`. It should have aliased `p.n` here too.
- Mistake: The only check after building `c2` was `count(*), count(arr)`, which cannot catch wrong interpolated values. It never compared one untimed call against the formula by hand.
- Mistake: The back-trace query for the last leg returned a single boarding option, `Pa3fba050` at 5820, and it was accepted without checking whether that call was timed in `calls`.
- Mistake: First request used a `union all` with mismatched column counts and the `c2` query used unquoted `at`; two requests lost to errors.

**Code mode: passed.** Loaded the files in Python, built connections for days 338 and 339 and ran a connection scan, returning a three-leg journey arriving 6420. Passed in 9 requests where the tools run failed. ($0.13, 9 requests, 42 s)
- Right: Interpolation was written directly from the formula with integer `//`, with no column-name clash possible.
- Right: Handled `service_changes` and both service days in `runs_on`.
- Right: Rebuilt legs from parent pointers kept during the scan instead of separate back-trace queries.
- Mistake: First request used `__import__('pathlib')`, which the sandbox type checker rejects; one wasted request.
- Mistake: Ran the scan twice because the first version did not store parent legs.

### arrive_by

**Tool calling: passed.** Ran a backward latest-departure search in SQL from Lennéplatz with an 18:00 deadline and returned a two-leg journey leaving Pohlandplatz at 63360, arriving 64440. Passed. ($0.18, 13 requests, 54 s)
- Right: Chose a backward search (`A` = latest arrival per platform, `step()` macro) that fits the question, and ran rounds until the best departure stopped changing at 63360.
- Right: Aliased north as `nn`, avoiding the column clash that broke after_midnight.
- Right: Reconstructed both legs with one join that enforces `z.dep>=y.arr+120+w.w`.
- Mistake: `act` only covers day 2026-344 with weekday bit 8; previous-day runs past midnight and `service_changes` were ignored. Harmless at 17:36 but not checked.
- Mistake: Unquoted `at` caused a parser error on the first big query, and `select ref,name,e,n from pl` failed because `pl` had no `name` column; two wasted requests.

**Code mode: passed.** Binary-searched the latest start time with a forward connection scan, then verified 63360 works and 63361 arrives at 64860. Passed in 7 requests. ($0.13, 7 requests, 46 s)
- Right: Explicitly checked the boundary: `csa2(63360)` arrives 64440, `csa2(63361)[0]` is 64860, past the 18:00 limit.
- Right: Handled both service days and `service_changes`.
- Mistake: About 13 full scans for the binary search where one backward scan would do; cheap here but wasteful.
- Mistake: Weekday was computed with a hand-made table `[8,16,32,64,1,2,4][(d-1)%7]` rather than a date; correct for 2026 but fragile.

### departure_profile

**Tool calling: passed.** Computed earliest arrival for 209 candidate set-off times with four SQL rounds, picked the 12 non-dominated pairs and rebuilt each two-leg journey. Passed. ($0.34, 17 requests, 1.6 min)
- Right: The only tools run that applied `service_changes` and the previous service day when building `act`.
- Right: Computed set-off time as `tc.dep - o.w`, matching the question's definition of leaving the origin.
- Right: Looked past 08:00 (`s<=30600`) so later, faster departures could dominate earlier ones.
- Mistake: The 12 Pareto pairs were typed by hand into a `values` list (`sel`) after reading the table, instead of being filtered in SQL; a transcription slip would have gone unnoticed.
- Mistake: `cast(c.at as int) at` hit the reserved-word parser error; one wasted request.
- Mistake: Journeys were limited to two vehicles in the reconstruction join; it worked because every chosen pair had a two-leg option (1 or 7 matches each).

**Code mode: passed.** After a memory-limit crash, reloaded leaner data, ran a connection scan from each of 201 candidate set-off times and filtered the Pareto set in code. Passed in 10 requests. ($0.25, 10 requests, 77 s)
- Right: Recovered from `MemoryError: memory limit exceeded` by switching from dicts to tuples and keeping only calls of active services.
- Right: Dominance was filtered in code over all 201 results, not by eye as in the tools run.
- Right: Kept one journey per `(departure, arrival)` pair, as the question asks.
- Mistake: First load parsed all 163,359 calls into dicts and blew the 256 MB sandbox limit; one request lost and state reset.
- Mistake: Left a meaningless filter `if station[p]!='' or True`.

### meeting_point

**Tool calling: passed.** Ran three or four rounds of a two-origin search in SQL, ranked stations by `greatest(a.t,b.t)` and returned Sbb9212fa at 33701 with one direct leg per friend. Passed. ($0.22, 16 requests, 73 s)
- Right: Covered both service days with a `days` table for 338 and 339.
- Right: Re-ran two more rounds and confirmed the top five meeting stations did not change.
- Right: Chose a single-leg journey for the first friend, boarding `Rc0124950` at `Pda4a5390` in the origin station, simpler than the code-mode answer.
- Mistake: Unquoted `at` parser error on the first interpolation query; one wasted request.
- Mistake: The `ev` build contains a no-op `case when i.name like '%+%' then 0 else 0 end` and a comment `-- fix: off already includes k*every`; confused but harmless.
- Mistake: `service_changes` ignored.

**Code mode: passed.** Ran one connection scan per friend, took the station minimising the later arrival, and returned Sbb9212fa at 33701. Passed in 7 requests. ($0.15, 7 requests, 52 s)
- Right: Included the final walk when ranking stations (`st_arr`).
- Right: Top five stations match the tools run exactly.
- Mistake: The first friend's journey has an unneeded extra leg: `R465985dd` out to `P0c5c96dd`, then `Rc0124950` back, a run boardable at the origin station at 33300. Valid and same arrival, but a worse journey than the tools answer.
- Mistake: SVG has no `viewBox` or background; passed anyway.

### timed_tour

**Tool calling: passed.** Chained five earliest-arrival searches for one visiting order (Prohlis, TU, Pohlandplatz, Mickten) and returned a five-leg tour back at 44160. Passed with the most requests of any run, 24. ($0.46, 24 requests, 2.6 min)
- Right: Built reusable `rnd()` and `rdyn()` macros and ran six rounds per segment.
- Right: Visit departures subtract the walk to the next platform (e.g. 35493 = 35640 - 147), as the question defines.
- Mistake: Only one of the 24 visiting orders was evaluated; no query compares alternatives or tests the opening windows. The answer matches code mode's exhaustive result (44160), so this was unproven rather than wrong.
- Mistake: Three parser errors on reserved words (`at`, then `days`), then `Table with name places does not exist` after the failed batch; four requests lost before any data was loaded.
- Mistake: An ambiguous `k` column cost another request.
- Mistake: `act` covers only day 343; previous-day runs and `service_changes` ignored.

**Code mode: passed.** Wrapped a SQL round-based search in a Python `raptor()` function, then enumerated visiting orders level by level with the opening windows, returning a tour back at 44160. Passed in 18 requests. ($0.35, 18 requests, 2.3 min)
- Right: Actually searched the orders: the level loop kept 4, 10, 12, 5, 5 feasible states and ranked finishes (44160, 45960, 48960...), which the tools run never did.
- Right: Encoded the windows as `st0=max(a,o)` and `st0+900>c`, so waiting for opening is allowed.
- Right: Caught arrivals of `-55980` from day-342 and day-343 copies of a run sharing a `tid`, and fixed it by suffixing `#prev`.
- Mistake: Same `DATA.md` detour as one_change: truncated `read_text`, then 43 chunked `substr` queries.
- Mistake: Parser errors on `at` and then `days`, patched with string `.replace()`; two requests lost.
- Mistake: The `trace()` reconstruction issues several `run_sql` calls per leg.
- Mistake: First leg boards at `P9cd5b9a9` (Altmarkt) after a walk rather than in the start station; valid, just less natural than the tools answer.

### tour

**Tool calling: passed.** Solved the five-station round trip with a bitmask dynamic programme over visited sets, each layer a recursive-CTE search, giving an 11-leg tour back at 48660. Passed; the most expensive run at $0.52. ($0.52, 20 requests, 2.8 min)
- Right: Used a real exhaustive method (`states` table keyed by `mask`, `cur`) rather than guessing an order.
- Right: Carried a `path` string through the recursive CTE to recover legs and walks.
- Right: Result 48660 matches code mode's 120-permutation search.
- Mistake: Unquoted `at`, then `calls_raw does not exist` after the rolled-back batch, then an ambiguous `src`; three requests lost.
- Mistake: Services were hard-coded as a five-id list for Saturday; the previous service day and `service_changes` were left out.
- Mistake: Each DP layer re-pasted the full recursive CTE, making very long requests.

**Code mode: passed.** Built a memoised connection scan in Python and tried all 120 visiting orders (149 scans), returning a 12-leg tour back at 48660. Passed in 15 requests after four failed ones. ($0.37, 15 requests, 2.3 min)
- Right: Exhaustive over `itertools.permutations(T)` with a `(station, time)` memo, so the order is proven best under greedy legs.
- Right: After a failure it freed memory (`places=None`, `runs=None`) and restricted station bookkeeping to `KEEP`.
- Mistake: Four requests lost: `__import__` rejected by the type checker, `time.time` unsupported, a runtime error inside `csa` during the permutation loop, and a type-checker error on `arr[i]+int(...)`.
- Mistake: The last segment adds a 91-second hop `R6a6680a8+4` (47909 to 48000) before the final run, so the answer has 12 legs against 11 in tools for the same arrival.
- Mistake: `csa` uses a fixed `horizon=7200`; a leg longer than two hours would be missed silently.
