---
title: "GPT-6 Astra 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 100%; rank 1 of 32."
canonical: https://models.pydantic.dev/models/gpt-6-astra/transit_planner/
---

# GPT-6 Astra 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 100%; rank 1 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/gpt-6-astra/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/gpt-6-astra.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $5.02 | 175      | 177        | 14.7 min |
| Code mode    | 100%  | 10 of 10     | $4.01 | 135      | 135        | 12.8 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gateway/openai:gpt-6-astra` passed all 20 runs: 10/10 in each mode. Both modes produced matching optimal arrival or meeting times, including the 12-journey departure profile. All runs read `/data/DATA.md` first and produced the required SVG. These results support strong task completion, although every run needed error recovery.

#### Where it does well

It translates detailed timetable rules into executable searches: distance-based interpolation with `ceil` and `floor`, repeated-run identities, service calendars, boarding restrictions, walking limits and transfer margins. Both after-midnight runs correctly applied `-86400` to previous-day services.

The more complex objectives also succeeded in both modes: backward latest-departure routing, departure/arrival dominance, two-person meeting optimization, and tours with visit masks and opening windows. Searches generally continued to zero improvements instead of accepting the first feasible answer. Code-mode tour additionally checked recovered visit durations and transfers.

#### Mistakes it makes

All 20 runs initially used unquoted `at` in SQL and recovered from parser errors. Four additional error responses involved an extra parenthesis, ambiguous `w`, reserved alias `offset`, and an unterminated Python string. None caused a final failure; no provider failures occurred.

Tools mode repeatedly bundled several result-producing `SELECT`s even though only the last result returned, causing avoidable repeat queries. Code mode sometimes requested truncated nested values, used fixed iteration counts, or continued after convergence. Its meeting search happened to converge on the sixth and final scheduled round.

#### Tool calling compared with code mode

Code mode used 135 model requests versus 175, a 22.9% reduction, and cost $4.0064 versus $5.0223, 20.2% less. It used fewer requests in eight cases, tied one and used more in one; it was cheaper in eight cases.

Python loops and generated SVGs usually reduced orchestration. Exceptions matter: departure profile made seven separate relaxation calls and cost more, while tour performed 325 paginated SQL reads despite fewer model requests. Code mode improves aggregate efficiency here, without eliminating SQL mistakes or guaranteeing less underlying tool work.

## Runs

### one_vehicle

**Tool calling: passed.** Passed with a 399-second initial walk to Strehlener Platz and one ride, `R27f8d4b1+2`, arriving at 30480. ($0.25, 11 requests, 44 s)
- Right: Restricted interpolation to runs connecting reachable starting and ending platforms.
- Right: Included previous-day service instances and expanded repeats before comparing arrival times.
- Right: Selected boarding at `P0091960a` at 29940 and alighting at `P6e8c05a2` at 30480.
- Mistake: The initial walking-table batch failed because its diagnostic query used `max(at)`.
- Mistake: A later batch again hid the maximum-time result behind other queries, requiring a separate `SELECT max("at")`.
- Mistake: The final initial-walk lookup was also hidden by the following coordinate query.

**Code mode: passed.** Passed with the same initial walk and single vehicle as tools mode, arriving at 30480 in nine requests. ($0.26, 9 requests, 38 s)
- Right: Reduced interpolation to 72 candidate runs connecting reachable origin and destination platforms.
- Right: Selected the 399-second walk to `P0091960a`, then `R27f8d4b1+2` at 29940.
- Right: Generated the route and platform markers from query results.
- Mistake: The candidate-building batch failed because its diagnostic subquery used `max(at)`; it reran the batch and queried `max("at")` separately.
- Mistake: Despite two fewer model requests than tools mode, this run cost slightly more: $0.2577 versus $0.2533.

### saturday_direct

**Tool calling: passed.** Passed with direct run `Rb28d92d7`, boarding at 33484 and arriving at 34560. ($0.37, 15 requests, 55 s)
- Right: Applied Saturday service eligibility, expanded repeats and interpolated untimed calls.
- Right: Checked transfer alternatives after finding the direct journey and reached zero improvements.
- Right: Drew `P7fa04a55` to `P1093f876` with the correct run id.
- Mistake: The loading batch failed on `min(at)`.
- Mistake: The service-expansion query then failed because it used reserved word `offset` as an unquoted column alias; renaming it to `off` fixed the query.
- Mistake: The first improvement count was hidden behind another `SELECT`, so it queried the count again.

**Code mode: passed.** Passed with direct run `Rb28d92d7`, departing at 33484 and arriving at 34560, after recovering from two syntax errors. ($0.35, 12 requests, 64 s)
- Right: Expanded current and previous service days and applied service-change overrides.
- Right: Ran routing in a Python loop until zero improvements after five rounds.
- Right: Selected the one-leg solution and generated the SVG from its platform coordinates.
- Mistake: The fourth `run_code` call closed a triple-quoted SQL string with only two quotes, causing `SyntaxError: missing closing quote in string literal`.
- Mistake: After fixing Python quoting, the next call failed on SQL's unquoted `at`; the subsequent replacement quoted `"at"`.
- Mistake: The exploratory `DESCRIBE calls; SELECT * FROM services` returned only the service rows, discarding the schema output.

### one_change

**Tool calling: passed.** Passed with the best journey using at most two vehicles: `Rafeef850` and `R620ec7d9`, arriving at 28440. ($0.32, 13 requests, 48 s)
- Right: Compared one-vehicle and two-vehicle options while enforcing boarding/alighting permissions and distinct vehicle runs.
- Right: Correctly used interpolated departure 27669 and a 72-second platform walk; `27960 + 72 + 120 <= 28200`.
- Right: Wrote both vehicle legs and all four boarding/alighting platforms to the SVG.
- Mistake: The interpolation query failed on unquoted `at`; the replacement quoted it.
- Mistake: The two-leg query's result was hidden by a subsequent `SELECT`, and the coordinate query was similarly hidden by a line lookup. Both had to be repeated.

**Code mode: passed.** Passed with `Rafeef850` and `R620ec7d9`, arriving at 28440 in nine requests. ($0.28, 9 requests, 44 s)
- Right: Found the best one-vehicle arrival, 29160, and used it to bound the two-vehicle search.
- Right: Enforced distinct runs, permitted boarding/alighting and the 72-second walk plus 120-second margin.
- Right: Checked for a walking-only option and built the answer and SVG from the selected result.
- Mistake: The first interpolation batch failed on unquoted `at`. The corrected batch quoted `"at"` and also replaced the potentially problematic `offset` alias with `off`.

### walking_change

**Tool calling: passed.** Passed with `R76d2117b+4`, a walk from Prager Straße to Altmarkt, and `R3a0dccd4+54`, arriving at 63480. ($0.41, 17 requests, 65 s)
- Right: Applied the 400-metre walking limit and 120-second transfer margin.
- Right: The chosen transfer satisfies `61920 + 341 + 120 = 62381 <= 62458`.
- Right: Continued relaxation until zero improvements and verified the destination arrival.
- Mistake: The interpolation query failed at `CASE WHEN at IS NOT NULL`; quoting `"at"` repaired it.
- Mistake: Created and immediately dropped a dummy `r2` table before constructing the actual second-leg table.
- Mistake: The final batch returned only the destination result, requiring separate coordinate and line-information queries.

**Code mode: passed.** Passed with the same two vehicle legs and 63480 arrival as tools mode, using 11 requests. ($0.33, 11 requests, 55 s)
- Right: Executed six routing rounds in one Python loop, stopping at zero improvements.
- Right: Explicitly retrieved the 341-second Prager Straße–Altmarkt walk and respected the 120-second transfer margin.
- Right: Extracted scalar leg fields for the final answer and generated the SVG programmatically.
- Mistake: The first preparation batch failed on unquoted `at`; the replacement quoted it and used `arr` for derived times.
- Mistake: Requested the complete path as `to_json(a.path)`, which was truncated despite `truncated:false`. It recovered through `unnest(path)` and then scalar columns; selecting scalar fields initially would avoid the extra calls.

### after_midnight

**Tool calling: passed.** Passed with two buses, departing at 5280 and arriving at 6420. Correctly used the previous service day's timetable for both legs. ($0.48, 17 requests, 63 s)
- Right: `run_sql` expanded `2026-338` with offset `-86400`, retained service-day identity in ride joins, and generated repeat ids such as `R900bf42f+2`.
- Right: Found `R93fefd15` followed by `R900bf42f+2`; the transfer satisfies `5492 + 76 + 120 <= 5700`.
- Right: Continued relaxation until improvements reached zero and wrote `/out/journey.svg` with the required platform and run attributes.
- Mistake: During interpolation-table creation, `CASE WHEN at IS NOT NULL` caused a parser error; quoting `"at"` fixed it.
- Mistake: The initial loading query and later verification query bundled several `SELECT`s, but only the final result was returned. It repeated station, route and coordinate queries; separate result-producing calls would avoid this.

**Code mode: passed.** Passed with the same two-leg journey and 6420 arrival as tools mode, using 11 model requests. ($0.27, 11 requests, 57 s)
- Right: `run_code` read `/data/DATA.md`, then called `run_sql` to expand both service days with the previous day's `-86400` offset.
- Right: A Python loop ran six routing rounds; improvement counts ended at zero.
- Right: Extracted scalar leg fields, verified the 76-second transfer walk and generated the SVG programmatically.
- Mistake: The third `run_code` call used `SELECT min(at), max(at)` and received a parser error; quoting `"at"` fixed it.
- Mistake: The later `info` query placed the answer metadata before a walk query, so only the walk result returned; arrival metadata was fetched again.

### arrive_by

**Tool calling: passed.** Passed by searching backward from the 64800 deadline. Returned the latest departure, 63360, with arrival at 64500. ($0.44, 17 requests, 75 s)
- Right: Backward relaxation used `r.atime + w.dur + 120 <= b.bt` and maximized origin departure after subtracting initial walking time.
- Right: Returned `R1aabe4da+29` from `P10db34c8` at 63360, then `R54c1ee76+5` from `P6ea0167f` at 64320.
- Right: Continued until the improvement count reached zero.
- Mistake: The first interpolation query failed on unquoted `at`; its replacement then failed on the extra `)` in `FROM a) SELECT * FROM ci`. Both were repaired.
- Mistake: The final verification batch returned only line information, requiring separate queries for `unnest(legs)` and platform coordinates.

**Code mode: passed.** Passed with latest departure 63360 and arrival 64500, matching tools mode in 12 requests. ($0.32, 12 requests, 62 s)
- Right: Ran backward routing inside a Python loop, stopping after five rounds when improvements reached zero.
- Right: Subtracted walking and the 120-second margin for reverse transfers while treating initial walking separately.
- Right: Verified the 64-second platform walk and generated the SVG directly from extracted leg data.
- Mistake: The preparation SQL used unquoted `at` and failed. It inspected existing tables before rerunning corrected SQL.
- Mistake: Loaded all fields with `all_varchar=true`, then repeatedly cast numeric fields; typed loading would have made the SQL shorter.

### departure_profile

**Tool calling: passed.** Passed with all 12 nondominated journeys, from departure/arrival 25327/27420 through 28620/30780. ($0.52, 16 requests, 1.9 min)
- Right: Used recursive SQL with `USING KEY(st,place)` to retain earliest arrivals for each departure and platform.
- Right: Considered departures through 32400 before applying the requested 28800 cutoff, then removed dominated choices using `min(arrival) OVER (... ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING)`.
- Right: Extracted individual legs with `unnest(path)` and drew the profile's routes.
- Mistake: The preliminary `min(at)` query failed; subsequent queries quoted `"at"`.
- Mistake: After solving the profile, `SELECT min(w) FROM ow JOIN dw ...` failed because `w` was ambiguous. It should have qualified the intended column or expression; it instead dropped that check and separately retrieved coordinates.
- Mistake: Several exploratory batches returned only their final `SELECT`, prompting repeated reads.

**Code mode: passed.** Passed with the same 12 journeys as tools mode, but used more requests and cost more: 19 requests and $0.5397. ($0.54, 19 requests, 1.9 min)
- Right: Tracked labels by departure and platform, considered departures beyond 08:00, and applied the later-departure dominance window before filtering to 28800.
- Right: Reached zero improvements and extracted all 24 legs as scalar rows.
- Right: Checked that previous-day expanded services ended by 18480, before the profile's start.
- Mistake: The preparation query failed on unquoted `at`; the replacement quoted it and renamed derived times to `arr`.
- Mistake: After defining `step_sql`, invoked it in seven separate `run_code` calls instead of looping to convergence in one call. This forfeited a principal code-mode efficiency benefit.

### meeting_point

**Tool calling: passed.** Passed with Albertplatz (`Sbb9212fa`) as the earliest meeting station at 33701. The friends arrive at 33701 and 33692. ($0.41, 17 requests, 75 s)
- Right: Maintained reachability by `who` and platform, then ranked stations by `greatest(a.t,b.t)`.
- Right: Included the first friend's 353-second initial walk to `P3035f403`, followed by `Rc0124950`; the second takes `Rfa439a34`.
- Right: Pruned to the candidate meeting time and continued until no earlier platform labels remained.
- Mistake: The loading batch failed at `min(at)`; it recovered with `min("at")`.
- Mistake: Repeatedly placed `SELECT ... FROM chosen` before another `SELECT`, losing its output. It finally issued that query alone to confirm both final walks were zero.

**Code mode: passed.** Passed with Albertplatz at 33701 and the same two journeys as tools mode, using 11 requests. ($0.36, 11 requests, 69 s)
- Right: Tracked both passengers, allowed initial walking without a transfer margin, and ranked meeting stations by the later arrival.
- Right: Executed six SQL relaxation rounds in one Python call; the last returned zero improvements.
- Right: Retrieved the initial walking options and drew both vehicle journeys programmatically.
- Mistake: The loading batch failed at `max(at)` and was rerun with `max("at")`.
- Mistake: The routing loop used fixed `range(6)` rather than stopping on convergence. It happened to reach zero improvements on exactly the sixth round; an explicit convergence check would make termination robust.

### timed_tour

**Tool calling: passed.** Passed with a five-leg tour returning at 44160, visiting Prohlis, Technische Universität, Pohlandplatz and Mickten in that order. ($0.69, 16 requests, 2.4 min)
- Right: Used recursive state `USING KEY(mask,p,mode)` to track visited stations and boarding readiness.
- Right: Applied opening windows with `greatest(arrival,op) + 900 <= cl`.
- Right: Reported visit departures accounting for subsequent walks: 35493, 38244, 40478 and 43241.
- Right: Returned five vehicle legs and generated the requested SVG.
- Mistake: The large preparation batch failed on unquoted `at`; it checked `SHOW TABLES` and reran corrected SQL.
- Mistake: Service, coordinate and walking checks were repeatedly hidden by later `SELECT`s in the same call. Separate calls eventually recovered the required results.

**Code mode: passed.** Passed with five legs and return at 44160. It boarded the first run at Altmarkt at 32743 after a 257-second initial walk. ($0.54, 16 requests, 2.1 min)
- Right: Tracked visit masks and transfer margins, requiring `greatest(b.a,v.op)+900 <= v.cl`.
- Right: Computed visit departure as the next vehicle's departure minus its initial walk.
- Right: Recovered all actions, verified the initial walking platform and generated the SVG programmatically.
- Mistake: The preparation batch failed on unquoted `at`; `re.sub(r'\bat\b','"at"',q)` repaired it.
- Mistake: A preliminary `SELECT list(ref)` produced a truncated string rather than a usable list.
- Mistake: The final fixed three-round batch returned zero changes in all three rounds, performing two unnecessary iterations after convergence.

### tour

**Tool calling: passed.** Passed with an 11-leg tour visiting all five stations and returning to Hauptbahnhof at 48660. This was the most expensive tools run: 36 requests and $1.1392. ($1.14, 36 requests, 3.4 min)
- Right: Represented visits with a five-bit mask and used `relax()` over `(mask,node)` labels.
- Right: Added 900 seconds per visit, included walking in station departure calculations, and pruned with `(5-bit_count(mask))*900`.
- Right: Continued until the frontier was empty, then checked leg access permissions and potentially omitted calls spanning the start time.
- Mistake: The preliminary statistics query failed on `WHERE at IS NULL`; later SQL quoted `"at"`.
- Mistake: Many nearly identical relaxation calls required separate model requests; recursive SQL could have reduced orchestration overhead.
- Mistake: Multiple verification batches discarded earlier result sets and required repeat queries.
- Mistake: The `active` table used weekday/date filtering without service-change overrides. The inspected changes concerned other dates, so this shortcut did not affect this case.

**Code mode: passed.** Passed with a 12-leg tour returning at 48660, matching tools mode's optimal return time. It used 25 model requests and $0.7567. ($0.76, 25 requests, 2.3 min)
- Right: Loaded 2468 platforms, 47026 calls and 15128 walking edges through paginated `run_sql` calls.
- Right: Used a Python chronological event scan with 32 visit masks, onboard state, 900-second visits and walking-aware departures.
- Right: Checked the omitted call spanning 36000 and established that its platform was not reachable from the origin.
- Right: Verified visit durations and transfers before generating the final SVG.
- Mistake: The initial timetable expansion failed on unquoted `at`; the replacement quoted it.
- Mistake: Fetching platforms, calls and walks required 325 paginated SQL reads, batched with `asyncio.gather`; fewer model requests did not mean fewer underlying tool calls.
- Mistake: The returned route includes extra run `R6a6680a8+4` compared with the 11-leg tools solution. This is valid because the objective minimized return time, not vehicle count.
