---
title: "Kimi K2.6 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 90%; rank 30 of 44."
canonical: https://pydantic.dev/models/list/kimi-k2.6/sql_data_analysis/
---

# Kimi K2.6 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 90%; rank 30 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/kimi-k2.6/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/kimi-k2.6/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time      |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | --------- |
| Tool calling | 20%   | 2 of 10      | $6.10 | 730      | 741        | 123.8 min |
| Code mode    | 90%   | 9 of 10      | $6.47 | 529      | 529        | 167.2 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

Kimi K2.6 passed **11 of 20** runs. With plain tool calling it passed **2 of 10**; in code mode it passed **9 of 10**. All 9 failures were the same: it hit the **80-request limit** (`UsageLimitExceeded`) and never answered. There were no wrong answers and no provider errors. When it did answer, the answer passed.

#### Where it does well

- It read the data rules correctly: it chose services by weekday, expanded repeats into `+k` run ids, interpolated untimed calls, included runs past midnight, and handled walking changes.
- Its answers were correct across all question types in code mode: arrive-by, departure profile, meeting point, timed tour, and changes with walks.
- Its SVGs used the required coordinate formula and `data-place`/`data-run` attributes, and drew walks without a `data-run`.

#### Mistakes it makes

- **It keeps exploring after it has the answer.** In tool mode `after_midnight` its thinking already had the correct arrival, 6420, but it kept checking later boardings. In code mode `tour` it found a return at 50340 around step 109, then spent its last requests verifying and re-running a script that failed with a type error.
- **It looks things up one at a time.** In tool mode `one_change` it made about 75 `run_sql` calls, many of them single-row lookups (`WHERE ref = 'P...'`) instead of one two-leg join. `arrive_by` and `tour` (tools) traced individual runs and lines by hand.
- **SQL and sandbox slips:** it left the reserved word `at` unquoted and got `ParserException` retries. It called the async `run_sql` without `await` and got empty results, costing about 16 requests in code-mode `tour`. It hit the 200-row cap on `run_sql` results in code-mode `one_vehicle`, which made a direct-run search come back empty.
- Even its passes used many requests: 35–70 per run, and code-mode `departure_profile` reached 70 requests and $1.36.

#### Tool calling compared with code mode

Code mode decided the outcome. In tool mode every SQL statement used one request, so building tables, debugging and checking used up the 80 requests on anything harder than a single vehicle. Only `one_vehicle` (51 requests) and `saturday_direct` (39) passed. In code mode it loaded the files into Python and wrote its own earliest-arrival search, so one request did far more work. Passes there took 35–70 requests, and only the hardest case, `tour`, ran out. Cost per run was similar in both modes ($0.27–$0.93 in tools, $0.31–$1.36 in code mode), but code mode turned that spend into answers.

## Runs

### one_vehicle

**Tool calling: passed.** It found bus 66 run `R27f8d4b1+2`, boarding `P0091960a` at 29940 and alighting at `P6e8c05a2` at 30480 after a walk. It drew a correct SVG and passed in 51 requests. ($0.32, 51 requests, 6.9 min)
- Right: It handled the walk to a platform at another station and the repeat offset `+2`
- Right: Its SVG coordinates match east/35 and 600 − north/35
- Mistake: 51 requests for a single-vehicle question is heavy

**Code mode: passed.** It reached the same answer as tool mode (`R27f8d4b1+2`, 29940→30480) and passed, but used 63 requests. ($0.55, 63 requests, 12.6 min)
- Right: The answer and SVG were correct
- Mistake: Steps 13–25: `run_sql` results were capped at 200 rows (`runs count 200`, `calls fetched 200`), so a direct-run search came back empty (`candidate base runs 0`) before it switched to reading the files in Python
- Mistake: It wrote a placeholder `<svg></svg>` first, then rewrote it

### saturday_direct

**Tool calling: passed.** It answered with Saturday line 9 run `Rb28d92d7`, boarding at 33484 and arriving at 34560, plus a minimal SVG. It passed in 39 requests. ($0.27, 39 requests, 5.5 min)
- Right: It chose the right service for a Saturday
- Right: Its SVG was small and had correct `data-place` and `data-run` attributes
- Mistake: It gave `departure` as the boarding time (33484), where code mode gave the journey start (33300). Both were accepted

**Code mode: passed.** It gave `Rb28d92d7`, boarding at 33484 and arriving at 34560, with departure 33300, and marked both the stations and the platforms in the SVG. It passed in 40 requests. ($0.35, 40 requests, 13.8 min)
- Right: It was correct and reasonably efficient

### one_change

**Tool calling: error.** It made about 75 `run_sql` calls: several `ParserException` retries on `CREATE TABLE`, building `run_instances` and `instance_calls`, then many lookups of single runs and places plus walking-distance checks. It never answered. The correct journey (arrival 28440 via `Rafeef850` then `R620ec7d9`) was within reach. ($0.59, 80 requests, 12.5 min)
- Right: It expanded the repeats correctly into a `run_instances` table (10183 rows) with interpolated call times
- Mistake: Steps 23–27 and 39–41: SQL syntax errors from leaving the reserved word `at` unquoted cost retries
- Mistake: Steps 79–157: it looked up runs and places one at a time (`SELECT ... WHERE ref = 'P...'`) instead of one two-leg join with walking transfers
- Mistake: It never wrote the SVG or a final answer

**Code mode: passed.** It found `Rafeef850` then a walk then `R620ec7d9`, arriving at 28440 within 2 vehicles, and drew the walk as a dashed line without a `data-run`. It passed in 52 requests. ($0.57, 52 requests, 13.7 min)
- Right: It kept walks out of the legs, as the rules require

### walking_change

**Tool calling: error.** Not reviewed. ($0.73, 80 requests, 13.7 min)

**Code mode: passed.** It returned `R76d2117b+4` to `P6e794064`, a short walk to `P72ccec8b`, then `R3a0dccd4+54` arriving at 63480. It passed in 55 requests. ($0.59, 55 requests, 13.5 min)
- Right: It handled the walking change between platforms of one station correctly

### after_midnight

**Tool calling: error.** It built DuckDB tables with one `run_sql` call per step. By its last messages it had found a best arrival of 6420, the same arrival as the passing code-mode answer. It was still checking leg-1 boardings after 20000 when it hit the 80-request limit without answering. ($0.65, 80 requests, 14.5 min)
- Right: Its thinking near the end named the correct earliest arrival, 6420
- Right: It handled the Friday-night runs that continue past midnight into Saturday
- Mistake: Near the end (message 157) it spent its last requests re-checking boardings after 20000 instead of stopping to write the SVG and answer
- Mistake: Each SQL probe used a whole request, so the budget went on exploration

**Code mode: passed.** It wrote a Python earliest-arrival search covering Friday runs past midnight. It returned two legs (`R93fefd15`, then `R900bf42f+2`) arriving at 6420 and passed in 41 requests. ($0.47, 41 requests, 13.3 min)
- Right: It included Friday runs past midnight on the Saturday
- Right: It got the right answer in about half the request budget
- Mistake: The SVG drew every platform and set a zoomed `viewBox`, so the output was about 156 KB. That was wasteful but accepted

### arrive_by

**Tool calling: error.** It reasoned run by run in `run_sql` about which runs head west, for example checking that `Rf0e36679` repeats pass Straßburger before Pohlandplatz, and never reached an answer before the 80-request limit. ($0.76, 80 requests, 12.0 min)
- Right: It reasoned correctly about the direction of runs and their `+k` repeats
- Mistake: It looked at individual runs by hand instead of running one query that scans all departures between 16:30 and 18:00 backwards from the deadline
- Mistake: It hit the limit while still exploring (cost $0.76)

**Code mode: passed.** It returned a latest-departure journey: `R1aabe4da+29` from 63360, a walk, then `Rfd6f9e2d+67` arriving at 64440 before 18:00. It passed in 50 requests. ($0.68, 50 requests, 16.1 min)
- Right: It got the latest departure right, including a walking change

### departure_profile

**Tool calling: error.** It tried to build the departure profile as a chain of SQL tables (`leg2_all`, `leg2_pruned` with a `MIN() OVER` window to drop dominated journeys). It was still pruning tables at request 80. ($0.62, 80 requests, 13.4 min)
- Right: Its pruning idea, using a running minimum over earlier departures, was sound
- Mistake: Building a multi-leg profile search in SQL one statement per request was too slow for the 80-request budget

**Code mode: passed.** It listed every non-dominated two-leg journey leaving between 07:00 and 08:00, alternating between the `R77afbc0f` and `R45005fd8` departures. It passed but used 70 requests and cost $1.36. ($1.36, 70 requests, 28.0 min)
- Right: It removed dominated journeys correctly across the whole hour
- Mistake: Most expensive run in the benchmark ($1.36, 70 requests). It came close to the limit

### meeting_point

**Tool calling: error.** Late in the run it was still planning an iterative earliest-arrival method over 1,187 stations in SQL. It never produced a result. ($0.45, 80 requests, 12.2 min)
- Right: It saw that it needed earliest arrivals from both origins to every station
- Mistake: It only settled on an algorithm near the end of the budget, after many exploratory queries

**Code mode: passed.** It computed earliest arrivals from both friends and picked station `Sbb9212fa` at 33701, where the second friend arrives. It passed in 35 requests, the cheapest run ($0.31). ($0.31, 35 requests, 11.3 min)
- Right: It used one search per friend and took the earlier of the two latest arrivals
- Right: It marked every platform of the meeting station in the SVG

### timed_tour

**Tool calling: error.** It built state tables of the visited set and arrival time in SQL (`states_d5`, `visited = 15`). It was checking the final states when the 80-request limit hit. ($0.79, 80 requests, 15.2 min)
- Right: Its bitmask search over visit orders in SQL was a reasonable idea
- Mistake: It ran out of requests one step away from reading off the best tour, with no time left for the SVG or answer

**Code mode: passed.** It visited 4 stations over 5 legs and returned to the start at 44160, with a visit dwell recorded at each station. It passed in 43 requests. ($0.65, 43 requests, 17.3 min)
- Right: It searched visit orders in Python with minimum stay times

### tour

**Tool calling: error.** It worked out the tour by hand, line by line (for example bus 64 from Waldschlößchen to Trachenberger Platz, then line 4). It hit the limit at $0.93, the most expensive run. ($0.93, 80 requests, 18.0 min)
- Right: Its knowledge of the network was sensible
- Mistake: It tried to solve a visit-every-station problem by hand-picking lines one query at a time instead of computing earliest arrivals between every pair of stations

**Code mode: error.** It spent about 16 requests finding out that `run_sql` is async and returned `{}` or coroutine objects, then wrote its own heap and earliest-arrival search. It found a tour ending at 50340 around step 109 but kept checking (`Rb5b04dfd` service days). Its final rewrite at step 157 failed with a type error, and the 80-request limit hit. ($0.93, 80 requests, 27.6 min)
- Right: Its search over visit orders found a candidate best return of 50340 with the legs
- Mistake: Steps 7–31: repeated sync calls to the async `run_sql` that returned nothing
- Mistake: Steps 85–103: debugging its own Heap class and probing `time.perf_counter`
- Mistake: After finding 50340 it did not write the SVG and answer straight away; its re-run of the full script at step 157 had an `Unsupported -` type error
