---
title: "GPT-5.6 Terra 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 60%; rank 30 of 44."
canonical: https://pydantic.dev/models/list/gpt-5.6-terra/sql_data_analysis/
---

# GPT-5.6 Terra 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 60%; rank 30 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/gpt-5.6-terra/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-terra/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 20%   | 2 of 10      | $2.17 | 209      | 218        | 16.8 min |
| Code mode    | 60%   | 6 of 10      | $2.20 | 196      | 196        | 32.2 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

gpt-5.6-terra passed 8 of 20 cases: 2 of 10 in tool calling and 6 of 10 in code mode. The two modes cost about the same, $2.17 against $2.20. Most failures are valid-looking journeys that are not the best one, because a rule was skipped or the search was not complete. Only one run gave up.

#### Where it does well

- It reads DATA.md and gets the basics right: service-day filters, expanding `+k` repeats, the 400 m walk radius, and the SVG coordinate formula. Every SVG had `data-place` and `data-run`.
- Code mode builds the timetable systematically. It interpolates untimed calls (meeting_point, 33701), uses runs from the previous service day (after_midnight, 6420), and checks walk plus 120 s at changes (arrive_by).
- The simple single-route cases (one_vehicle, walking_change, one_change) were fast to solve whenever its timetable table was complete.

#### Mistakes it makes

- **Dropping or mishandling untimed calls (3 cases):** `WHERE c.at IS NOT NULL` in tools meeting_point, and similar filters in tools saturday_direct. In code-mode one_change, `dwell` stayed NULL at untimed calls, so they could never be boarded.
- **Skipping rules (2):** tools arrive_by left the walk out of the transfer margin (`o.xa+120`). Tools after_midnight left out service `V97ebea07` (days 48), which runs on Friday.
- **Incomplete search (5):** tools saturday_direct stopped at the direct tram. Tools departure_profile fixed `l.label='2'`. Tools timed_tour and tour picked visit orders by hand. Tools one_vehicle expanded the repeats of only one run.
- **Logic and copying errors (2):** code-mode departure_profile removed dominated journeys in the wrong direction and returned dominated ones. Code-mode saturday_direct found the right journey (35160) but wrote the boarding platform as the alighting platform.
- **Gave up (1):** code-mode tour hit the 30 s SQL limit with a bitmask search and returned an empty answer.
- **Recurring friction:** `run_sql` returns only the last statement's result, `at` causes parser errors, and the `lines` table went missing. Each cost the tools runs extra requests.

#### Tool calling compared with code mode

Code mode was clearly stronger: 6 passes against 2. With Python it could build a full Dijkstra, interpolate untimed calls and expand every repeat. Tool calling instead pieced journeys together from SQL joins of fixed depth plus mental arithmetic. In the 4 cases that passed only in code mode (after_midnight, arrive_by, meeting_point, one_vehicle), tool calling broke a specific rule or skipped a candidate. Tool calling won one_change, where code mode's dwell bug hid the untimed boarding. Both modes failed departure_profile, saturday_direct and tour. The tours were the hardest cases in both modes.

## Runs

### one_vehicle

**Tool calling: failed.** It listed direct runs from platforms near Lennéplatz to TU and worked out repeat departures by hand. It picked `Rf679205e+3` (board 30540, arrive 31080) and missed `R27f8d4b1+2` (board 29940, arrive 30480). Failed. ($0.065, 9 requests, 34 s)
- Right: Found the 399 m walk to Strehlener Platz `P0091960a` and the earliest boarding time of 29799
- Right: Cheap run: 9 requests
- Mistake: Its query listed base runs with `every`/`count` but did not expand the repeats. It then expanded only `Rf679205e` in its head, though `R27f8d4b1` (base 27540, every 1200) gives the earlier `+2` departure at 29940.
- Mistake: Called the bus line 66 run a 'tram' in the SVG (cosmetic)

**Code mode: passed.** It found bus 66 `R27f8d4b1+2` boarding at 29940 and arriving at 30480. Passed. ($0.11, 10 requests, 20 s)
- Right: Expanded repeats systematically and so found the earlier run that the tools run missed
- Right: Cheap: 10 requests

### saturday_direct

**Tool calling: failed.** It found the direct tram 9 `Ra7402f8f` (34320 → 35460) and looked through nearby boarding options, but never did a full search for journeys with a change. Code mode shows a bus 64 + tram 6 journey arriving at 35160. Failed. ($0.093, 13 requests, 46 s)
- Right: Correct service filter for Saturday, repeat expansion and walk radius around the origin
- Mistake: Stopped at the first plausible direct answer instead of searching all journeys for the earliest arrival
- Mistake: A multi-statement `run_sql` returned only the last result and hid the nearby-platform list, which cost an extra call
- Mistake: Its first boarding query dropped untimed calls through `x.tm IS NOT NULL`

**Code mode: failed.** It found the faster journey: bus 64 `Rebc40153` from Mosenstraße, then tram 6 `Rb9c6fb68`, arriving at 35160. In the answer it wrote the alighting platform of the second leg as `P8f144634` (the boarding platform) instead of `Pbc692c0e`. Failed. ($0.14, 14 requests, 73 s)
- Right: Searched journeys with changes and found an earlier arrival (35160) than the direct tram (35460)
- Right: Its SVG placed the end point correctly, at Anton-/Leipziger Str. coordinates
- Mistake: Copying error in `final_result`: leg 2 `alight` is `P8f144634` instead of `Pbc692c0e` (Anton-/Leipziger Str., 35160)

### one_change

**Tool calling: passed.** It found a 2-vehicle journey: `Rafeef850` boarding at the untimed call at 27669, then `R620ec7d9`, arriving at 28440. Passed. ($0.22, 19 requests, 87 s)
- Right: Handled interpolated untimed times, so it could board `Rafeef850` at 27669
- Right: Checked the 120 s + 72 m transfer at Straßburger Platz, and the SVG marks every platform
- Mistake: 19 requests with several retries after SQL errors. Nothing affected the result.

**Code mode: failed.** It built a `sched` table and searched 2-leg journeys, returning `Rb0356f0c+8` then `R749e73aa`, arriving at 28740. The tools run found 28440 by boarding `Rafeef850` at an untimed call. Failed. ($0.18, 17 requests, 84 s)
- Right: Tried to interpolate untimed calls (`ctimed` with `coalesce(a.at, ...)`) and expanded repeats
- Mistake: Its departure filter was `sc.arr+sc.dwell`, but `ctimed` filled in only `at`, so `dwell` stayed NULL at untimed calls. Boarding at untimed calls therefore looks impossible, and `Rafeef850` (27669) never appears in the conversation.
- Mistake: The answer's second leg alights at `P9d96d2d3`, while its own query showed `R749e73aa` reaching `P812a8483`. That is inconsistent.

### walking_change

**Tool calling: passed.** It found bus `R76d2117b+4` then tram `R3a0dccd4+54` with a walk between them, arriving at 63480. Passed. ($0.22, 23 requests, 1.9 min)
- Right: Correct earliest arrival, the same as code mode
- Right: Drew the walk as an unlabelled dashed path, and the legs with `data-run`
- Mistake: 23 requests, which is many for a 2-leg answer

**Code mode: passed.** Same runs as tools (`R76d2117b+4` then `R3a0dccd4+54`), changing via a different platform pair, arriving at 63480. Passed. ($0.22, 21 requests, 2.8 min)
- Right: Correct earliest arrival with a valid walk change

### after_midnight

**Tool calling: failed.** It searched by hand in SQL for a 01:10 Saturday start and returned a 4-leg journey arriving at 8400. Code mode found a 2-leg journey arriving at 6420 using `R93fefd15`, a run from Friday's service day. Failed. ($0.29, 25 requests, 1.9 min)
- Right: Understood that Friday service-day runs with times above 86400 count, and subtracted 86400 (`c.at+c.dwell-86400`)
- Right: The 4-leg chain it gave obeys the access letters (`YN`/`NY`), and it drew the walk between legs
- Mistake: When choosing Friday services it kept only `'V479271d1','V3e8ce6ee','V69c66ffb'`. It dropped `V97ebea07` (days 48 = Fri+Sat), even though its own query had just listed `R93fefd15` (`V97ebea07`) at `P99202dfd` at 91680 (= 5280).
- Mistake: So it never considered the faster 5280 → 6420 journey. It built a long bus/tram chain instead.
- Mistake: It lost time to `run_sql` returning only the last statement's result, and to a missing `lines` table

**Code mode: passed.** In code mode it included Friday service-day runs and found `R93fefd15` then `R900bf42f+2`, arriving at 6420. Passed. ($0.30, 29 requests, 2.3 min)
- Right: Correctly handled the previous service day: `V97ebea07` runs on Friday, and it subtracted 86400
- Right: Applied the walk plus transfer margin correctly at the change (5492 → 5700)
- Mistake: 29 requests, the most of any passing case

### arrive_by

**Tool calling: failed.** It built first-leg and second-leg tables in SQL and picked the departure at 63660 that arrives at 64500. The change at Straßburger Platz breaks the transfer margin. Failed. ($0.20, 19 requests, 1.8 min)
- Right: Correctly framed the question as latest departure with arrival ≤ 64800, not before 59400
- Right: Expanded repeats and checked walks at the origin and destination
- Mistake: Its transfer filter was `b.dep BETWEEN o.xa+120 AND 64800`, which leaves out the walk time. The change from `P3b6efaff` (arr 64200) to `P6ea0167f` is a walk of about 63 m, so the next vehicle had to leave at 64383 or later. `R54c1ee76+5` leaves at 64320.
- Mistake: The same result table listed the valid `R1aabe4da+29` → `Rfd6f9e2d+67` option (dep 63360, arr 64440), which is the passing code-mode answer

**Code mode: passed.** It returned `R1aabe4da+29` (dep 63360) then `Rfd6f9e2d+67`, arriving at 64440 by the 18:00 deadline. Passed. ($0.20, 16 requests, 76 s)
- Right: Its transfer check included the walk, so it rejected the 64320 connection that the tools run accepted

### departure_profile

**Tool calling: failed.** It returned a fixed series of journeys every 600 s on line 2 then line 4/13, from 25280 to 28280. These come from a query limited to particular line labels, so better journeys were missed and dominated ones kept. Failed. ($0.32, 30 requests, 3.3 min)
- Right: Built an expanded call table with interpolated untimed calls (`coalesce(a.at, ... floor(...))`)
- Right: Applied the 120 s + walk transfer rule in its pair query
- Mistake: Fixed the lines in advance with `l.label='2'` for the first leg and `l.label IN ('4','13')` for the second, instead of searching every route
- Mistake: As a result it missed journeys such as `R77afbc0f+4` → `R61625888` (leaving 25327, arriving 27420), which dominates its 25280 → 27960 entry
- Mistake: Its own reasoning noted that other lines could do better, but it still wrote the restricted answer (30 requests, the most expensive tools run after the two tours)

**Code mode: failed.** It wrote a Python Dijkstra over expanded runs, but its pass to remove dominated journeys went from earliest to latest departure. It returned 3 journeys whose arrivals get later as departures get earlier. Failed. ($0.20, 18 requests, 2.5 min)
- Right: Built the timetable correctly in Python: untimed calls interpolated, repeats expanded, nearby-platform lists
- Right: Got past type-checker errors in the sandbox by rewriting the code
- Mistake: `solve2(st, ceiling)` processed starts in increasing departure order, with the previous best arrival as a cap. Every later start was then pruned (`None`), and the earlier dominated journeys 25277 → 28428 and 25295 → 28020 were kept.
- Mistake: It should have scanned from the latest departure to the earliest, keeping a journey only if it arrives strictly earlier than every later-leaving one

### meeting_point

**Tool calling: failed.** It found one-vehicle and two-vehicle reachability for both friends and chose Bautzner/Rothenburger Str. at 33780. Both friends' runs pass Albertplatz earlier, at untimed calls, where the meeting is at 33701. Failed. ($0.12, 18 requests, 68 s)
- Right: Set the problem up correctly: the earliest arrival per station for each friend, with the meeting time as the maximum of the two
- Right: Included walks at the start and between vehicles
- Mistake: Built `ecalls` with `WHERE c.at IS NOT NULL`, which drops every untimed call. Albertplatz (`Sbb9212fa`) is reached at interpolated times 33701 and 33692 on the same runs `Rc0124950` and `Rfa439a34`, so it never appeared.
- Mistake: Should have interpolated untimed calls by distance, as DATA.md describes

**Code mode: passed.** It found Albertplatz `Sbb9212fa` at 33701, using interpolated arrival times on `Rc0124950` and `Rfa439a34`. Passed. ($0.14, 19 requests, 85 s)
- Right: Interpolated untimed calls, which was exactly what the tools run missed

### timed_tour

**Tool calling: failed.** It planned the tour with the order TU → Pohlandplatz → Mickten → Prohlis, by chaining station-to-station SQL queries, and got back at 49080. Code mode visited Prohlis first and got back at 44160. Failed. ($0.35, 26 requests, 2.0 min)
- Right: Respected the opening windows and the 15-minute stays, and built a `ridepairs` table for station-to-station rides
- Right: Its queries surfaced the Mickten → Pirnaischer Platz `R20f18e60+34` ride (43260 → 44160) used in the best answer
- Mistake: Fixed TU as the first visit and never compared all 24 visit orders
- Mistake: Considered putting Prohlis before Mickten in its reasoning, but only tried it after TU
- Mistake: Most expensive tools case: 26 requests, $0.35

**Code mode: passed.** It found the order Prohlis → TU → Pohlandplatz → Mickten within the opening windows and got back at 44160. Passed. ($0.28, 21 requests, 3.7 min)
- Right: Put the station without an opening window (Prohlis) first, which the tools run never tried
- Right: All visits fall inside their windows

### tour

**Tool calling: failed.** It built the 5-station tour by hand, one hop at a time with greedy station-to-station queries. It returned an 8-leg plan arriving at 59400 that includes an impossible zero-length leg. Failed. ($0.30, 27 requests, 2.0 min)
- Right: Expanded repeats into an `ec` table and found individual connections, such as tram 13 `Ree04d71d+6` from Altpieschen
- Mistake: Never searched visit orders. It chose the next stop greedily, and many direct station-to-station queries came back empty.
- Mistake: The final answer has leg `Rff85599c+18` boarding and alighting at the same `Pda4a5390` at 44880, which is not a real ride
- Mistake: Long waits (for example 44880 → 51000 at Waldschlößchen) show the plan was far from the earliest return

**Code mode: failed.** It tried a SQL label-setting search over visited-station bitmasks (`l2`). That hit the 30-second query limit, and it submitted an empty answer (`arrival` 0, no legs) with a placeholder SVG. Failed. ($0.41, 31 requests, 15.2 min)
- Right: Chose a sound state-space formulation: bitmask of visited stations plus place and time
- Mistake: The state table grew to over 1.8M rows and the iteration loop timed out (`the query was stopped after 30 seconds`). It could have pruned dominated labels, or run the search in Python as it did for departure_profile.
- Mistake: It had a partial mask-28 path but gave up and returned `{legs:[], visits:[], arrival:0}`; 31 requests, $0.41
