---
title: "DeepSeek V4.1 Flash on Pydantic AI Transit Planner"
description: "Journey planning over a real Dresden public transport timetable, with an SVG map of each answer. Tool calling 20%, code mode 60%; rank 27 of 32."
canonical: https://models.pydantic.dev/models/deepseek-v4.1-flash/transit_planner/
---

# DeepSeek V4.1 Flash on Pydantic AI Transit Planner

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

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 20%   | 2 of 10      | $0.27 | 269      | 373        | 89.1 min |
| Code mode    | 60%   | 6 of 10      | $0.44 | 358      | 399        | 76.7 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

DeepSeek-V4.1-Flash passed 8 of 20 runs: 2 of 10 in tool calling and 6 of 10 in code mode. Total cost was about $0.27 for tool calling and $0.44 for code mode. One fault dominates: the model calls `final_result` in the middle of its work, while its recorded thinking says it is about to run another query.

#### Where it does well

- **Reading the rules.** It reads `DATA.md` fully and reasons correctly about weekday bits, access letters, the 400 m walk limit and service-day offsets.
- **Search when it finishes.** `arrive_by`, `meeting_point`, `one_vehicle` and `timed_tour` in code mode were complete: verified answer, SVG written, then submitted.
- **Self-checks.** In `walking_change` code mode it tested its time window against the maximum `dwell` of 780 s before trusting the result.

#### Mistakes it makes

- **Premature `final_result` (13 of 20 runs).** Ten of these failed and three passed only because the answer was already known (`meeting_point` tools, `saturday_direct` and `walking_change` code mode).
  - Seven submissions were placeholders or inventions: `run: "bogus"`, `board: "P"`, `legs: []`, or ids such as `P1a2b3c4d` that appear in no query result.
  - Five came within 8 requests, before any search.
  - `departure_profile` code mode finished a full dynamic programme and then submitted one journey without reading the results.
- **Spurious tool calls.** Unneeded `list_files` calls recur; in `after_midnight` tools the model itself wrote "Something's inserting list_files calls".
- **Time conversion.** `one_vehicle` tools took 08:10 as 28800 s (08:00) and chose a bus that leaves before the passenger can reach it.
- **Missed rule.** `after_midnight` tools submitted a zero-second change at `Pa6239db7`, although 120 s is required.
- **Missing SVG.** Only 6 of 20 runs wrote `/out/journey.svg`; three passes had none.

#### Tool calling compared with code mode

Code mode was three times as successful (6 against 2). The premature `final_result` fault hit both modes: 7 runs in tool calling and 6 in code mode. Code mode more often already had the answer when it fired. Code mode alone solved `arrive_by`, `one_vehicle`, `timed_tour` and `walking_change`; tool calling solved nothing that code mode missed. Code mode cost more per run ($0.044 against $0.027) and lost one run's state to the 30 s sandbox limit (`tour`). Neither mode solved `after_midnight`, `departure_profile`, `one_change` or `tour`.

## Runs

### one_vehicle

**Tool calling: failed.** Found bus 66 from Strehlener Platz to Technische Universität with a 399 s start walk, wrote a full SVG, and submitted `Rf679205e+2` boarding at 29340 with departure 28800. Failed. ($0.042, 40 requests, 26.5 min)
- Right: Found the right pattern: walk 398 m to `P0091960a`, then line 66 to `P6e8c05a2`
- Right: Wrote a valid `/out/journey.svg` with `data-place` and `data-run`
- Right: Read the access letters correctly after doubting them
- Mistake: Message 3 onward: converted 08:10 to 28800 s, which is 08:00; 08:10 is 29400
- Mistake: So it picked the 29340 bus, which leaves before the passenger can get there (29400 + 399 = 29799); code mode took the next one, `R27f8d4b1+2` at 29940
- Mistake: The final check at message 79 repeated 28800 without recomputing
- Mistake: A no-op `run_sql` `SELECT 1` at message 75; 40 requests

**Code mode: passed.** Used 08:10 = 29400, walked 399 s to Strehlener Platz and took bus 66 `R27f8d4b1+2` at 29940, arriving 30480; wrote the SVG and submitted. Passed. ($0.030, 38 requests, 4.7 min)
- Right: Correct time conversion, where the tool-calling run used 28800
- Right: Read the SVG back from disk to confirm it was written
- Mistake: A no-op `run_code` `print('done')` before `final_result`; 38 requests

### saturday_direct

**Tool calling: passed.** Found tram 9 run `Rb28d92d7` from `P7fa04a55` at 33484 to `P1093f876` at 34560, wrote the SVG with `write_file`, and submitted. Passed. ($0.048, 34 requests, 7.4 min)
- Right: Complete run: answer, SVG file, then `final_result`
- Right: Marked both platforms and both stations in the SVG
- Mistake: Message 67 is about 9,000 characters of deliberation on whether departure is 33300 or 33484; it chose 33484 while code mode gave 33300 and both passed
- Mistake: 34 requests and $0.048 for a single direct tram

**Code mode: passed.** Found the direct tram `Rb28d92d7` (33484 to 34560), compared it with the best two-vehicle arrival 34971, and submitted during a three-vehicle check. Passed, without an SVG. ($0.019, 32 requests, 3.2 min)
- Right: Checked start walks and two-vehicle options against the direct tram
- Mistake: Called `final_result` straight after building `ride2g` (2,176,912 rows) without finishing the check it had started or writing `/out/journey.svg`
- Mistake: Gave departure 33300 where the tool-calling run gave 33484

### one_change

**Tool calling: failed.** Read DATA.md, loaded tables and listed the services valid on 2026-337, then called `final_result` with `legs: []`, departure 27600, arrival 27600 at request 8. Failed. ($0.0033, 8 requests, 10.7 min)
- Right: Correctly worked out the Thursday weekday bit (8) and that no service change applies
- Right: Correctly reasoned that the 1.2 km gap rules out a walk-only journey
- Mistake: Message 15: thinking says "Let me create service_changes and confirm", but the call emitted is `final_result` with an empty journey
- Mistake: No timetable search was run; no SVG

**Code mode: failed.** Loaded the tables and listed the platforms of both stations, then called `final_result` with `legs: []`, departure 4, arrival 5 at request 7. Failed. ($0.0015, 7 requests, 13 s)
- Right: Loaded all files in one `run_code` call
- Mistake: Message 13: thinking says "Let me first check the repeats table", but the call emitted is `final_result` with placeholder numbers
- Mistake: No search was run; no SVG

### walking_change

**Tool calling: failed.** Was still exploring line routes (62, 61, 2) when it called `final_result` with two legs pasted from sample rows, one at 16260-16440 (about 04:30) for a 17:05 start. Failed. ($0.014, 15 requests, 2.2 min)
- Right: Identified which lines serve the origin and the destination
- Mistake: Message 29: thinking says "Let me get it directly" for run `R3c8c138`, but the call emitted is `final_result`
- Mistake: Leg 1 uses base run `R003ce541` at 16260, hours before the 61500 start, and departure 61500 is later than leg 2's `board_time` 61200
- Mistake: No journey search was run; no SVG

**Code mode: passed.** Ran a search giving 63480 via `R76d2117b+4` to Pirnaischer Platz and `R3a0dccd4+54` onward, checked window truncation against max `dwell` 780, and submitted. Passed, without an SVG. ($0.045, 35 requests, 17.6 min)
- Right: Checked that no call with `at` in 60500-61000 and long dwell was cut from its window
- Right: Used `asyncio.gather` to run two checks in one call
- Right: Allowed 480 s for the platform change at Pirnaischer Platz
- Mistake: Message 69: computed all four SVG coordinates and wrote "Let me write the file", then called `final_result` instead; `/out/journey.svg` was never written

### after_midnight

**Tool calling: failed.** Built a label-propagation search in SQL (`c1`..`c5`) that gave 6420, then started redoing it with untimed-call interpolation, and submitted the old two-leg answer mid-rebuild with no SVG. Failed. ($0.066, 62 requests, 11.7 min)
- Right: Handled the previous service day with an `off=-1` offset in `callabs`
- Right: Worked out that `at` is a reserved word in DuckDB and quoted it
- Mistake: The submitted change alights at `Pa6239db7` at 5460 and boards `R900bf42f+2` there at 5460, a zero-second change although DATA.md requires 120 seconds plus the walk
- Mistake: Around messages 109-123 it had just found untimed calls and built `cdist` to interpolate them, but called `final_result` straight after `SELECT count(*) FROM cdist` without recomputing
- Mistake: Repeated spurious `list_files` calls (messages 111, 117); its own thinking says "Something's inserting list_files calls"
- Mistake: Never wrote `/out/journey.svg`; 62 requests

**Code mode: failed.** Listed the active services for days 338 and 339 and the calls at origin and destination, then called `final_result` with a run id `R8f7c2e1a+2` that appears in no query result. Failed at request 13. ($0.010, 13 requests, 1.8 min)
- Right: Recognised that the previous service day's runs need a 86400 offset
- Right: Confirmed that no run serves both stations directly
- Mistake: Message 25: thinking says "First, expand repeats", but the call emitted is `final_result` with an invented direct run
- Mistake: Its own query had just returned 0 direct runs, so a one-leg answer contradicts its data
- Mistake: No SVG

### arrive_by

**Tool calling: failed.** Built a backward latest-departure fixpoint that gave 63660, began a forward check, then called `final_result` with `run: "bogus"`, `board: "x"`, times 0 and 1. Failed. ($0.040, 37 requests, 8 s)
- Right: Noticed that `run_sql` returns only the last statement's rows and re-ran the `repeats` query alone
- Right: The backward search was largely complete by message 71
- Mistake: Message 73: thinking says it will put six iterations in one `run_sql` call, but the call emitted is `final_result` with placeholder values
- Mistake: Had a candidate departure of 63660 and did not submit even that; code mode found 63360
- Mistake: Extra `list_files` call in message 71; no SVG

**Code mode: passed.** Found the latest departure 63360 on `R1aabe4da+29` with a 64 m walk at Straßburger Platz to `Rfd6f9e2d+67`, arriving 64440; wrote the SVG and submitted. Passed. ($0.055, 69 requests, 7.6 min)
- Right: Verified both runs' services against day 2026-344 before answering
- Right: Left 360 s for a 64 m walk change, inside the 120 s plus walk rule
- Right: Complete SVG with a dashed walk line
- Mistake: 69 requests, the most of any case, for a two-leg journey

### departure_profile

**Tool calling: failed.** Loaded the data, built `call_geo` and `call_s`, then called `final_result` with one empty journey (`legs: []`, departure 0, arrival 0) at request 18. Failed. ($0.0077, 18 requests, 81 s)
- Right: Fixed the ambiguous `ref` binder error in one retry
- Right: Planned the cumulative-distance interpolation for untimed calls correctly
- Mistake: Message 35: thinking plans a correlated-subquery `run_sql` for interpolation, but the call emitted is `final_result` with a placeholder
- Mistake: No journey search had been run at all; no SVG

**Code mode: failed.** Built a full backward dynamic programme in Python over 223,422 calls ("done 223422 223317"), then submitted a single journey before reading any result out of it. Failed. ($0.048, 29 requests, 7.5 min)
- Right: The search itself (`Aval`, `Bval`, suffix minima per platform) ran to completion in the sandbox
- Right: Found 19 start-walk and 13 end-walk platforms
- Mistake: Message 57: thinking says "DP done. Now collect journeys... Let me compute", but the call emitted is `final_result`
- Mistake: Submitted one journey (departure 26340, 07:19) for a question asking for every worthwhile departure between 07:00 and 08:00
- Mistake: The submitted legs do not appear in the tail of the transcript I read; no SVG

### meeting_point

**Tool calling: passed.** Found Albertplatz `Sbb9212fa` at 33701 with one tram each (`Rc0124950`, `Rfa439a34`) and submitted it. Passed, without an SVG. ($0.048, 42 requests, 18.3 min)
- Right: Checked both runs' calls in `ride_calls` before answering
- Right: Same answer as code mode
- Mistake: Message 83: thinking plans a two-ride validation query, but it called `final_result` instead; the answer happened to be already correct
- Mistake: Never wrote `/out/journey.svg`
- Mistake: An accidental `list_files` call at message 77 ("Oops, I accidentally re-read places"); 42 requests

**Code mode: passed.** Found Albertplatz `Sbb9212fa` at 33701 with `Rc0124950` and `Rfa439a34`, checked the interpolated time at `Pcb3f34ed`, wrote the SVG and submitted. Passed. ($0.071, 56 requests, 9.7 min)
- Right: Verified the untimed call's interpolation in `calls_s` before answering
- Right: SVG marks the three stations and four platforms
- Mistake: 56 requests and $0.071, against 42 and $0.048 for the same answer in tool calling

### timed_tour

**Tool calling: failed.** Read DATA.md and the platforms of the five stations, then called `final_result` with `run: "R1"`, `board: "P"`, `station: "S"` and all times 0 at request 7. Failed. ($0.0027, 7 requests, 35 s)
- Right: Read the opening-window rule carefully in message 11
- Mistake: Message 13: thinking says "Let me see the full lines.txt", but the call emitted is `final_result` with placeholders
- Mistake: No tables were loaded and no search was run; no SVG

**Code mode: passed.** Read the files into Python and produced a five-leg tour through Prohlis, Technische Universität, Pohlandplatz and Mickten, back at 44160, with an SVG. Passed. ($0.13, 57 requests, 18.6 min)
- Right: Visits satisfy the stated windows: Pohlandplatz 39480-40478, Technische Universität 37080-38244, Mickten 42300-43241
- Right: The only tour case the model solved in either mode
- Mistake: The most expensive case at $0.128 and 57 requests

### tour

**Tool calling: failed.** Loaded all seven tables in one `run_sql`, then called `final_result` with made-up ids (`P1a2b3c4d`, `P5e6f7a8b`, `R4a08d24d+3`) and one visit at request 6. Failed. ($0.0013, 6 requests, 10.3 min)
- Right: Loaded the data correctly in a single call
- Mistake: Message 11: thinking says "let me query places for those station ids", but the call emitted is `final_result` with invented platforms and a run it never looked up
- Mistake: Called `list_files` three times in the first four turns
- Mistake: Only one of the five required visits; no SVG

**Code mode: failed.** Built an in-memory model in Python, hit the 30 s sandbox limit which reset the session, tested `/out` for caching, then submitted a partial tour with 2 of 5 visits. Failed. ($0.029, 22 requests, 5.8 min)
- Right: After the time-out it checked that files in `/out` persist between calls, a sound plan for caching
- Mistake: Message 37: a `run_code` call exceeded 30 s and lost all state
- Mistake: Message 43: thinking says "Let me redo the loading with timing", but the call emitted is `final_result`
- Mistake: The answer visits only `Sc29ca723` and `S2a8c1b68` and has no leg back to Hauptbahnhof; no SVG
