---
title: "Qwen3.8 27B 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 0%; rank 38 of 44."
canonical: https://pydantic.dev/models/list/qwen3.8-27b/sql_data_analysis/
---

# Qwen3.8 27B 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 0%; rank 38 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/qwen3.8-27b/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.8-27b/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time      |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | --------- |
| Tool calling | 0%    | 0 of 10      | $2.37 | 375      | 429        | 108.4 min |
| Code mode    | 0%    | 0 of 10      | $1.50 | 186      | 190        | 77.9 min  |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

The model (Qwen3.8-27B-FP8) failed all 20 cases: 0 of 10 in tools mode and 0 of 10 in code mode. None of the runs produced a valid SVG: 18 returned `svg: null`, and the two files written were empty or contained only a bare `<svg>`. Cost was about $2.37 in tools mode and $1.50 in code mode.

#### Where it does well

- Its reasoning about the rules is often good. It read DATA.md and got the active services right, including spotting that the two `service_changes` rows name services that do not exist. It derived an exact integer `ceil(sqrt)`, worked out the Pareto dominance rule for departure_profile, and handled previous-day runs for after_midnight.
- It finds its own bugs when it checks itself:
  - a `[6:]` slicing error (meeting_point, code mode)
  - an inner loop variable `b` overwriting the outer run id (walking_change, code mode)
  - a `0x7FFF` bit mask that should have been `0x1FFFF` (timed_tour, code mode)
- In timed_tour (code mode) it built a working search and checked an itinerary arriving at 44160 against every opening window.

#### Mistakes it makes

- **Calls `final_result` too early, with an empty answer (10 cases).** Its reasoning says 'let me look at more data' or 'create the tables next', and then it calls `final_result` with `legs: []` and times of 0. This happened in arrive_by, departure_profile, one_change, one_vehicle, saturday_direct and tour (tools mode) and in arrive_by, departure_profile, one_change and after_midnight (code mode). It treats the answer tool as just another step.
- **Makes up answers (8 cases).** It invented ids such as `P1a2b3c`, `P_114` and `L136f8a`, run names such as `R27fdc8d0+0`, or journeys that no query produced. In walking_change (tools mode) its own analysis had found an arrival of 63480, yet it submitted a different 3-leg trip arriving at 93360. In timed_tour (code mode) it replaced its correctly computed ids with `P00000001` and with `R0a1b2c3d`, the example run id from DATA.md.
- **Runs out of limits (2 cases).** after_midnight (tools mode) used up all 80 requests while still on the interpolation step. timed_tour (tools mode) ended with `OutputTokenLimitExceeded`.
- **Coding errors and slips:**
  - `at` left unquoted in DuckDB
  - SQL statements run without `;` separators
  - plain English pasted as code
  - wrong function names (`async_blueprint` instead of `main`)
  - using `heapq`, which the sandbox does not have
  - converting 01:10 to 370 s instead of 4200

#### Tool calling compared with code mode

Neither mode solved anything. Code mode cost less ($1.50 against $2.37) and used fewer requests, but it made up more answers (6 against 2). Tools mode more often submitted zeros (6 against 4). Code mode added sandbox-specific errors: a stray `done` line, a missing `heapq`, and confusion about which variables still existed. Its best effort, timed_tour, got closest of all 20 runs to a real answer, but it was spoiled at the last step when it submitted placeholder ids.

## Runs

### one_vehicle

**Tool calling: failed.** Over 56 requests the agent built tables of walk distances to the origin and destination. Its reasoning then said 'Let me list them out', and instead it submitted an empty answer with times 0. ($0.43, 56 requests, 27.3 min)
- Right: Caught its own typo, `p.north - ds.east`, and reran the query
- Mistake: Computed the walk ceiling as `ROUND(SQRT(d2))`, then added 1 when the value is not a perfect square. That is wrong whenever the root rounds up
- Mistake: Never searched the direct runs, even though a direct trip on one vehicle is a simple join
- Mistake: Called `final_result` with an empty answer while still exploring

**Code mode: failed.** The agent's table-creation cell crashed on a stray `done` line. It assumed the tables existed and immediately submitted an invented journey: run `f3a4e1c2+3`, platforms `P_114` and `P_27`, departing 29885. ($0.0071, 8 requests, 10 s)
- Right: Called `run_sql` correctly from inside `run_code`
- Mistake: Ran pointless cells such as `import asyncio` on its own
- Mistake: Fabricated ids that do not match the dataset format
- Mistake: Departure 29885 is after the 08:10 start, yet no data supported it

### saturday_direct

**Tool calling: failed.** The agent computed the cumulative distance along each run with `LEAD` and window sums (`stops_s`, 48428 rows). While planning the interpolation, it called `final_result` with empty legs. ($0.030, 15 requests, 43 s)
- Right: Computed the distance along the run correctly with a window `SUM` over ceiling-rounded segments
- Mistake: Called `final_result` with zeros right after describing the next SQL step

**Code mode: failed.** After repeated `NameError`s (`r2`, then `async_blueprint` instead of `main`), the agent submitted an invented 2-leg answer: `R0012e563+19`, then `R06d235b2+2`, arriving 35520. ($0.072, 12 requests, 1.7 min)
- Right: Started materialising a `svc_on` table of (service, day) pairs for days 338 to 340
- Mistake: Called a function by the wrong name and left stray lines in cells
- Mistake: Submitted a journey without having run any search

### one_change

**Tool calling: failed.** The agent wrote an empty `<svg>` early on, created only the `places` table, and then called `final_result` with empty legs. Its reasoning at that point said it was about to create the other tables. ($0.0070, 10 requests, 10 s)
- Right: Recovered from the multi-statement parse error by running statements one at a time
- Mistake: Tried to read a file that does not exist, `/data/schedules.txt`
- Mistake: Wrote a placeholder `<svg width="800" height="600"></svg>` with no data
- Mistake: Called `final_result` with zeros after loading a single table

**Code mode: failed.** The agent once pasted plain English into `run_code`, which caused a SyntaxError. After confirming that `run_sql` works with `SELECT 1`, it submitted an empty answer. ($0.031, 7 requests, 61 s)
- Right: Checked how to call the tools from inside the sandbox
- Mistake: Sent plain English as code
- Mistake: Called `final_result` with zeros immediately after saying 'Let's create a table'

### walking_change

**Tool calling: failed.** The agent's analysis found a journey arriving at 63480: bus 62 on `R76d2117b+4`, then tram 2 on `R3a0dccd4+54`. It then submitted an unrelated 3-leg answer that departs at 84120 and arrives at 93360, with the malformed run id `R0ebe01dcd+5`. It also wrote an empty SVG. ($0.28, 46 requests, 5.2 min)
- Right: Worked out walks and transfer margins correctly in its reasoning (for example 61920+120+341 ≤ 62458)
- Mistake: Submitted a final answer that contradicts its own finding (17:38 arrival) and uses invented runs
- Mistake: Wrote a 0-byte `/out/journey.svg`
- Mistake: Did not notice that a multi-statement `run_sql` returns only the result of the last statement until late in the run

**Code mode: failed.** The agent found a real bug, an inner loop variable `b` overwriting the outer run id, which left only 497 of 3973 base runs. Instead of rerunning, it submitted an invented 2-leg answer that includes the invalid run name `R27fdc8d0+0`. ($0.14, 25 requests, 26.7 min)
- Right: Found the bug through a consistency check between SQL and Python (81040 rows against 3603)
- Mistake: Submitted a journey that was never computed
- Mistake: Used the run name `+0`, which breaks the naming rules (the first run has no suffix)

### after_midnight

**Tool calling: error.** The agent spent all 80 requests building the timetable in SQL, one small step at a time. It was still writing the untimed-call interpolation when it hit `UsageLimitExceeded`, and it never searched for a route. ($0.19, 80 requests, 18.2 min)
- Right: Read DATA.md and planned the repeat expansion and the interpolation correctly in its reasoning
- Mistake: Wasted requests on probes and rereads: it read `places.txt` again for no reason, then ran `select 1 as x from (select 1 as y)` just to check that subqueries parse
- Mistake: Took around 75 requests to reach the interpolation step, so the budget was gone before any journey search

**Code mode: failed.** The agent built the platforms, walk edges and a Dijkstra in Python, but converted 01:10 to `T0 = 370` instead of 4200. When `import heapq` failed, it planned a hand-written heap and then submitted `legs: []` with times 370. ($0.16, 15 requests, 4.2 min)
- Right: Considered runs from the previous service day (2026-338) for an after-midnight start
- Right: Designed a careful time-dependent Dijkstra with 120 s transfer margins
- Mistake: Wrong time conversion: 01:10 is 4200 s, not 370
- Mistake: Used `heapq`, which the sandbox does not provide
- Mistake: Called `final_result` with a placeholder right after deciding to rewrite the code

### arrive_by

**Tool calling: failed.** After 7 requests, spent listing files twice and reading DATA.md and the small files, the agent called `final_result` with `legs: []` and times 0. Its own reasoning had just said 'Let me look at more data'. ($0.0063, 7 requests, 8 s)
- Right: Read DATA.md and the small files first
- Mistake: Called `list_files` twice in a row
- Mistake: Called `final_result` with a placeholder answer as if it were an exploration step, before loading any table
- Mistake: Wrote no SVG

**Code mode: failed.** Its sandbox state got confused: it hit a `NameError` on `a`, then 'probed' state by printing a list literal of names. It then submitted an empty answer with times 0. ($0.16, 18 requests, 4.3 min)
- Right: Loaded several tables into Python structures early on
- Mistake: Lost track of which variables existed and probed them in a meaningless way
- Mistake: Called `final_result` with zeros mid-debugging

### departure_profile

**Tool calling: failed.** The agent wrote a long and largely sound plan for a Pareto search over (departure, arrival). Its first multi-statement `CREATE TABLE` failed because `at` was not quoted. It then submitted `journeys:[{legs:[],departure:0,arrival:0}]` while its reasoning was planning the fix. ($0.16, 12 requests, 4.4 min)
- Right: Worked out the active services for 2026-342 correctly, and spotted that the two service_changes rows name services that do not exist
- Right: Worked out an exact integer ceil of the square root, and the right semantics for the walk at the start
- Mistake: Did not quote the reserved column name `at`: `CASE WHEN at IS NULL` raised a ParserException
- Mistake: Called `final_result` with an empty answer right after deciding to reload the data with `all_varchar`

**Code mode: failed.** In only 2 requests the agent read DATA.md and wrote a long, mostly correct plan: enumerate first vehicles, run earliest arrival for each, then filter with a Pareto check. It ended its reasoning with 'Step 1: create tables + count' and called `final_result` with `journeys: []`. ($0.033, 2 requests, 67 s)
- Right: Correctly reasoned that the minimum arrival for each first vehicle is enough to check dominance
- Right: Noticed the sandbox limits (no `heapq`, a 200-row cap)
- Mistake: Submitted an empty answer instead of running step 1

### meeting_point

**Tool calling: failed.** The agent built a label-setting search in SQL that runs round by round (`lb`, `pre` and `wins` tables) and reached round T=32460. It then submitted, in the same response, an invented answer: run `L136f8a` (a line-style id), platforms `P1a2b3c` and `P4d5e6f`, and station S2a8c1b68, which is one friend's own starting point. ($0.26, 50 requests, 21.5 min)
- Right: Built a working round-by-round frontier search with predecessor tracking in DuckDB
- Mistake: Sent `final_result` with made-up ids in the same response as the next round's `run_sql`
- Mistake: The meeting time of 32460 came from a partial frontier, not from finished results

**Code mode: failed.** The agent fixed a slicing bug in its service-day check (2072 runs active on day 339, 3973 on day 338) and planned how to build the stop list. It then submitted an invented answer: station `Sc921c3c6` at 35837, and a second journey with no legs. ($0.19, 24 requests, 24.3 min)
- Right: Found the `[6:]` versus `[5:]` slicing bug when the count of active runs came out as zero
- Right: Estimated the problem size sensibly
- Mistake: Gave a final answer that no computation produced; the second friend has no legs but arrives at 35837
- Mistake: Wrote no SVG

### timed_tour

**Tool calling: error.** The agent built a timetable table (`rel`) and was checking departures from Pohlandplatz by hand when, after 79 requests and $0.89, the model hit `OutputTokenLimitExceeded`. No answer was produced. ($0.89, 79 requests, 28.4 min)
- Right: Built an expanded timetable with run names that include the `+k` suffix, and access codes
- Mistake: Explored by hand station by station instead of writing a search, and reread `service_changes.txt` late in the run
- Mistake: Its final generation went over the output token limit

**Code mode: failed.** Over 69 requests the agent built a full search, debugged a bit-packing mask bug (`0x7FFF` instead of `0x1FFFF`), and checked an itinerary arriving at 44160 against every opening window. It then submitted the right times but placeholder ids (`P00000001`, `S00000001`, `R0a1b2c3d`), and it dropped the `+8`, `+10` and `+34` repeat suffixes. ($0.68, 69 requests, 13.7 min)
- Right: Implemented a working search over visit order with opening windows and walk-adjusted departures
- Right: Found the decoding bug where 35640 - 2872 = 2^15
- Right: Checked each 15-minute stay against its window by hand (for example 941 s at Mickten)
- Mistake: Replaced the real ids in `final_result` with dummy ones, including the example run id from DATA.md
- Mistake: Gave runs without their repeat suffixes (`Rf679205e` instead of `Rf679205e+8`)
- Mistake: Wrote no SVG

### tour

**Tool calling: failed.** The agent read DATA.md again (in total it read DATA.md several times), wrote out a step-by-step plan, and then called `final_result` with `legs: []`, `visits: []` and `arrival: 0`. ($0.11, 20 requests, 2.5 min)
- Right: Laid out a sensible pipeline: active runs, interpolation, edges between stations, then DP
- Mistake: Kept rereading DATA.md
- Mistake: Submitted a placeholder answer instead of running step 1 of its plan

**Code mode: failed.** The agent made a syntax-error typo (`read())))`), then submitted an invented single-leg answer, `R129b49ba` from 36120 to 36180, with no visits. ($0.028, 6 requests, 42 s)
- Mistake: Did no computation at all before answering
- Mistake: The answer visits none of the 5 required stations
