---
title: "Qwen3.7 Flash on Pydantic AI - SQL data analysis"
description: "Planning journeys by querying a real Dresden public transport timetable with SQL, with an SVG map of each answer. Tool calling 0%, code mode 10%; rank 38 of 44."
canonical: https://pydantic.dev/models/list/qwen3.7-flash/sql_data_analysis/
---

# Qwen3.7 Flash on Pydantic AI - SQL data analysis

> Planning journeys by querying a real Dresden public transport timetable with SQL, with an SVG map of each answer. Tool calling 0%, code mode 10%; rank 38 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/qwen3.7-flash/sql_data_analysis/. Index for agents: https://pydantic.dev/models/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://pydantic.dev/models/api/select` with a JSON body such as `{"description": "what the agent does"}`. It returns up to five ranked models with reasons. Format: https://pydantic.dev/models/select.md
- Search models by name: `GET https://pydantic.dev/models/api/search?query=<text>`
- List, filter and sort models: `GET https://pydantic.dev/models/api/models`, for example `?weights=open&max_price=2&sort=efficiency`
- One model in full: `GET https://pydantic.dev/models/api/models/<slug>`
- Any other question about the models: `GET https://pydantic.dev/models/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://pydantic.dev/models/mcp`. More: https://pydantic.dev/models/usage.md

About the benchmark: https://pydantic.dev/models/benchmarks/sql_data_analysis.md. The model on every Pydantic AI benchmark: https://pydantic.dev/models/list/qwen3.7-flash/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time      |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | --------- |
| Tool calling | 0%    | 0 of 10      | $0.64 | 734      | 738        | 80.8 min  |
| Code mode    | 10%   | 1 of 10      | $0.81 | 758      | 758        | 107.4 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

Qwen3.7-flash passed **1 of 20** cases. The pass was `one_vehicle` in code mode. **15 runs hit the 80-request limit** with no answer: 7 of 10 in tools mode and 8 of 10 in code mode. The 4 answers that were submitted but wrong were `meeting_point` (tools), `tour` (tools) and `saturday_direct` (both modes). Costs were low ($0.03–0.15 per run), but almost every run used all its requests without getting anywhere.

#### Where it does well

- It always read DATA.md first and filtered services correctly for the weekday (`days & 32`, service_changes).
- In code mode it implemented untimed-call interpolation and expanded repeats into `+k` names, for example `R27f8d4b1+2` and `R76d2117b+6`.
- On the one pass it applied the 400 m walk rule and checked the SVG's `data-run` and `data-place` elements before answering.

#### Mistakes it makes

- **No search algorithm.** In every multi-leg case it explored one run, platform or station pair at a time (`SELECT ... WHERE run = 'R...'`) instead of building an earliest-arrival search. That is the main reason for the 15 request-limit failures.
- **Missed rules.** In tools mode it ignored repeats and start or end walks. `one_vehicle` (tools) decided no journey existed, while code mode found one with a 399 m walk. `after_midnight` (tools) looked only at Saturday services and ignored Friday-night runs past 86400.
- **Answers that contradict themselves.** `meeting_point` (tools) named meeting station `Sb7b601aa`, but the second friend alights at a Niedersedlitz platform, and no SVG was written. `tour` (tools) neither starts nor ends at Hauptbahnhof and includes a 6-hour wait.
- **Stops too early.** Both `saturday_direct` runs settled on the first direct ride (`Ra7402f8f`) without a full search with changes.
- **Tool friction.** Tools runs repeatedly hit DuckDB parser errors on the reserved column `at`; `saturday_direct` lost about 20 requests to them before quoting `"at"`.

#### Tool calling compared with code mode

Both modes ended in the request limit about equally often (7 vs 8). Code mode got further: it modelled interpolation and repeats, produced the only pass, and came within a few requests of an answer on `walking_change`. Its own costs were 4–17 errors per run (tracebacks, f-string syntax), a `KeyError: None` from platforms without a station, and per-run `run_sql` calls in a loop that broke the 100-nested-call cap. Tools mode submitted more answers (3 vs 1), but all were wrong, and two broke the question's basic constraints. Code mode cost somewhat more per run (about $0.08 vs $0.06 on average).

## Runs

### one_vehicle

**Tool calling: error.** A single-vehicle trip from Lennéplatz to TU. It concluded that no run serves both stations (msgs 155-157) and kept re-checking that until the request limit. The correct answer needed a 399 m walk to platform `P0091960a`, which the code_mode run found. ($0.045, 80 requests, 6.4 min)
- Right: Correctly confirmed that no run calls at both stations' own platforms
- Mistake: It ignored the rule that allows a walk of up to 400 m at the start and end, so it never looked for platforms near Lennéplatz such as `P0091960a`
- Mistake: It spent its last requests re-verifying the zero-overlap result

**Code mode: passed.** It passed with `R27f8d4b1+2`, boarding `P0091960a` (a 399 m walk from Lennéplatz) at 29940 and arriving at TU `P6e8c05a2` at 30480. It found this by scanning walk-reachable platforms and repeat expansions, and it checked the SVG attributes before finishing. ($0.047, 66 requests, 6.8 min)
- Right: Applied the 400 m walk rule (walk times 399, 377, 357 to nearby platforms)
- Right: Expanded repeats into `+k` run names
- Right: Verified that the SVG contained the `data-run` and `data-place` elements (msg 130)
- Mistake: 14 errors along the way (syntax errors, an f-string format bug, an `IndexError` in interpolation) cost many of its 66 requests

### saturday_direct

**Tool calling: failed.** It answered `Ra7402f8f`, boarding `P7fa04a55` at 34320 and arriving at `P1093f876` at 35460. The answer failed. Its search joined only timed calls of base runs, with no repeats, no walks and no changes. ($0.031, 65 requests, 5.7 min)
- Right: Correct service-day filter: it used `days & 32` for Saturday and checked service_changes
- Right: Wrote a valid SVG with `data-place` and `data-run` elements
- Mistake: About 20 requests (msgs 35-58) went to DuckDB parser errors because `at` is a keyword. It only fixed them by quoting `"at"` at msg 57
- Mistake: Its final candidate query covered base runs only and never expanded `repeats.txt` into `+k` runs
- Mistake: It treated the first direct ride as earliest and never considered a change or a walk to a nearby platform

**Code mode: failed.** It found 68 direct rides with repeats and interpolation and chose `Ra7402f8f` (34320→35460), the same run as the tools mode. It gave departure 34200. Its transfer check was capped at `[:50]` stops and only looked at same-station platforms. The answer failed. ($0.047, 52 requests, 10.0 min)
- Right: Handled interpolation, repeats and walks within the start station
- Mistake: Its change search was partial: capped at 50 stops, same-station only, and run after a `ValueError` unpack bug (msg 96). It never ran a full earliest-arrival search with changes
- Mistake: The reported departure of 34200 does not follow from any walk it computed (the walk to `P7fa04a55` was at most 59 s)

### one_change

**Tool calling: error.** Earliest journey from Gret-Palucca-Straße to Pirnaischer Platz with at most 2 vehicles. It traced intermediate platforms of `R27f8d4b1` and candidate second runs like `R07222b02` one query at a time and ran out of requests. ($0.096, 80 requests, 9.6 min)
- Right: Few errors (3)
- Right: Reasoned about call order (`n`) along a run
- Mistake: It searched second legs by manually inspecting single runs (msgs 151-157) instead of joining all first-leg alight calls to all second-leg boarding calls with the 120 s plus walk margin
- Mistake: It never expanded repeats

**Code mode: error.** It looked for shared platforms between origin runs and destination runs and found `Overlap: 0` with timing filters and 39 common platforms without them. It ran out of requests before building a journey. This was its most expensive code_mode run at $0.106. ($0.11, 80 requests, 13.2 min)
- Right: Checked call order (dest after shared platform) in its pair search
- Mistake: 12 tracebacks
- Mistake: It used set intersections instead of a time-respecting 2-leg search with walks

### walking_change

**Tool calling: error.** Earliest trip from Chemnitzer Straße to Marienberger Straße. It checked runs one at a time (`R782868bc`, `Re5215f58`, line `L62735a6d`) with `CAST("at" AS INTEGER)` queries and ran out of requests. ($0.074, 80 requests, 8.4 min)
- Right: Quoted `"at"` after early errors
- Mistake: 4 parser errors on `at`
- Mistake: It did manual run-by-run exploration with no general transfer or walk search

**Code mode: error.** It had settled on two legs, `R76d2117b+6` then `R3a0dccd4+56`, and was looking up their repeat definitions when the 80-request limit hit. It never submitted the answer or the SVG. ($0.091, 80 requests, 11.4 min)
- Right: Found a 2-leg journey with correct `+k` repeat naming
- Mistake: It spent its last requests on single-row `repeats` lookups instead of finishing
- Mistake: It needed to reserve requests to write the SVG and the final answer

### after_midnight

**Tool calling: error.** Asked for the earliest journey from Reichenbachstraße at 01:10 on Saturday. It spent 80 requests on one-off `run_sql` probes (counting runs, joining origin and destination runs, which returned `count = 0`) and never built a search. It hit the request limit with no answer. ($0.037, 80 requests, 6.0 min)
- Right: Read DATA.md and found the platforms of both stations
- Mistake: It filtered to Saturday services only (`service IN ('V97ebea07','Va19c0692',...)`, msg 155). For a 01:10 start, Friday's service-day runs with `at` > 86400 also have to be considered
- Mistake: It hit 5 DuckDB parser errors from the unquoted reserved column `at`
- Mistake: Once no direct run existed (msg 152), it kept listing common platforms one query at a time instead of writing a transfer search in a single query

**Code mode: error.** It built interpolated call times for 1339 runs in Python, found no direct connection, and computed 3541 first legs. It was still indexing second-leg departures (`Platforms with departures: 260`) when the request limit hit. ($0.058, 80 requests, 9.1 min)
- Right: Implemented untimed-call interpolation and repeat expansion
- Right: Got to a real 2-leg search structure
- Mistake: 13 errors, including 7 tracebacks and 6 SQL parser errors, used up requests
- Mistake: It built the search incrementally across many `run_code` calls instead of one routing function

### arrive_by

**Tool calling: error.** Latest departure from Pohlandplatz that still reaches Lennéplatz by 18:00. It worked leg by leg with hand-written CTEs, checking runs like `Rbbeb518e` one at a time. It ended on a `Binder Error: Ambiguous reference to column name "run"` and ran out of requests. ($0.050, 80 requests, 7.0 min)
- Right: Loaded the tables into named DuckDB tables (`calls`, `places`) and quoted `"at"` correctly later in the run
- Mistake: 9 errors, 3 of them parser errors on `at`
- Mistake: It never handled repeats or untimed calls systematically, and never produced a single query that searched both legs
- Mistake: Its last query (msg 157) failed on an unqualified `run` in a join

**Code mode: error.** It reloaded the data several times ("intermittent SQL issues") and was debugging why run `Rf0e36679` showed 0 timed stops when it ran out of requests. ($0.077, 80 requests, 9.8 min)
- Right: Loaded repeats (200 definitions) and coordinates for both stations
- Mistake: It misdiagnosed its own bug as SQL flakiness and rewrote its loaders repeatedly (msgs 153-158)
- Mistake: It never got to a search

### departure_profile

**Tool calling: error.** List the non-dominated journeys from Marienberger Straße to Altpieschen between 07:00 and 08:00. It hand-searched for walking transfers by eyeballing coordinates and ran out of requests with no answer. ($0.056, 80 requests, 9.3 min)
- Right: Spotted its own wrong distance calculation for `P5bdda7ca` (msg 153)
- Mistake: It computed transfer candidates by hand, one place at a time (msgs 151-157), instead of building a time-dependent search
- Mistake: It produced no journeys and no SVG

**Code mode: error.** It loaded calls for 200 relevant runs, confused itself over a seconds-to-hours print (26580 s), and then hit `Code mode allows 100 nested tool calls per run_code call` by calling `run_sql` once per run inside a loop. It ran out of requests. ($0.075, 80 requests, 9.6 min)
- Right: Correctly concluded that no single run serves both stations
- Mistake: 11 tracebacks
- Mistake: It made per-run `await run_sql(...)` calls in a loop instead of one bulk query
- Mistake: It wasted requests re-checking its own time formatting

### meeting_point

**Tool calling: failed.** It returned station `Sb7b601aa` at 35880. The first friend's leg ends at `Pf8cab82c` (Bühlau, station Sb7b601aa) at 33240. The second friend's leg ends at `P14ffc7ac`, which belongs to Niedersedlitz (`Seebf7eb0`). The answer contradicts itself, and no SVG was written (`svg: null`). ($0.066, 70 requests, 7.7 min)
- Right: Looked up the platforms' station ids (msgs 131-138), which showed the mismatch
- Mistake: It picked one long run per traveller (`R465985dd`, `Rfa439a34`) and stopped there without searching for meeting stations
- Mistake: It claimed the friends met at a station the second friend never reaches, even though its own lookup in msg 138 showed `P14ffc7ac` belongs to `Seebf7eb0`
- Mistake: It never wrote /out/journey.svg

**Code mode: error.** It parsed files with `open()` and computed station walk times. Its last steps found `Station pairs reachable by walk: 0`, then failed with `KeyError: None` because `all_stations` included the `None` station of platforms that have no station. It ran out of requests. ($0.075, 80 requests, 10.7 min)
- Right: Read /data files directly in Python, avoiding SQL keyword issues
- Mistake: 17 errors and 14 tracebacks, the most of any case
- Mistake: It mixed state between re-defined variables (`station_platforms` and `all_stations`), which caused the walk-pairs bug

### timed_tour

**Tool calling: error.** A round trip from Pirnaischer Platz with opening-time windows. It probed station pairs (for example Pirnaischer Platz to Prohlis) with ad-hoc SQL and `EXISTS` subqueries and ran out of requests. This was the most expensive tools run at $0.15. ($0.15, 80 requests, 14.6 min)
- Right: Narrowed the search to the relevant services
- Mistake: It had no plan for ordering the visits and checked pair connections one at a time
- Mistake: It produced no answer

**Code mode: error.** It was enumerating repeat variants such as `R20f18e60+26` and `R1aabe4da+10` that pass Pohlandplatz and Mickten in their open windows when it hit the limit. This was the most expensive case at $0.133. ($0.13, 80 requests, 14.0 min)
- Right: Tied repeat offsets to the opening windows
- Mistake: It searched by hand, run family by family, instead of a general search over visit orders
- Mistake: It produced no answer

### tour

**Tool calling: failed.** It returned a 5-leg tour that never returns to Hauptbahnhof. The first leg boards at `Pb4e674b9`, a Julius-Vahlteich-Str. platform, not Hauptbahnhof. The trip ends at Marienberger Straße at 69900 after waiting about 6 h at Waldschlößchen (arrive 47220, leave 68940). It finished in only 39 requests. ($0.041, 39 requests, 6.0 min)
- Right: Wrote an SVG and gave per-visit arrival and departure times
- Mistake: It wrote the SVG at msg 71 before it had a feasible plan, then output a plan that breaks the question: no return to Hauptbahnhof (S593de5bc) and a start from the wrong station
- Mistake: It never searched visit orders or checked connectivity between consecutive legs

**Code mode: error.** It was still checking which runs visit both Julius-Vahlteich-Str. and Marienberger Straße (`Raec2024e`, `R5257428e`, with untimed `at=None`) when it ran out of requests. ($0.10, 80 requests, 12.8 min)
- Right: Recognised untimed calls in the data
- Mistake: It explored pairwise run coverage and never built a tour solver
- Mistake: 6 tracebacks
