---
title: "DeepSeek V4 Pro 0423 on Pydantic AI Transit Planner"
description: "Journey planning over a real Dresden public transport timetable, with an SVG map of each answer. Tool calling 40%, code mode 70%; rank 24 of 32."
canonical: https://models.pydantic.dev/models/deepseek-v4-pro/transit_planner/
---

# DeepSeek V4 Pro 0423 on Pydantic AI Transit Planner

> Journey planning over a real Dresden public transport timetable, with an SVG map of each answer. Tool calling 40%, code mode 70%; rank 24 of 32.
>
> Markdown copy of https://models.pydantic.dev/models/deepseek-v4-pro/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/deepseek-v4-pro.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time      |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | --------- |
| Tool calling | 40%   | 4 of 10      | $8.97 | 695      | 755        | 180.7 min |
| Code mode    | 70%   | 7 of 10      | $7.83 | 562      | 564        | 201.6 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

DeepSeek-V4-Pro-0813 passed **11/20 runs**: **4/10 tools** and **7/10 code_mode**. Six failures exhausted the 80-request budget; three submitted answers failed validation. No terminal failure was identified as a provider error.

#### Where it does well

Both modes passed `meeting_point`, `one_change`, `one_vehicle`, and `walking_change`. Successful runs handled repeat identifiers, boarding permissions, transfer margins, and SVG identifiers. Code mode additionally completed `after_midnight`, `arrive_by`, and `saturday_direct`.

The strongest implementations used reusable searches: backward latest-departure propagation for `arrive_by`, routing rounds for meeting points, and event searches for overnight travel. Both walking-change answers reached `63480` through different valid transfers.

#### Mistakes it makes

Request management is the largest weakness. Tools mode exhausted its budget on five cases; code mode did so on `departure_profile`. Repeated route inspection, late interpolation rebuilds, and SQL repair displaced reconstruction and submission.

Unquoted `at`, invalid aliases, and even unfinished `?` expressions recur. Code mode adds sandbox incompatibilities, memory resets, and unchecked truncated SQL results.

Completed failures expose modeling problems: tools-mode `saturday_direct` accumulated distances through `1 PRECEDING`, producing boarding time `33479` instead of `33484`. Code-mode `timed_tour` subtracted station-coordinate walks even when arrival and departure used the same platform. The tour search forced visits at unvisited target stops rather than preserving ordinary transfer alternatives; its precise optimality gap is not supplied.

#### Tool calling compared with code mode

Code mode used **562 requests versus 695**, and cost **$7.8283 versus $8.9708**, while passing three additional cases. Its largest request improvement was `meeting_point`: **31 versus 69**.

The benefit was uneven. `one_change` rose from **48 to 74** requests, and `one_vehicle` from **51 to 63**. Wrapping sequential SQL in Python did not itself improve efficiency. Neither mode passed either tour or the departure profile, so code mode is the stronger choice here, but remains unreliable for broader optimization tasks.

## Runs

### one_vehicle

**Tool calling: passed.** Passed in 51 requests using `R27f8d4b1+2`, boarding at `29940` and arriving at `30480`. ($0.57, 51 requests, 18.2 min)
- Right: Included an initial walk to `P0091960a` while respecting the one-vehicle constraint.
- Right: Checked repeat expansion and compared subsequent departures before selecting the earliest arrival.
- Right: Returned journey start `29400` and generated the SVG.
- Mistake: Late interpolation queries at messages 79 and 83 failed on unquoted `at`.
- Mistake: Repeated small queries over the same CSV files and candidate runs made this simple one-vehicle task expensive in requests.

**Code mode: passed.** Passed with `R27f8d4b1+2`, `29940–30480`, but took 63 requests and needed recovery from incomplete tool results. ($0.85, 63 requests, 23.1 min)
- Right: Verified the repeat interval and selected the same one-vehicle journey as tools mode.
- Right: Recovered missing platform and repeat data with narrower queries and completed interpolation checks.
- Mistake: Messages 83–85 repeated the unquoted `at` SQL error.
- Mistake: Later code assumed every SQL response contained `rows`, producing `KeyError` on error responses.
- Mistake: At message 109 it loaded only 200 places and 200 repeats from truncated results, then failed on missing platform `Pd1afb228`. It should have checked `truncated` and fetched complete or targeted data initially.

### saturday_direct

**Tool calling: failed.** Returned the correct run and arrival, but failed with boarding time `33479` instead of `33484` and journey departure `33479` instead of the requested start `33300`. ($0.94, 70 requests, 18.4 min)
- Right: Selected Saturday run `Rb28d92d7` to `P1093f876`, arriving at `34560`.
- Right: Produced an SVG with the required run and platform identifiers.
- Mistake: The `act_calls_seq` calculation used `SUM(seg) ... 1 PRECEDING` even though `seg` was the distance into the current stop. This shifted cumulative distances backward and corrupted interpolation; it should include `CURRENT ROW`.
- Mistake: The final `final_result` used boarding time as journey departure rather than the specified `33300` start.
- Mistake: It spent further requests running six routing rounds without detecting the underlying interpolation error.

**Code mode: passed.** Passed in 40 requests with journey start `33300`, boarding `Rb28d92d7` at `33484`, and arrival `34560`. ($0.58, 40 requests, 18.3 min)
- Right: Correctly interpolated the untimed boarding call, avoiding tools mode's five-second error.
- Right: Reconstructed and drew the direct journey with the required identifiers.
- Mistake: Used unsupported `globals()` and generator-style `next`, causing recoverable errors.
- Mistake: Reloading full CSV dictionaries at message 55 exceeded the 256 MiB memory limit and reset the session.
- Mistake: It recovered using more compact data structures and reran routing; the final answer passed despite this substantial restart.

### one_change

**Tool calling: passed.** Passed in 48 requests with two vehicles, departing the origin at `27600` and arriving at `28440`. ($0.85, 48 requests, 20.4 min)
- Right: Selected `Rafeef850`, `27669–27960`, followed by `R620ec7d9`, `28200–28440`.
- Right: Verified the transfer walk as `72` seconds: `27960 + 72 + 120 = 28152`, before the second departure.
- Right: Compared one-vehicle alternatives and wrote the required platform and run markers.
- Mistake: Interpolation setup repeatedly failed on unquoted `at`, unsupported `sum(v IGNORE NULLS)`, and nested window functions.
- Mistake: It recovered by separating window calculations into intermediate tables; doing that initially would have reduced the 48-request run.

**Code mode: passed.** Passed with the same `28440` arrival and two runs as tools mode, but required 74 requests. ($0.90, 74 requests, 19.1 min)
- Right: Compared one- and two-leg candidates, including initial, transfer, and final walks.
- Right: Eventually rebuilt schedules with untimed calls and verified `Rafeef850` and `R620ec7d9`.
- Mistake: Initially searched schedules that omitted untimed calls, then revisited interpolation after already drawing an SVG.
- Mistake: Errors included querying missing `walk_to_dest` and `transfer_edges`, using nonexistent `second_trips.place`, and invalid `LAST_VALUE` null-handling syntax.
- Mistake: Most work remained sequential `await run_sql(...)` calls, so code mode added little batching benefit and used 26 more requests than tools mode.

### walking_change

**Tool calling: passed.** Passed in 57 requests with two vehicles and arrival `63480`. ($0.79, 57 requests, 10.2 min)
- Right: Returned `R76d2117b+4`, `61560–62040`, then `R3a0dccd4+54`, `62520–63480`, transferring between platforms at Pirnaischer Platz.
- Right: Verified repeat metadata and service validity, and drew the transfer separately from vehicle legs.
- Mistake: SQL errors included malformed join syntax, unquoted `at`, and querying nonexistent `calls.line` at message 99.
- Mistake: Numerous route-specific inspections prolonged the run despite the final itinerary requiring only two vehicles.

**Code mode: passed.** Passed in 49 requests, arriving at `63480` through a different transfer location from tools mode. ($0.46, 49 requests, 18.5 min)
- Right: Selected `R76d2117b+4` to `P86f9a261` at `61920`, then walked `341` seconds to `P9cd5b9a9`.
- Right: Verified readiness `61920 + 341 + 120 = 62381`, before boarding `R3a0dccd4+54` at `62458`.
- Right: Independently checked interpolation using segment lengths `305` and `320`, yielding base time `30058`.
- Mistake: An early file iteration failed under the sandbox, and a later verification unpacked four-field records into five variables.
- Mistake: Initial walking candidates were measured from the station coordinate rather than all origin platforms; the final journey boarded directly at the origin and did not rely on this modeling error.

### after_midnight

**Tool calling: error.** Expanded Friday and Saturday services and investigated journeys arriving at `6420`, but exhausted all 80 requests without submitting a journey or SVG. ($1.43, 80 requests, 23.5 min)
- Right: Applied previous-service-day offsets of `-86400` and expanded repeat identifiers.
- Right: Eventually interpolated untimed calls and checked whether four-vehicle connections could beat `6420`; the last query returned no such connection.
- Mistake: Initially joined events using run names without distinguishing service days; at message 67 it rebuilt `events_timed` with `inst_id` containing the day.
- Mistake: Deferred interpolation until message 119, requiring replacement of the earlier timed-only routing tables.
- Mistake: Several `run_sql` calls contained unfinished expressions such as `e.base?` and `t_q_adj?`. It should have built complete event tables once and reserved requests for reconstruction and submission.

**Code mode: passed.** Passed in 68 requests with three legs arriving at `6420`, successfully completing the case that exhausted tools mode. ($1.05, 68 requests, 18.1 min)
- Right: Built interpolated Friday/Saturday instances and searched boarding/alighting events with walking and transfer margins.
- Right: Returned `Rca4e4824`, `R93fefd15`, and `R900bf42f+2`, with boarding times `4380`, `5100`, and `5700`.
- Right: Rewrote the SVG to match the final three-leg answer.
- Mistake: After the first search, it reran routing with additional walks from station coordinates, although the dictionary permits platform-to-platform walks; the submitted route did not depend on that extension.
- Mistake: An SVG-generation call contained unfinished Python, `for? no`, causing a syntax error.
- Mistake: It first drew a two-leg alternative before replacing it, adding avoidable work.

### arrive_by

**Tool calling: error.** Found a candidate departing at `63360`, then exhausted 80 requests checking later departures through progressively larger ride-count tables. ($0.75, 80 requests, 15.8 min)
- Right: Expanded repeated runs, interpolated calls, and included walking and the `120`-second transfer margin.
- Right: The candidate departure matched the successful code-mode answer.
- Mistake: Setup produced errors involving existing `base_call_s`, unquoted `at`, and a nonexistent `bp` alias.
- Mistake: After finding the candidate, it built `states2` through `states5` in separate calls; the final destination query returned no rows, but no answer or SVG followed.
- Mistake: A backward latest-departure search from deadline `64800`, with predecessor tracking, would have avoided the lengthy forward enumeration.

**Code mode: passed.** Passed in 38 requests using a backward search, leaving at `63360` and arriving at `64500`, before deadline `64800`. ($0.39, 38 requests, 12.4 min)
- Right: `scan_runs` propagated latest feasible times backward and converged with zero changes at iteration 5.
- Right: Reconstructed `R1aabe4da+29` and `R54c1ee76+5`, including a `64`-second transfer walk.
- Right: Checked later origin departures and generated the SVG.
- Mistake: Several calls used unsupported sandbox features, including `time.time`, `__import__`, and generator-style `next`.
- Mistake: Two calls contained literal unfinished `?` expressions, including the first `run_code` call.
- Mistake: These were recovered implementation errors rather than defects in the submitted journey.

### departure_profile

**Tool calling: error.** Computed preliminary departure/arrival candidates and dominance flags, but hit 80 requests before completing the profile or drawing it. ($0.65, 80 requests, 15.7 min)
- Right: Expanded repeats and eventually constructed interpolated schedules.
- Right: Used a dominance test comparing later departures against earlier arrivals.
- Mistake: Message 7 queried `places` before loading it.
- Mistake: Messages 33–87 spent many calls isolating the parser failure caused by unquoted `at`, including numerous one-column SQL experiments; qualifying or quoting the field would have resolved it directly.
- Mistake: The late dominance calculation used `candidate_1`, a restricted candidate set, while nearby-origin walking options were still being investigated in the last call. It needed complete routing candidates, including later departures outside the requested window, before filtering.

**Code mode: error.** Developed profile-routing code and evaluated later departures in batches, but exhausted 80 requests without submitting journeys or an SVG. ($1.42, 80 requests, 28.8 min)
- Right: Recognized that departures after `28800` could dominate journeys inside the requested window.
- Right: Implemented suffix-minimum filtering and broader routing passes after the initial restricted candidate search.
- Mistake: Early errors included passing a `Path` directly to `csv.DictReader`, importing unavailable `heapq`, and indexing an integer as a dictionary.
- Mistake: A large later-departure loop at message 131 exceeded the sandbox's 30-second execution limit and reset its state; rebuilding then incurred three type-check failures.
- Mistake: The final call finished evaluating 168 later events, leaving no requests for reconstruction or submission. It should have bounded and batched computation earlier and retained predecessors.

### meeting_point

**Tool calling: passed.** Passed in 69 requests, selecting Albertplatz (`Sbb9212fa`) at `33701` and producing both journeys and the SVG. ($0.59, 69 requests, 20.4 min)
- Right: Compared reachability from both origins through multiple routing rounds.
- Right: Returned `Rc0124950` arriving at `33701` and `Rfa439a34` arriving at `33692`, correctly taking the later arrival as the meeting time.
- Mistake: Setup and routing incurred nine error responses, including comparison of date strings with `339`, unquoted `at`, and unfinished SQL such as `SELECT count(*) FILTER? FROM?`.
- Mistake: Messages 93–97 attempted to query `b1_scan3` after its creation failed. Checking the preceding result would have avoided the extra call.

**Code mode: passed.** Passed in 31 requests, finding Albertplatz at `33701` with the same two runs as tools mode. ($0.30, 31 requests, 10.0 min)
- Right: `compute_earliest` and `compute_with_paths` handled both origins, transfer walks, and station arrival comparisons.
- Right: The first friend walked to `P3035f403` and boarded `Rc0124950` at `33180`; a checked origin-platform walk was `353` seconds.
- Right: Verified meeting-time ties and the selected calls before submission.
- Mistake: Schedule construction indexed the previous call's arrival field as a platform, causing `KeyError: 37920`.
- Mistake: Later calls referenced undefined `lines_rows` and imported unavailable `html`; both were repaired.

### timed_tour

**Tool calling: error.** Loaded and expanded the timetable, then manually explored station-pair routes until the 80-request limit, without a final itinerary or SVG. ($1.07, 80 requests, 11.1 min)
- Right: Constructed `direct_legs` and examined departures relevant to the visit windows.
- Right: Investigated nearby boarding platforms as well as direct station connections.
- Mistake: Early calls queried unloaded `services`, treated `2026-343` as arithmetic rather than a date string, and repeatedly used unquoted `at`.
- Mistake: Much of the latter half consisted of individual `direct_legs` lookups rather than a search tracking visited stations and opening windows.
- Mistake: The last call contained `n.near_place?` and failed. It needed a complete state-based tour search with predecessor records and a submission budget.

**Code mode: failed.** Submitted seven legs returning at `44760`, but failed after modeling visit departures using station coordinates rather than the actual platforms. ($1.24, 76 requests, 26.5 min)
- Right: Searched visit orders with `900`-second stays and explicit opening windows.
- Right: Verified boarding/alighting permissions and times for all seven submitted legs.
- Mistake: `station_initial` and the final visit calculation used station-to-platform distances. For Prohlis it subtracted `52` seconds despite arriving and subsequently boarding at the same platform, `P68b78dbb`, reporting departure `35588` instead of `35640`.
- Mistake: The same error reported Mickten departure `43393` instead of `43500`, again with the same arrival and boarding platform.
- Mistake: It should have retained arrival-platform state across visits and measured actual platform walks. The search also suffered a sandbox timeout and memory reset before rebuilding.

### tour

**Tool calling: error.** Built a visited-station bitmask search and reached a computed return time of `49935`, but exhausted 80 requests before reconstructing or submitting the tour. ($1.33, 80 requests, 27.1 min)
- Right: Tracked five visits using masks through `31` and applied `900`-second stays.
- Right: Its final relaxation reported `75251` states and zero improvements.
- Mistake: Initial loading produced repeated `at` parser errors and invalid conversions of `YYYY-DDD` dates to integers.
- Mistake: It later rebuilt interpolation tables after changing call ordering to numeric `n`, duplicating substantial work.
- Mistake: The converged table retained minimum times without a submitted predecessor chain. The final calls merely identified `R07ed193a+11` at `49935`; that computed time was never validated as a complete itinerary.

**Code mode: failed.** Submitted ten validated vehicle legs and five visits, returning at `50012`, but the benchmark rejected the tour. ($0.64, 43 requests, 26.7 min)
- Right: Implemented compact timetable arrays, repeat offsets, a custom heap, and visited-station masks.
- Right: Reconstructed walks and visits and checked every submitted leg against its computed schedule.
- Right: Generated platform and station markers in the SVG.
- Mistake: In `process_alighting`, reaching an unvisited target exclusively created a visit state; ordinary transfer states were omitted. This forces a 15-minute visit whenever alighting there and excludes routes that transfer there before visiting later.
- Mistake: It should have preserved both visit and non-visit alternatives before claiming earliest return. The supplied result gives no reference optimum, so the exact return-time gap is not established.
- Mistake: Development also incurred a memory reset, unsupported timing call, missing `global counter`, and `len(heap)` on a class without `__len__`.
