---
title: "Claude Fable 5.1 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 90%; rank 1 of 32."
canonical: https://models.pydantic.dev/models/claude-fable-5.1/transit_planner/
---

# Claude Fable 5.1 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 90%; rank 1 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/claude-fable-5.1/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.1.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $9.99 | 201      | 197        | 24.2 min |
| Code mode    | 90%   | 9 of 10      | $7.72 | 142      | 132        | 20.5 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gateway/anthropic:claude-fable-5-1` passed 19/20 runs: 10/10 in tools mode and 9/10 in code mode. The sole failure was a silent SQL data-loss bug, not a provider failure. These results favor tools mode for observed correctness, with code mode offering lower aggregate cost.

#### Where it does well

Both modes solved overnight travel, arrival deadlines, departure profiles, meeting points, walking transfers, and both tours. They recovered the same 12 departure/arrival frontier pairs and the same tour return times, `44160` and `48660`.

The model generally handles interpolation, repeat identifiers, boarding restrictions, and `120 + walk` transfer margins. It also investigates suspicious results: tools-mode `one_change` compared row and non-null counts; code-mode `after_midnight` repaired service-day identity; code-mode `one_vehicle` recovered missing repeats after checking truncation. Every run produced an SVG, including the failed route.

#### Mistakes it makes

All 10 tools runs and four code runs encountered SQL errors involving unquoted `at`. Five code runs attempted unsupported `time.time()`. Recovery sometimes assumed tables existed after a failed multi-statement call, causing additional errors.

The decisive failure was `k*every` after a nullable repeat join. In code-mode `one_change`, non-repeating runs retained rows but lost their times, yielding arrival `28800` instead of `28440`. Tools mode caught and fixed the identical bug with `COALESCE(every,0)`.

Both overnight runs initially conflated service days. Code mode repaired the key; tools mode submitted a valid route despite contaminated intermediate candidates. Five passing code runs also bypassed the handbook’s `run_sql` loading requirement by parsing files directly.

#### Tool calling compared with code mode

Code mode used 142 requests versus 201, about 29% fewer, and cost `$7.7183` versus `$9.9924`, about 23% less. It used fewer requests in eight pairs, tied one, and used more for `after_midnight`.

The largest gain was `tour`: 14 versus 36 requests and `$0.8317` versus `$2.9764`. Python loops and reusable searches reduced repeated SQL generation, but fewer requests did not guarantee better validation.

## Runs

### one_vehicle

**Tool calling: passed.** Passed with a `399`-second initial walk and bus `R27f8d4b1+2`, boarding at `29940` and arriving at `30480`. Reported journey departure as `29940-399=29541`. ($0.51, 16 requests, 77 s)
- Right: Searched boarding and alighting platforms within `400` metres while retaining the one-vehicle constraint.
- Right: Confirmed that no ride connected the two stations without walking.
- Right: Verified the repeat interval `1200` and used the correct `+2` offset of `2400` in the final inspection.
- Mistake: `count(at)` caused the multi-statement preparation call to fail; the next call queried nonexistent `seq3` before rebuilding the tables.
- Mistake: A diagnostic query initially applied `1200` rather than `2400` to `R27f8d4b1+2`; the following query corrected it.
- Mistake: Multiple `SELECT` statements again discarded an earlier result and required another call.

**Code mode: passed.** Passed with `R27f8d4b1+2`, a `399`-second initial walk, and arrival `30480`. Recovered from treating a truncated repeat lookup as complete. ($0.53, 11 requests, 69 s)
- Right: Used SQL to identify reachable platforms and candidate services, then inspected individual runs.
- Right: Noticed `repd.get('R27f8d4b1')` was missing and checked the response’s `truncated` flag.
- Right: Requeried repeats for the candidate runs and recovered boarding time `29940` and journey departure `29541`.
- Mistake: `SELECT run, every, count FROM repeats` returned only 200 rows with `truncated=True`, but the next calculation treated it as complete. This initially made the earliest candidate appear at `64685`.
- Mistake: The interpolation loop used already-filled `arr` values to choose preceding anchors. Consecutive untimed stops should retain the original timed anchors rather than reuse rounded interpolations; this did not prevent the accepted result.

### saturday_direct

**Tool calling: passed.** Passed with tram `Rb28d92d7`, boarding `P7fa04a55` at `33484` and reaching `P1093f876` at `34560`. ($0.52, 14 requests, 74 s)
- Right: Selected Saturday services using weekday bit `32` and expanded `6852` run instances.
- Right: Computed the interpolated boarding time and checked walking and two-vehicle alternatives for an earlier arrival.
- Right: Drew the ride through intermediate platform coordinates.
- Mistake: The initial interpolation query failed on unquoted `at`; the retry used `t_at`.
- Mistake: Repeat expansion generated `10000` candidate indices per base run before filtering by the actual repeat count, an unnecessarily broad expansion.

**Code mode: passed.** Passed with `Rb28d92d7` from `33484` to `34560`. Repaired a join that initially omitted all repeated instances. ($0.69, 11 requests, 1.7 min)
- Right: Selected five active Saturday services and expanded 6852 run instances.
- Right: Checked one-, two-, and three-vehicle searches plus destination walks.
- Right: Created the SVG path from queried intermediate coordinates.
- Mistake: The first preparation batch failed on unquoted `at`.
- Mistake: The initial expansion joined with `a.run = CASE WHEN a.k=0 THEN c.run ELSE split_part(a.run,'+',1) END`, excluding suffixed runs and yielding only `48428` calls.
- Mistake: Corrected the join to `c.run = split_part(a.run,'+',1)`, restoring `160366` calls before routing.

### one_change

**Tool calling: passed.** Passed with `Rafeef850` and `R620ec7d9`, departing at `27669` and arriving at `28440`. Crucially, it detected and repaired the same null-expansion bug that caused the code-mode failure. ($0.55, 17 requests, 83 s)
- Right: Compared `count(*)` with `count(arr)` after expansion: `233358` versus `169624` exposed missing times.
- Right: Rebuilt `tt` with `k*coalesce(every,0)`, restoring all `233358` arrival values.
- Right: Found the `72`-second transfer and verified `27960 + 120 + 72 <= 28200`.
- Mistake: The first preparation query failed on unquoted `at`.
- Mistake: The first repeat expansion used `arr+k*every` after a `LEFT JOIN`, making non-repeating runs’ times `NULL`. The explicit completeness check prevented this from affecting the final answer.

**Code mode: failed.** Failed by returning arrival `28800`, 360 seconds later than the valid `28440` journey. The submitted rides were feasible, but the search silently excluded non-repeating services. ($0.82, 15 requests, 1.9 min)
- Right: Read the rules, modeled initial and final walks, and enforced the two-vehicle limit and transfer margin.
- Right: Verified the submitted `Re01494c3+4`/`R156a8ca5` route and eventually wrote its SVG.
- Mistake: In `CREATE TABLE ex`, `c.arr + k*every` and `c.dep + k*every` followed a `LEFT JOIN repeats`. For non-repeating runs, `every` was `NULL`, so even `k=0` erased their times. Checking only `count(*)=233358` missed this.
- Mistake: It should have used `COALESCE(every,0)` and compared `count(arr)`/`count(dep)` with `count(*)`. Tools mode made this exact repair and found `Rafeef850` at `27669`, followed by `R620ec7d9`, arriving at `28440`.
- Mistake: Earlier calls failed on unquoted `at`, invalid `IGNORE NULLS` placement, and a retry against nonexistent `c2`.
- Mistake: SVG preparation selected nonexistent `pl.name`, then accessed `r['rows']` without checking the SQL error, causing `KeyError: rows`; this was repaired.

### walking_change

**Tool calling: passed.** Passed with `R76d2117b+4` and `R3a0dccd4+54`, departing at `61560` and arriving at `63480`. Changed at Pirnaischer Platz. ($0.67, 22 requests, 1.7 min)
- Right: Included the `78`-second platform walk: readiness was `62040+120+78=62238`, before departure `62520`.
- Right: Checked destination walks and a third vehicle round for improvements.
- Right: Verified the selected runs and produced the required SVG.
- Mistake: Used unquoted `at` during preparation, then repeated the reserved-word error in `at + 120` when building `s1`.
- Mistake: The coordinate query requested `name` from `plat`, which did not contain it; the corrected query omitted that column.

**Code mode: passed.** Passed with departure `61560` and arrival `63480`, using the same runs as tools mode but transferring from Prager Straße to Altmarkt. ($0.55, 14 requests, 1.5 min)
- Right: Built 12660 walking links and scanned 52045 connections.
- Right: Explicitly verified the `341`-second walk and transfer feasibility: `61920+120+341=62381 <= 62458`.
- Right: Checked boarding/alighting indices and `YY` access against the selected trips before drawing the SVG.
- Mistake: Separate calls failed on unsupported `time.time()` and unavailable `datetime.date.timetuple()`; it then used the supplied day `2026-338` and Friday bit `16`.
- Mistake: Reread and parsed timetable files with `Path.read_text()` after SQL initialization, contrary to the required loading workflow.

### after_midnight

**Tool calling: passed.** Passed with `R93fefd15` followed by `R900bf42f+2`, departing at `5280` and arriving at `6420`. Correctly used the previous Friday’s service with a `-86400` offset. ($0.90, 17 requests, 2.0 min)
- Right: `run_sql` interpolated untimed stops and verified the selected runs’ service-day offsets.
- Right: The Südhöhe transfer allowed `76` seconds walking plus `120` seconds interchange: `5492 + 76 + 120 = 5688`, before departure at `5700`.
- Right: `write_file` created `/out/journey.svg` with both runs and all four endpoint platforms.
- Mistake: The first `CREATE TABLE cb` failed on unquoted `at`; the retry renamed it `att`.
- Mistake: In `ev`, service-day identity was discarded, and subsequent joins used only `a.run=b.run`. This produced impossible candidates, including departure `91680` followed by arrival `5492`. The final selected journey was valid, but the search should have joined on run and service day.

**Code mode: passed.** Passed with the same `5280–6420` journey as tools mode, after repairing service-day collisions. Required 22 requests and `$1.2630`, more than tools mode. ($1.26, 22 requests, 3.0 min)
- Right: Used `run_sql` for loading and paginated results through `asyncio.gather`.
- Right: After detecting an impossible reconstructed ride, changed the internal key to `inst || '@' || day`.
- Right: Reloaded `19263` calls, checked that no connection arrived before departure, and recovered the valid two-leg journey.
- Mistake: The initial interpolation SQL failed on unquoted `at`.
- Mistake: The first `evw` and Python `byinst` grouped both service days under the same run name. Searches first returned `8400`, then reconstructed a ride departing at `4380` and arriving at `4158`.
- Mistake: Service-day identity should have been retained from the initial expansion; repairing it required rebuilding and downloading the timetable again.

### arrive_by

**Tool calling: passed.** Passed with the latest departure `63360` and arrival `64440`, before the `64800` deadline. Used `R1aabe4da+29` and `Rfd6f9e2d+67`. ($0.61, 15 requests, 90 s)
- Right: `run_sql` ranked candidates by `l1.dep - l1.od DESC`, accounting for initial walking.
- Right: Included the `64`-second transfer walk and checked three-vehicle alternatives departing after `63360`; none were returned.
- Mistake: The initial timetable-building query failed because it used `at` as an unquoted alias; the retry used `t_at`.
- Mistake: Twice issued multiple `SELECT` statements but received only the last result: services and later platform coordinates had to be queried again.

**Code mode: passed.** Passed with departure `63360` and arrival `64440`, matching tools mode. Completed in 11 requests. ($0.59, 11 requests, 1.5 min)
- Right: Used `run_code` to batch `run_sql` calls while retaining service exceptions, repeats, interpolation, and walking constraints.
- Right: Ranked by departure minus initial walking and checked three-vehicle alternatives leaving later.
- Right: Verified the `64`-second interchange walk and generated the SVG from platform coordinates.
- Mistake: The first `bcalls`/interpolation batch failed because `at` was unquoted; the following call quoted it and rebuilt the batch.

### departure_profile

**Tool calling: passed.** Passed with 12 nondominated journeys, from `(25327,27420)` through `(28620,30780)`. Each returned journey used two vehicles. ($0.91, 17 requests, 2.2 min)
- Right: `run_sql` expanded `233360` calls and applied a dominance test using later departure and no-later arrival.
- Right: Compared two- and three-vehicle candidates and obtained the same departure/arrival frontier.
- Right: Drew the returned journeys with their run identifiers.
- Mistake: The first `CREATE TABLE base` failed on the alias `at`; the retry used `att`.
- Mistake: The initial `j2` construction used `LEFT JOIN walks` and `COALESCE(wk.pb,l.ap)`, which omitted same-platform changes whenever walking neighbors existed. It correctly rebuilt `j2` using `xfer`, explicitly adding zero-distance self-transfers.
- Mistake: A broad departure-results query hit the 200-row limit before the model switched to a compact frontier query.

**Code mode: passed.** Passed with the same 12 departure/arrival pairs as tools mode, using different valid transfer platforms for some journeys. ($0.90, 17 requests, 2.6 min)
- Right: Implemented earliest-arrival search and cached evaluations in `EA(T)`.
- Right: Generated 622 candidate departures and binary-searched equal-arrival plateaus to find nondominated departures.
- Right: Removed the extra departure `28927`, outside the `25200–28800` window, and asserted reconstructed times matched the selected pairs.
- Mistake: The third `run_code` call failed on unsupported `time.time()`; it retried without timing.
- Mistake: After initially loading tables through `run_sql`, it reread and parsed timetable files with `Path.read_text()`, contrary to the handbook’s loading requirement.
- Mistake: Repeated platform-list construction and inspection after already obtaining the correct 2468 platforms.

### meeting_point

**Tool calling: passed.** Passed with Albertplatz (`Sbb9212fa`) at `33701`. The friends arrived on `Rc0124950` at `33701` and `Rfa439a34` at `33692`. ($0.86, 21 requests, 2.3 min)
- Right: Propagated arrival labels for both origins and minimized the maximum of their station arrival times.
- Right: Checked a fourth routing round; its earliest improvements, `34894` and `34920`, were later than the chosen meeting.
- Right: Verified both final rides and their `YY` access.
- Mistake: Timetable preparation first failed on unquoted `at`, then repeat expansion failed on ambiguous `every`; both were repaired.
- Mistake: The final `write_file` placed `P291e54d3` at `y=271.1`, although its queried northing `11521` gives `600-11521/35≈270.8`. The benchmark still passed.

**Code mode: passed.** Passed with Albertplatz at `33701`, matching tools mode. Simplified an initially circuitous reconstructed journey to one tram per friend. ($0.74, 13 requests, 2.1 min)
- Right: Ran connection scans from both origins and ranked stations by `max(st1[s],st2[s])`.
- Right: Inspected `Rc0124950` and replaced an unnecessary ride to Mordgrundbrücke with boarding directly at Waldschlößchen at `33300`.
- Right: Generated coordinates programmatically, including `P291e54d3` at `y≈270.8`.
- Mistake: The initial timing call used unsupported `time.time()`.
- Mistake: Reread the timetable directly with `Path.read_text()` after SQL loading, bypassing the required `run_sql` loading workflow.
- Mistake: The first reconstruction used two rides for friend one even though waiting for `Rc0124950` at the origin achieved the same arrival; this was corrected before submission.

### timed_tour

**Tool calling: passed.** Passed with six vehicle legs and return time `44160`. Visited Prohlis, Technische Universität, Pohlandplatz, then Mickten, respecting the visit windows. ($1.49, 26 requests, 3.7 min)
- Right: Accounted for departure walks in visit times, including `38312-44=38268` at Technische Universität and `40560-82=40478` at Pohlandplatz.
- Right: Scheduled Mickten from `42300` until `43241`, satisfying its opening time and 900-second stay.
- Right: Checked faster alternatives on several individual sections and wrote all six legs to the SVG.
- Mistake: Preparation failed on unquoted `at`, then retried against nonexistent `c1`; the complete preparation was subsequently rerun.
- Mistake: A station-pair query referenced nonexistent `a.code` and `b.code`, then corrected them to `sa.code` and `sb.code`.
- Mistake: The visible search pursued one visit order and checked selected sections, rather than comparing all 24 orders. Its accepted result does not make that search an exhaustive optimality proof.

**Code mode: passed.** Passed with five vehicle legs and return time `44160`, matching tools mode with one fewer vehicle. Enumerated all 24 visit orders. ($0.79, 14 requests, 2.1 min)
- Right: Applied `setoff=max(arr,opening)+900` and rejected orders whose stay exceeded closing time.
- Right: Found the winning order Prohlis → Technische Universität → Pohlandplatz → Mickten; the next feasible order returned at `45960`.
- Right: Found bus `Rf679205e+8` via a `117`-second walk from Prohlis, reaching Technische Universität at `37080`.
- Mistake: Loaded timetable files entirely through `Path.read_text()` rather than the required `run_sql`.
- Mistake: An early `time.time()` call failed in the sandbox and was removed.
- Mistake: `expand_run` selected preceding anchors from the mutable `times` array, allowing previously interpolated stops to become anchors. It should have retained the original timed-stop mask; the final result nevertheless passed.

### tour

**Tool calling: passed.** Passed with 11 vehicle legs, five visits, and return time `48660`. This was the most expensive run: 36 requests and `$2.9764`. ($2.98, 36 requests, 6.9 min)
- Right: Used SQL dynamic programming over visited subsets and last station, adding `900` seconds before each onward search.
- Right: Compared return times for all possible final visit stations and selected Wasaplatz.
- Right: Reconstructed and checked all 11 legs, including the final `317`-second walk before `R5771ad39+5`.
- Mistake: The initial `count(at)` query failed and had to quote `"at"`.
- Mistake: Repeated large, nearly identical four-round routing SQL blocks for successive subset sizes and then reran routing for reconstruction. This accounted for substantial request and token overhead.
- Mistake: The routing subroutine imposed four vehicle rounds and a `7200`-second boarding horizon without a visible proof that those bounds preserved every alternative.

**Code mode: passed.** Passed with five visits and return time `48660` in 14 requests. Returned 12 vehicle legs, versus tools mode’s 11. ($0.83, 14 requests, 2.9 min)
- Right: Implemented dynamic programming keyed by `(mask,last_idx)` and earliest-arrival searches between visits.
- Right: Separated vehicle-arrived and walked labels to prevent consecutive walking links.
- Right: Compared all five possible final visit stations and reconstructed the winning order and SVG.
- Mistake: The early timing call failed on unsupported `time.time()`.
- Mistake: After SQL initialization, directly parsed files with `Path.read_text()`, bypassing the handbook’s loading requirement.
- Mistake: The final section added `R6a6680a8+4` before `R5771ad39+5`; tools mode achieved the same return by walking `317` seconds. This extra ride was unnecessary, although minimizing vehicle count was not the objective.
