---
title: "GPT-5.6 Luna 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 20%, code mode 20%; rank 30 of 44."
canonical: https://pydantic.dev/models/list/gpt-5.6-luna/sql_data_analysis/
---

# GPT-5.6 Luna 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 20%, code mode 20%; rank 30 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/gpt-5.6-luna/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/gpt-5.6-luna/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 20%   | 2 of 10      | $0.25 | 217      | 250        | 16.9 min |
| Code mode    | 20%   | 2 of 10      | $0.33 | 314      | 314        | 25.7 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

gpt-5.6-luna passed 4 of 20 cases. In tools mode it passed 2 of 10 (`arrive_by`, `walking_change`); in code mode it passed 2 of 10 (`one_vehicle`, `saturday_direct`). No two cases passed in both modes. Total cost was about $0.25 for tools and $0.33 for code mode. On average a case took 22 requests in tools mode and 31 in code mode.

#### Where it does well

- It read `DATA.md` first every time. In most runs it expanded `repeats.txt` correctly into `<run>+<k>` names.
- The SVGs were nearly always well formed, with `data-place` and `data-run` on the right elements.
- When it did build a real search, it was capable: code-mode `meeting_point` had an iterative label search with a walk table, and it fixed its own bug with repeated runs.

#### Mistakes it makes

- **Dropping untimed calls.** In 4 cases (`saturday_direct` and `meeting_point` in tools mode, `one_change` in both modes) it filtered `at IS NOT NULL` instead of interpolating. In `saturday_direct` this hid the correct run, Rb28d92d7 at 33484.
- **Breaking walk rules.** Tools-mode `one_vehicle` ignored the walk allowed at the start and answered with no journey, although a 399 m walk works. Code-mode `arrive_by` boarded 63 s too early after a change, ignoring the 120 s plus walk margin. Tools-mode `timed_tour` stayed 300 s at a stop that needs 900 s.
- **Giving up with empty answers.** All three empty answers came from searches that found nothing: `tour` in both modes and code-mode `timed_tour` submitted `arrival: 0`. Tools-mode `after_midnight` submitted a change it had not checked.
- **Misreading the time.** Code-mode `meeting_point` used `9000` seconds for 09:00, so the whole answer was for the wrong start time.
- **Browsing instead of searching.** In `after_midnight` (both modes) and code-mode `walking_change` it looked up runs one at a time and accepted waits of hours.

#### Tool calling compared with code mode

The scores were the same, 2 of 10 each, but code mode cost about 30% more and used more requests. Code mode handled interpolation and walks at the start better and won the two direct-trip cases. It also found much faster `departure_profile` journeys, though that case still failed. However, it rarely used Python to write an actual routing algorithm. It mostly sent `run_sql` calls from inside `run_code`, and the largest errors (the 9000 s start, the empty tours, a 67320 arrival where tools mode found 63480) happened in this mode. Tools mode was cheaper and did better on changes and arrive-by, but kept the `IS NOT NULL` shortcut.

## Runs

### one_vehicle

**Tool calling: failed.** It searched only for runs calling at Lennéplatz's own platforms and then at a TU platform. It found none and submitted an empty journey (`legs: []`, 29400/29400). Failed. ($0.023, 22 requests, 65 s)
- Right: Worked out which services run on Wednesday correctly
- Mistake: Steps 23–41: it ignored the rule that a journey may start with a walk of up to 400 m. Code mode walked 399 m to P0091960a and caught R27f8d4b1+2, arriving 30480
- Mistake: Submitted 'no journey' as an answer instead of widening the search

**Code mode: passed.** It walked 399 m to P0091960a and took R27f8d4b1+2 (29940 → 30480). Passed. ($0.016, 17 requests, 32 s)
- Right: Applied the walk-at-start rule right up to the 400 m limit
- Right: Used the repeated-run name correctly
- Mistake: The SVG label says 'walk 399 m/s'. This is cosmetic

### saturday_direct

**Tool calling: failed.** It found Ra7402f8f from Pa32f4668 (a 355 m walk) at 34200, arriving 35460. Failed: the correct answer was Rb28d92d7 at 33484 from the origin platform P7fa04a55. ($0.020, 15 requests, 55 s)
- Right: Considered walking to nearby platforms
- Right: Interpolated one untimed call by hand (step 19)
- Mistake: Step 11: its direct-run query required `c1.at IS NOT NULL`, which dropped the untimed origin call of Rb28d92d7 at P7fa04a55 (interpolated 33484)
- Mistake: Step 23: it saw Rb28d92d7 at Mosenstraße but wrongly decided it could not reach it, so it accepted a later run

**Code mode: passed.** It found Rb28d92d7 from P7fa04a55 at the interpolated time 33484, arriving 34560. Passed. ($0.028, 31 requests, 2.7 min)
- Right: Interpolated the untimed origin call correctly (33484)
- Mistake: Reported arrival 34582 while the leg alights at 34560 at the destination platform P1093f876. The extra walk was harmless here
- Mistake: Used 31 requests for a direct trip

### one_change

**Tool calling: failed.** A single SQL join over two vehicles gave Rb0356f0c+8 then R749e73aa, arriving 28740. Failed. ($0.017, 14 requests, 88 s)
- Right: Expanded repeats with `generate_series` and named runs `<run>+<k>`
- Right: Checked the change margin (72 m walk, 168 s to spare)
- Mistake: Its origin and destination CTEs filtered `c.at IS NOT NULL`, so it never interpolated the untimed calls and missed the faster options that use them

**Code mode: failed.** It submitted Raf072dfe+8 and then R156a8ca5, arriving 28800, 60 s later than tools mode. Failed. ($0.033, 36 requests, 3.6 min)
- Right: Expanded repeats
- Mistake: Its candidate query used `TRY_CAST(c.at AS INTEGER) IS NOT NULL`, which dropped untimed calls in the same way as tools mode
- Mistake: Spent 36 requests with no better result

### walking_change

**Tool calling: passed.** It found bus R76d2117b+4 and then, after a walk, tram R3a0dccd4+54, arriving 63480. Passed. ($0.018, 20 requests, 70 s)
- Right: Changed with a walk between two different platforms (P6e794064 → P72ccec8b)
- Right: Named both repeated runs correctly

**Code mode: failed.** It explored lines by hand (333, 4, 1, …) over 42 requests and submitted R3760c7cf and then R812c6a64, arriving 67320. Tools mode had found 63480. Failed. ($0.054, 42 requests, 2.8 min)
- Right: The journey it submitted keeps the change margin
- Mistake: Steps 55–81: guessed at routes via Hauptbahnhof and Prohlis instead of searching. It missed the bus-and-walk-to-tram connection that arrives 63480
- Mistake: Most expensive case ($0.054) and still a poor result

### after_midnight

**Tool calling: failed.** It looked through the timetable by hand with many `run_sql` lookups of single runs and never built a search. It submitted R712b6c84 (board 13980) and then Rc48ccec9 (board 17100, arrive 17400). Failed. ($0.035, 27 requests, 2.0 min)
- Right: Saw that the Friday services (`V3e8ce6ee`, `V479271d1`) with `at>=90000` were relevant to a 01:10 Saturday start
- Mistake: Steps 9–47: queried raw `calls.at` values and individual runs (`R712b6c84`, `Rc48ccec9`, `R1e302e00`, …). It never expanded `repeats.txt` and never ran a connection search
- Mistake: Its own reasoning at step 51 says it was 'unsure how to get from P4f to my next boarding point'. It still submitted a change from P4f3581e4 to P44b3422a without checking that the walk exists or is under 400 m
- Mistake: Departure 13980 means waiting from 01:10 until 03:53. It did not find any earlier night connection

**Code mode: failed.** It browsed runs by hand through `run_sql` inside `run_code`. It submitted Rca4e4824 (4380 → 4800) and then R5c208ab4 at 19860, arriving 20460, which is later than tools mode's 17400. Failed. ($0.044, 25 requests, 2.0 min)
- Right: Took the bus that leaves soon after 01:10 (board 4380)
- Mistake: Steps 31–47: looked at single runs and repeats ad hoc instead of writing a search, even though it had Python
- Mistake: Waited about 4.2 hours at Postplatz for line 68
- Mistake: The SVG draws the second leg from `P404abd46` and has no `data-place` for the boarding platform `Pfe2cf484`

### arrive_by

**Tool calling: passed.** It found the latest departure, 63284 (walk, then R1aabe4da+29 at 63360), with a change to R54c1ee76+5 that arrives 64500, plus a final walk to 64580. Passed. ($0.022, 21 requests, 2.0 min)
- Right: Named the repeated run correctly (`R1aabe4da+29`)
- Right: Left 120 s plus the walk at the change (alight 63900, board 64320)
- Right: Set departure to the boarding time minus the initial walk
- Mistake: Arrival 64580 includes a walk after alighting at P53270352, which by the rules is already a Lennéplatz platform. It was harmless here

**Code mode: failed.** It submitted R0e4beb23 boarding at 63660, alighting at P3b6efaff at 64200, then R54c1ee76+5 boarding at P6ea0167f at 64320. Failed. ($0.016, 19 requests, 82 s)
- Right: Found the same final leg (R54c1ee76+5) as the passing tools answer
- Mistake: The change is not valid: the walk from P3b6efaff to P6ea0167f is about 63 m, so the earliest boarding is 64200+120+63 = 64383, after the 64320 departure. It did not apply the 120 s plus walk margin

### departure_profile

**Tool calling: failed.** It gave a single journey, Rd49d751b to Prohlis (P68b78dbb) and then R6d8fa52a, arriving 32280. That is a long detour, and code mode found journeys arriving by 29580. Failed. ($0.040, 28 requests, 1.9 min)
- Right: Drew every platform of both stations with `data-place`
- Mistake: Listed only one journey for a 07:00–08:00 window that has several departures
- Mistake: The journey it chose is dominated: code mode found a 27365 departure that arrives at 29580, much earlier than 32280. This shows it had no proper earliest-arrival search

**Code mode: failed.** It listed two journeys, departing 27365 (arrive 29580) and 28565 (arrive 30780), both changing at a central platform. Failed. ($0.044, 33 requests, 2.4 min)
- Right: Found much faster journeys than tools mode
- Right: Set departure to the first boarding time minus the walk
- Mistake: The list is incomplete for 07:00–08:00: only two departures, so it probably missed other journeys worth taking. Its search was incomplete

### meeting_point

**Tool calling: failed.** It built reachability tables `ra`/`rb` in SQL and picked S29c8f148 at 33780, each friend riding one vehicle. Failed. ($0.022, 27 requests, 1.8 min)
- Right: Used the correct start time, 32400 (09:00)
- Right: Considered walks between platforms when computing station arrivals
- Mistake: Its search only kept arrivals from a few rounds (in its words, 'five rounds of counting'), and the reachability step skipped untimed calls (`IS NOT NULL` filter). The meeting time it found was not the soonest

**Code mode: failed.** It built a multi-round label search in DuckDB, but seeded it with start time `9000` seconds instead of 32400 (09:00). It answered S7e2190de at 16080 with departures of 9000. Failed. ($0.034, 43 requests, 5.0 min)
- Right: Built a working iterative label-setting search with a 400 m walk table `wp` and parent tracking
- Right: Found and fixed a bug where repeated runs had no time offset (steps 57–75)
- Mistake: Step 23 onward: `CAST(9000 AS BIGINT) arr` used 09:00 as 9000 s (02:30). The whole answer is for the wrong start time

### timed_tour

**Tool calling: failed.** It submitted a six-leg tour that returns at 48360, with the visits ordered TU, Pohlandplatz, Prohlis, Mickten. Failed. ($0.032, 17 requests, 1.6 min)
- Right: Produced a complete, well-formed tour with visit times and a full SVG
- Mistake: The Prohlis visit runs 42840→43140, only 300 s, which breaks the 15-minute (900 s) minimum stay
- Mistake: Planned the legs by hand, without a search over orders and connections

**Code mode: failed.** It pulled segment tables into Python and tried all visit orders over direct runs and two-vehicle options. Nothing was feasible, so it submitted an empty answer (`arrival: 0`) and an SVG of the stations only. Failed. ($0.029, 36 requests, 2.9 min)
- Right: Set up a permutation search with time windows (`win`) and the 900 s stay
- Mistake: Steps 49–67: the option set was capped (`limit 200` per pair, `d1>=30000`) and allowed at most two vehicles per hop, so no tour came out feasible
- Mistake: Submitted an empty answer instead of loosening those limits

### tour

**Tool calling: failed.** A recursive SQL over visit masks found no feasible tour, so it submitted `legs: [], visits: [], arrival: 0` and a blank SVG. Failed. ($0.024, 26 requests, 2.9 min)
- Right: Tried a bitmask state search (`mask`, `bit`) in DuckDB
- Mistake: Steps 29–47: its recursive query returned no complete tour, and it could not tell whether the joins or the 900 s stay condition were wrong
- Mistake: Gave up and submitted an empty answer instead of building a simpler search by visit order

**Code mode: failed.** It built `ev`/`legs` tables and generated per-order SQL. It found no valid tour and submitted an empty answer with a stations-only SVG. Failed. ($0.031, 32 requests, 2.5 min)
- Right: Expanded repeats and previous-day runs with a −86400 shift
- Mistake: Steps 41–57: every candidate order came back empty and it never found out why (it guessed the 120 s margin)
- Mistake: Gave up with `legs: [], visits: [], arrival: 0`
