---
title: "Gemini 4 Argon 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/gemini-4-argon/transit_planner/
---

# Gemini 4 Argon 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/gemini-4-argon/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/gemini-4-argon.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $3.71 | 199      | 203        | 62.5 min |
| Code mode    | 100%  | 10 of 10     | $3.67 | 198      | 198        | 59.6 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gemini-4-argon` passed all 20 runs: 10 of 10 in tool calling and 10 of 10 in code mode. Both modes returned the same legs and times for every case. Total cost was $3.71 for tools (199 requests) and $3.67 for code mode (198 requests). The two tour cases account for about half of each total.

#### Where it does well

- **Reads the rules and applies them.** In every run it interpolated untimed calls from cumulative distance, expanded `repeats` into `<run>+<k>`, used `120 + walk` for changes, and allowed walks to platforms within 400 m. In `one_vehicle` that walk (399 s to `P0091960a`) is the only route to the answer.
- **Previous service day.** In both `after_midnight` runs it shifted day 2026-338 by `-86400`. Elsewhere it checked `max(at)` = 104880 before ignoring it.
- **Checks optimality.** 18 of 20 runs searched one or more legs beyond the answer before finalising.
- **Tours.** It enumerated visit orders exhaustively, in SQL (tools) or a Python DP (code mode).

#### Mistakes it makes

- **The `at` keyword.** 17 of 20 runs hit a DuckDB parser error on unquoted `at`. Each cost one request, or two in `arrive_by` (tools).
- **Multi-statement calls.** A failed batch creates nothing and a successful one returns only the last result. This caused missing-table errors in `meeting_point` (tools) and `tour` (code mode), and repeat queries elsewhere.
- **Over-verification.** `timed_tour` (tools, $1.17) and `tour` (tools, 45 requests) each spent 10 to 15 calls re-inspecting segments already chosen. One `tour` query hit the 30-second limit.
- **Lucky pass.** In `one_vehicle` (code mode) the Python interpolation crashed with `IndexError` and was never rerun. Untimed candidate runs went unchecked.
- **Bounded searches.** `timed_tour` (tools) never tested hops of more than 2 vehicles.

#### Tool calling compared with code mode

Code mode brought no gain in accuracy or cost. In 8 of 10 code-mode cases every `run_code` call was a thin wrapper around `run_sql`. The 200-row cap on `run_sql` blocked pulling data into Python, as the model noted in `after_midnight` and `timed_tour`.

Code mode helped only on the tours, where a Python DP drove the SQL: `timed_tour` took 28 requests and $0.73 against 35 and $1.17, and `tour` took 33 requests against 45. It hurt on `departure_profile` (28 requests and $0.52 against 13 and $0.22), partly from two `KeyError: rows` crashes on error results. Large `print` dumps added tokens in `saturday_direct` and `after_midnight`.

## Runs

### one_vehicle

**Tool calling: passed.** One large CTE query produced all single-vehicle journeys with start and end walks; it returned bus 66 `R27f8d4b1+2` boarded at `P0091960a` after a 399 s walk, departure 29541, arrival 30480. Passed in 10 requests, the fewest of the run. ($0.15, 10 requests, 2.0 min)
- Right: Considered boarding platforms within 400 m of the origin, which is what finds the answer: no direct vehicle leaves Lennéplatz itself.
- Right: Reported `departure` as 29940 − 399 = 29541, the latest moment to leave the station, not the 08:10 start time.
- Right: Verified the run's `repeats` (`every` 1200) and raw calls afterwards.
- Mistake: 2nd call: the ~90-line CTE failed on `CASE WHEN at IS NOT NULL`; the whole query was resent with `c."at" AS at_val`.
- Mistake: Hard cap `reach_dest <= 36000` in the query is arbitrary, though the answer is far inside it.

**Code mode: passed.** Listed candidate direct runs near the origin and destination, tried to interpolate times in Python, and returned `R27f8d4b1+2` (walk 399 s, board 29940, arrive 30480), the same as tools. Passed in 13 requests. ($0.20, 13 requests, 3.0 min)
- Right: Found the walk to `P0091960a` (Strehlener Platz, 398.1 m) as the only way to a direct vehicle.
- Right: Took the times from timed calls: 27540 + 2×1200 = 29940 and 28080 + 2×1200 = 30480.
- Mistake: The Python interpolation loop crashed with `IndexError: list index out of range` at `while cs[b_idx]['at'] is None`; it was not fixed or rerun.
- Mistake: After the crash, candidate runs whose calls at both stops are untimed (`R99f51d2a`, `R5dda267f`, `Rcf54c9a7` show `None None`) were never given times in the visible queries, so the answer rests on the timed runs only. It passed, but an earlier untimed run would have been missed.
- Mistake: A wasted call `res['rows'][30:]` just to see the rest of a truncated result.

### saturday_direct

**Tool calling: passed.** Built Saturday's timetable and found tram 9 `Rb28d92d7` from `P7fa04a55` at 33484 (an interpolated untimed call) to `P1093f876` at 34560. Passed in 13 requests. ($0.18, 13 requests, 2.9 min)
- Right: Checked first whether Friday runs could reach Saturday 09:15 (`max(at + count*every)` = 104880 < 119700) and so safely ignored the previous day.
- Right: Interpolation was right for the boarding call: `P7fa04a55` has empty `at` and got 33484 from the distance formula.
- Right: Confirmed no 2- or 3-leg journey beats 34560 (`arr_leg2`, `arr_leg3` both empty).
- Mistake: 4th call: `run, n, place, at, dwell` parser error on unquoted `at`; resent with quotes.
- Mistake: A two-statement call returned only the second result, so `SELECT r.ref … WHERE r.ref = 'Rb28d92d7'` was run again on its own.

**Code mode: passed.** Built Saturday's timetable, got earliest arrival by leg count (`1`: 34560, `2`: 34971, `3`: 34971) and returned tram 9 `Rb28d92d7`, 33484 → 34560. Passed in 13 requests. ($0.20, 13 requests, 3.2 min)
- Right: Compared 1-, 2- and 3-leg arrivals in a single result, showing the direct tram is best.
- Right: Checked the latest Friday time (104880) before ignoring the previous day.
- Mistake: Typo `leg1_ alight AS (` caused a parser error and a full resend of the query.
- Mistake: Started with a separate `pathlib` directory listing call.
- Mistake: Printed 36 near-identical 1-leg rows and then all 45 calls of the run with interpolation columns, several thousand tokens of output that changed nothing.
- Mistake: An `untimed count` of 14614 was printed where other cases found 49345, from comparing `all_varchar` text with `''`; it did not affect the result.

### one_change

**Tool calling: passed.** Built the timetable for 2026-337, listed 1-leg journeys, then 2-leg journeys in a narrowed `calls_window` and returned `Rafeef850` then `R620ec7d9`, arriving 28440. Passed in 13 requests. ($0.16, 13 requests, 2.8 min)
- Right: Used the 1-leg best (29160) to cap the 2-leg search window at 29500, keeping the six-way join small.
- Right: Applied the `120 + walk` change margin and the 72 s walk `P66c27b1c`→`P3b6efaff` correctly.
- Mistake: First call re-read the tail of `DATA.md` with `read_text` (`start_line` 120) although the file had just been read.
- Mistake: 4th call: `WHERE at IS NULL` parser error, fixed with `"at"`.
- Mistake: `SELECT * FROM services; SELECT * FROM service_changes; SELECT count(*)…` returned only the last statement's rows, so a further call was needed to see the services.

**Code mode: passed.** Built the timetable, queried 1- and 2-vehicle journeys in one `UNION` and returned `Rafeef850` then `R620ec7d9`, arriving 28440. Passed in 10 requests, the fewest in code mode. ($0.16, 10 requests, 2.4 min)
- Right: Typed `east`/`north` as `DOUBLE` at load and kept the walk as `CEIL(...)::BIGINT`.
- Right: One query ranked 1- and 2-vehicle journeys together by `journey_arr`.
- Mistake: 2nd call: unquoted `at` in `run, n, place, at, dwell` parser error.
- Mistake: The first combined search returned no rows; the call was repeated with changed conditions before it produced the answer.
- Mistake: SVG leg coordinates were typed by hand into Python lists from a previous result rather than taken from the query result object.

### walking_change

**Tool calling: passed.** Found bus 62 `R76d2117b+4` to Pirnaischer Platz, a 78 s walk to `P72ccec8b`, then tram 2 `R3a0dccd4+54`, arriving 63480. Passed in 12 requests. ($0.21, 12 requests, 3.6 min)
- Right: Among ties on arrival 63480 it chose the change at `P6e794064` (78 s walk) over the one at `P86f9a261` (341 s walk).
- Right: Checked other arrivals near the destination (`dest_walks` query) and a competing run `Rd49d751b+59` before answering.
- Mistake: 2nd call: `MAX(CASE WHEN at IS NOT NULL …)` parser error.
- Mistake: The SVG draws each leg as a straight `<line>` between its two end platforms, unlike every other case where the path follows the intermediate stops; allowed, but inconsistent.
- Mistake: Typo `'run': ' VARCHAR'` in the `read_csv` types went unnoticed (no visible effect).

**Code mode: passed.** Not reviewed. ($0.17, 14 requests, 7.1 min)

### after_midnight

**Tool calling: passed.** Loaded the files with `run_sql`, built a timetable from both service days (2026-338 shifted by `-86400` and 2026-339), searched 1 to 4 legs and returned `R93fefd15` then `R900bf42f+2`, arriving 6420. Passed in 20 requests. ($0.26, 20 requests, 5.1 min)
- Right: Applied the previous-service-day rule: `active_services` unions day 2026-338 with `day_offset` `-86400` and day 2026-339 with offset 0, which is what makes `R900bf42f+2` (raw `at` 87660+) appear at 4860+.
- Right: Checked deeper searches (`reach3`, `reach4` with `arr4 + end_walk < 6420` returning 0) before settling on the 2-leg answer.
- Right: Re-read the raw `calls` rows and `repeats` (`every` 1800, `count` 2) for both runs before writing the SVG.
- Mistake: 4th call: `SELECT count(*) FROM calls WHERE at IS NULL` failed with a parser error because `at` is a DuckDB keyword; fixed on the next call with `"at"`.
- Mistake: Three near-duplicate inspection queries of the same two runs (`active_calls`, raw `calls`, then coordinates) before the SVG; one would have done.

**Code mode: passed.** Same approach as the tools run, wrapped in `run_code`: both service days with a `-86400` offset, a leg-count search (`legs` 2, 3, 4 all 6420) and the same two-bus answer arriving 6420. Passed in 23 requests. ($0.33, 23 requests, 5.2 min)
- Right: Counted active services for both days first (`2026-339`: 5, `2026-338`: 8) and applied the previous-day offset.
- Right: Recomputed the interpolation of `R93fefd15` in Python (`s` values, `at` None rows) to confirm 5492 at `P96dc02de`.
- Mistake: `SELECT count(*) FROM calls WHERE at = ''` parser error; also began with `DROP TABLE interpolated_base_calls` for a table created in the failed call.
- Mistake: One call fetched platforms into Python and printed only `Fetched calls: 200`: `run_sql` returns at most 200 rows, so the Python-side search was abandoned and it went back to SQL.
- Mistake: Two calls printed whole runs (about 50 and 70 rows each) into the conversation, adding tokens for no decision.

### arrive_by

**Tool calling: passed.** Built the day's timetable, ran a backward latest-departure search for arrival by 64800 and returned `R1aabe4da+29` (dep 63360) then `Rfd6f9e2d+67` (arr 64440). Passed in 15 requests. ($0.26, 15 requests, 4.7 min)
- Right: Used a backward reachability query (`r1_board` … up to 4 legs, `latest_dep`) which showed 63360 from `P10db34c8` as the latest departure for 2, 3 and 4 legs.
- Right: Cross-checked by listing every departure from origin-reachable platforms between 63000 and 64800 and every arrival near the destination.
- Mistake: 2nd and 3rd calls: the same long interpolation script failed twice on unquoted `at` (`CASE WHEN at IS NOT NULL`); the first retry only moved the error from line 38 to line 32. It should have quoted `"at"` everywhere at once.
- Mistake: Only services of day 2026-344 were loaded; the previous service day was not considered (harmless at 17:36).

**Code mode: passed.** Built the timetable, searched 1- and 2-leg journeys arriving by 64800, checked 3-leg options and returned the same answer as tools (dep 63360, arr 64440). Passed in 13 requests with no failed call. ($0.24, 13 requests, 2.6 min)
- Right: No SQL errors at all: it read every file with `all_varchar=true` and cast explicitly, so the `at` keyword trap did not bite.
- Right: Checked 3-leg journeys (best departs 63360, arrives 64680) and all later departures from the origin before answering.
- Mistake: Every `run_code` call is a single `await run_sql(...)`; nothing was gained from code mode.
- Mistake: Previous service day not loaded (harmless at this hour).

### departure_profile

**Tool calling: passed.** Built a backward profile (last leg, then `plat_best1`, `alight_to_1` …) for the 07:00-08:00 window and returned 12 non-dominated 2-leg journeys from 25327→27420 to 28620→30780. Passed in 13 requests. ($0.22, 13 requests, 3.5 min)
- Right: Compared best arrival for 2, 3 and 4 legs per departure (`arr2`, `arr3`, `arr4` identical in every row) before fixing the list.
- Right: Reconstructed the legs for all 12 pairs in one query with a `VALUES` list of `(dep_orig, arr_dest)`.
- Right: Cheapest of the harder cases at $0.22.
- Mistake: 2nd call: `WHERE at IS NULL` and `MAX(at)` parser error; fixed with `"at"`.

**Code mode: passed.** Built backward rounds `board_r1` … `board_r5` with Pareto pruning per platform, filtered to 12 non-dominated journeys and returned the same list as the tools run. Passed, but took 28 requests and $0.52 against 13 and $0.22 in tools. ($0.52, 28 requests, 7.0 min)
- Right: Ran the rounds until stable (`diff_r4_r5` = 0) instead of stopping at a fixed leg count.
- Right: When the profile pointed at a 3-leg version of the 25620 journey (`R0f4d6d9f+4` then `Re2a12a4f+3`), it looked for and returned the equivalent 2-leg journey with the same times.
- Right: Reduced 36 Pareto candidates to 12 strictly non-dominated ones.
- Mistake: Two `KeyError: rows` crashes from indexing `res['rows']` on a `run_sql` result that was an error dict (unquoted `at`; then `Referenced table "r1" not found`); each cost an extra call just to print the error.
- Mistake: Created `run_calls_dist`, dropped it and rebuilt it, then ran a further check returning 0.
- Mistake: Roughly twice the requests of the tools run for an identical answer.

### meeting_point

**Tool calling: passed.** Computed earliest arrivals from both origins after 32400 to every station, took the minimum of the pairwise maximum and returned `Sbb9212fa` at 33701 with one tram each (`Rc0124950`, `Rfa439a34`). Passed in 23 requests. ($0.31, 23 requests, 4.8 min)
- Right: Ranked all stations by `meet_time` (`Sbb9212fa` 33701 ahead of `S29c8f148` 33780) rather than guessing a midpoint.
- Right: Checked 2-leg options (`best1_leg2`, `best2_leg2`) to Albertplatz before committing; they gave 33732 and 33701, no improvement.
- Right: Re-derived the interpolated 33701 and 33692 from distances `s` for both runs.
- Mistake: Four failed calls early: `SELECT max(at)` (keyword), `count( FILTER (WHERE …) )` (wrong syntax), then `base_calls does not exist` because the previous multi-statement call had failed as a whole and it resumed from the middle instead of re-running the batch.
- Mistake: Search stops at 2 legs per person; nothing in the conversation rules out a 3-leg improvement.
- Mistake: Two almost identical final checks (`best1_leg2` + `best2_leg2`, then `best1_leg2` alone).

**Code mode: passed.** Computed earliest arrivals from both origins to every station and returned `Sbb9212fa` at 33701, identical to the tools answer. Passed in 23 requests. ($0.34, 23 requests, 4.3 min)
- Right: Sanity-checked its own data handling: integer vs float `floor` in the interpolation (`diff_count` 0), non-integer coordinates (0), `arr > dep` rows (0).
- Right: Extended the search to 3 and 4 legs (`leg3_alight`, `leg4_alight` count 0) before answering, further than the tools run went.
- Right: Loaded day 2026-338 services as well and confirmed `max_dep_338` 104880 cannot reach 09:00 next day.
- Mistake: 2nd call: `WHERE at IS NULL OR at = ''` parser error.
- Mistake: Several exploratory queries about runs it did not use (`Rd7036af4`, `Rf3b6d39f`, `Ra9b8dcb7`, `Rbedb8cc4`) and a 658 m walk check that could not matter.

### timed_tour

**Tool calling: passed.** Precomputed 1- and 2-leg trips between the five stations (`trips_1leg`, `trips_2leg`), enumerated visit orders against the opening windows in SQL and returned a 5-leg tour arriving 44160. Passed, but with 35 requests and $1.17, the most expensive case of the run. ($1.17, 35 requests, 18.6 min)
- Right: Encoded the opening windows in a `station_windows` table and let one query rank all orders (best 44160, next 45960).
- Right: Verified each leg's access letters (e.g. `P68b78dbb` is `NY`, alight only) and the stay at each station (`stay_sec` 1053, 1164 …).
- Right: Built the SVG paths with `STRING_AGG` in SQL.
- Mistake: 3rd call: `WHERE at IS NULL` parser error.
- Mistake: Between-station hops were limited to 1 or 2 vehicles; no 3-leg hop was tested.
- Mistake: About 15 follow-up queries re-inspected the already chosen segments one at a time (`Seg1` … `Seg5`, walks, access, raw calls, coordinates twice), which is where most of the cost went; `station_start_walk`-based table reached 1,762,495 rows.
- Mistake: Visit departures were reported as board time minus the walk from the alighting platform (35493 = 35640 − 147), a different convention from the code-mode run (35523 = 35640 − 117).

**Code mode: passed.** Wrote a Python DP over visit orders that calls a parameterised SQL earliest-arrival query per state (`find_earliest_subjourney`, 1 to 3 legs), then traced each hop; returned the same 5 legs arriving 44160. Passed in 28 requests and $0.73, against 35 and $1.17 in tools. ($0.73, 28 requests, 11.8 min)
- Right: The one case where code mode was used as intended: the DP (`dp` keyed by visited set and last station, with windows in a `STATIONS` dict) ran in a single call and printed `(44160, [...])` and the runner-up 49080.
- Right: Hops allowed up to 3 vehicles (`arr_1leg`, `arr_2leg`, `arr_3leg`), one more than the tools run.
- Right: Verified the `NY`/`YN` access at `P68b78dbb` and the untimed-call interpolation of `R2d3055ed` in Python.
- Mistake: 3rd call: `WHERE at IS NULL` parser error.
- Mistake: Realised mid-run (`run_sql returns at most 200 rows!`) that data could not be pulled into Python wholesale and spent a call listing `/data` again.
- Mistake: Visit departures use a different convention from the tools run (35523, and the board times 38312, 40560, 43260); both were accepted.
- Mistake: About eight verification calls after the DP result.

### tour

**Tool calling: passed.** Built pairwise 1-, 2- and 3-leg journeys between six stations, enumerated all 120 visit orders in SQL and returned an 11-leg tour arriving 48660. Passed after 45 requests, the most of any case. ($0.79, 45 requests, 14.5 min)
- Right: Enumerated permutations in one SQL query (`perms` self-joins) with the 900 s stay per station.
- Right: Re-ran the 2-leg tables without the per-run pruning (`leg1_alights_full`, `journeys_2leg_full`, same 1345 rows) to confirm the pruning lost nothing, and tested 4-leg hops (`journeys_4leg_check` = 0 improvements).
- Right: Found the 3-leg hop `Rb6f2f701+2` → `R81f00f31` → `Rfa241943+5` that the 2-leg tables miss.
- Mistake: `count(at)` parser error early on.
- Mistake: `CREATE TABLE prefix_2leg_alights …` hit `the query was stopped after 30 seconds`; it then aggregated first (`prefix2_pareto`) and intermediate tables still reached about 900,000 rows.
- Mistake: Roughly ten segment-by-segment verification queries after the answer was already known.

**Code mode: passed.** Loaded tables one statement at a time after early failures, ran a bitmask DP in Python that batches SQL earliest-arrival queries (`solve_batch`), and returned the same 11-leg tour arriving 48660. Passed in 33 requests against 45 in tools. ($0.76, 33 requests, 13.0 min)
- Right: Bitmask DP over the 5 stations with one batched SQL query per layer; first result `[48660, 4, 'S531e34da', 46978]` was final.
- Right: Tested alternative readings of where a visit starts and ends (`station_zero_walks` → 50012, `station_coord_walks` → 49560) and kept the DATA.md reading (48660).
- Right: Recomputed interpolation for six runs in Python (`All untimed interpolations 100% verified!`).
- Mistake: Five of the first six calls had errors: `services does not exist`, `calls does not exist` (a multi-statement load failed as a whole), then `TRY_CAST(at AS INTEGER) AS at` parser error; it ended up dropping and recreating `places`.
- Mistake: `active_calls_base` was created with 0 rows, dropped and rebuilt (48428 rows).
- Mistake: `active_runs` filters only on `services.days` and dates and ignores `service_changes`; no change applied on 2026-339, so it did not matter.
- Mistake: The alternative-interpretation experiments and repeated segment dumps were not needed for the answer.
