---
title: "Real sqlglot Bug Fix: 7 AI Models Graded | Straitly"
description: "Seven AI models at a real sqlglot bug fixed on 24 Nov 2026, after every model's release. Graded by running 70 rewrites on DuckDB."
url: https://straitly.ai/shootouts/real-bug-fix
updated: 2026-11-26
publisher: Straitly (https://straitly.ai)
---

# Fix a real open-source bug: 7 AI models, graded on 70 rewrites

None of the 7 models fixed it: 0 of 11 tries passed. GPT-6.2 Astra came closest, with 6 of 70 rewrites wrong. Each failure is below, in the grader's words, with the model's diff.

Updated 26 November 2026

[Who failed and why](#failed) [Next to the public boards ](#boards)

The task

Asked

Fix sqlglot issue #9314: the subquery unnesting rewrite wraps a scalar subquery in MAX() next to a window function, so the optimized SQL errors or returns the wrong rows.

Tries

0 of 11 passed, 1 to 3 tries a model

## Who failed, and why?

Each model's closest failed try: how far it got, the grader's own words and the start of its change to the library.

1. ### Claude Opus 5.5
0 of 1 try passed. Failed try: 9 of 70 rewrites wrong.
Fixed the 4 queries in the issue and stopped after 15 steps, but 9 of the 70 hidden rewrites still broke, mostly aggregates hiding in FILTER or DISTINCT ON.
**Grader, try 1:** 9 of 70 rewrites changed the result. Preserve a scalar subquery inside a window function's FILTER over grouped rows (BinderException). Preserve a scalar subquery in a query whose only aggregate is in DISTINCT ON (BinderException).
```
sqlglot/optimizer/unnest_subqueries.py
-            and (
-                parent_select.args.get("group")
-                or any(find_in_scope(select, exp.AggFunc) for select in parent_select.selects)
-            )
+            and _is_aggregate_select(parent_select)
```
2. ### GPT-6.2 Astra
0 of 1 try passed. Failed try: 6 of 70 rewrites wrong.
Closest of the seven: 6 of 70 hidden rewrites still broke, all edge cases (DISTINCT ON, sibling aggregates, an inner HAVING). Used all 50 steps.
**Grader, try 1:** 6 of 70 rewrites changed the result. Preserve a scalar subquery in a query whose only aggregate is in DISTINCT ON (BinderException). Preserve a scalar subquery with an anonymous aggregate in DISTINCT ON (BinderException).
Used all 50 tool steps without finishing.
```
sqlglot/optimizer/unnest_subqueries.py
-            and (
-                _has_aggregate_projection(parent)
-                or _has_order_aggregate(parent)
-                or parent.args.get("having")
-                or (
-                    (qualify := parent.args.get("qualify"))
-                    and projection_has_aggregate(qualify, parent.args.get("windows"))
-                )
-            )
+            and _is_aggregated(parent)
```
3. ### Gemini 4 Neon
0 of 1 try passed. Failed try: 14 of 70 rewrites wrong.
Fixed the window function case but 14 of 70 hidden rewrites still broke, including queries whose only aggregate sits in HAVING, ORDER BY or QUALIFY. Used all 50 steps.
**Grader, try 1:** 14 of 70 rewrites changed the result. Preserve a scalar subquery inside a window function's FILTER over grouped rows (BinderException). Scalar subquery next to a window function over ungrouped rows (BinderException).
Used all 50 tool steps without finishing.
4. ### Gemini 4 Carbon
0 of 1 try passed. Failed try: 14 of 70 rewrites wrong.
Same gap as Neon: 14 of 70 hidden rewrites still broke, mostly aggregates outside the SELECT list. Used all 50 steps.
**Grader, try 1:** 14 of 70 rewrites changed the result. Preserve a scalar subquery inside a window function's FILTER over grouped rows (BinderException). Scalar subquery next to a window function over ungrouped rows (BinderException).
Used all 50 tool steps without finishing.
5. ### Claude Fable 5.2
0 of 1 try passed. Failed try: 14 of 70 rewrites wrong.
On step 21 it spent the whole 16,000-token reply limit thinking and never sent the next edit, so the run ended with 14 of 70 hidden rewrites still broken.
**Grader, try 1:** 14 of 70 rewrites changed the result. Preserve a scalar subquery inside a window function's FILTER over grouped rows (BinderException). Scalar subquery next to a window function over ungrouped rows (BinderException).
One reply ran past the 16,000-token output limit, which ended the try.
6. ### DeepSeek V4.1 Flash 1017
0 of 3 tries passed. Closest failed try: 9 of 70 rewrites wrong.
0 of 3\. Its best try left 9 of 70 hidden rewrites broken, about where Opus and Kimi landed, for a few cents a try.
**Grader, try 1:** 9 of 70 rewrites changed the result. Preserve a scalar subquery inside a window function's FILTER over grouped rows (BinderException). Preserve a scalar subquery in a query whose only aggregate is in DISTINCT ON (BinderException).
Used all 50 tool steps without finishing.
```
sqlglot/optimizer/unnest_subqueries.py
-            and (
-                parent_select.args.get("group")
-                or any(find_in_scope(select, exp.AggFunc) for select in parent_select.selects)
-            )
+            and _is_aggregated(parent_select)
```
7. ### Kimi K3.1 Pro
0 of 3 tries passed. Closest failed try: 9 of 70 rewrites wrong.
0 of 3\. Each try fixed the issue's queries and added its own DuckDB checks, but hidden rewrites still broke every time.
**Grader, try 1:** 9 of 70 rewrites changed the result. Preserve a scalar subquery inside a window function's FILTER over grouped rows (BinderException). Preserve a scalar subquery in a query whose only aggregate is in DISTINCT ON (BinderException).
```
sqlglot/optimizer/unnest_subqueries.py
-            and (
-                _has_aggregate_projection(parent)
-                or _has_order_aggregate(parent)
-                or parent.args.get("having")
-                or (
-                    (qualify := parent.args.get("qualify"))
-                    and projection_has_aggregate(qualify, parent.args.get("windows"))
-                )
-            )
+            and _has_aggregate(parent)
```

### Every model, every try

| Model                             | Tries passed | Best try                | Median time | Median steps | List cost | Straitly price                                                 |
| --------------------------------- | ------------ | ----------------------- | ----------- | ------------ | --------- | -------------------------------------------------------------- |
| Claude Opus 5.5 Anthropic         | 0 of 1       | 9 of 70 rewrites wrong  | 6.6 min     | 15           | $0.42     | [$0.25](https://straitly.ai/models/claude-opus-5-5)            |
| GPT-6.2 Astra OpenAI              | 0 of 1       | 6 of 70 rewrites wrong  | 11.0 min    | 50           | $1.99     | [$1.20](https://straitly.ai/models/gpt-6.2-astra)              |
| Gemini 4 Neon Google              | 0 of 1       | 14 of 70 rewrites wrong | 6.8 min     | 50           | $1.10     | [See model page](https://straitly.ai/models/gemini-4-neon)     |
| Gemini 4 Carbon Google            | 0 of 1       | 14 of 70 rewrites wrong | 7.8 min     | 50           | $0.61     | $0.61                                                          |
| Claude Fable 5.2 Anthropic        | 0 of 1       | 14 of 70 rewrites wrong | 13.2 min    | 21           | $5.09     | [$3.05](https://straitly.ai/models/claude-fable-5.2)           |
| DeepSeek V4.1 Flash 1017 DeepSeek | 0 of 3       | 9 of 70 rewrites wrong  | 9.0 min     | 50           | $0.0519   | [$0.0210](https://straitly.ai/models/deepseek-v4-1-flash-1017) |
| Kimi K3.1 Pro Moonshot            | 0 of 3       | 9 of 70 rewrites wrong  | 10.7 min    | 29           | $0.37     | [$0.21](https://straitly.ai/models/kimi-k3.1-pro)              |

26 November 2026, 7:25 PM to 9:52 PM PT. Time is wall time for a whole try on our machine, tool runs included: one dated run, not a speed claim for any API. Both costs are for one try, the mean over a model's tries, at the maker's list price and at the Straitly catalog price that day. Gemini 4 Neon: see its model page.

## Do the public boards agree?

The Artificial Analysis Index, Terminal-Bench and ARC-AGI 2 run many tasks once each. This is one hard task, tried again and again.

Where we agree

Nowhere to agree on order: no model passed a single try, so this task cannot rank them. It does agree that the task is hard; Claude Fable 5.2, first on the AA Index, failed too.

Where we differ

The AA Index spreads these models from 65 down to 32; on this bug that gap did not show. The closest tries are in the failures above.

### Our run next to the public boards

| Model                             | Our tries passed | AA Index                                                                                                                                                                 | Terminal-Bench 4.1                                                                                                               | ARC-AGI 2                                                                                                                                                |
| --------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Claude Fable 5.2 Anthropic        | 0 of 1           | [65](https://artificialanalysis.ai/models/claude-fable-5-2 "Artificial Analysis Intelligence Index, max, default fallback reasoning effort, published 26 November 2026") | [65.8%](https://www.tbench.ai/leaderboard "Terminal-Bench 4.1, max effort, Claude Code agent, published 25 November 2026")       | [93.8%](https://arcprize.org/leaderboard "ARC-AGI 2, ARC Prize verified; default leaderboard view (best reasoning effort), published 9 November 2026")   |
| GPT-6.2 Astra OpenAI              | 0 of 1           | [62](https://artificialanalysis.ai/models/gpt-6-2-astra "Artificial Analysis Intelligence Index, max reasoning effort, published 26 November 2026")                      | [62.1%](https://www.tbench.ai/leaderboard "Terminal-Bench 4.1, max effort, Codex agent, published 25 November 2026")             | [95.8%](https://arcprize.org/leaderboard "ARC-AGI 2, ARC Prize verified; default leaderboard view (best reasoning effort), published 17 November 2026")  |
| Gemini 4 Neon Google              | 0 of 1           | [61](https://artificialanalysis.ai/models/gemini-4-neon "Artificial Analysis Intelligence Index, xhigh reasoning effort, published 26 November 2026")                    | [61.2%](https://www.tbench.ai/leaderboard "Terminal-Bench 4.1, xhigh effort, Antigravity CLI agent, published 25 November 2026") | [93.8%](https://arcprize.org/leaderboard "ARC-AGI 2, ARC Prize verified; default leaderboard view (best reasoning effort), published 18 November 2026")  |
| Gemini 4 Carbon Google            | 0 of 1           | [60](https://artificialanalysis.ai/models/gemini-4-carbon "Artificial Analysis Intelligence Index, high reasoning effort, published 26 November 2026")                   | [64.5%](https://www.tbench.ai/leaderboard "Terminal-Bench 4.1, high effort, Antigravity CLI agent, published 25 November 2026")  | [94.2%](https://arcprize.org/leaderboard "ARC-AGI 2, ARC Prize verified; default leaderboard view (best reasoning effort), published 10 November 2026")  |
| Claude Opus 5.5 Anthropic         | 0 of 1           | [59](https://artificialanalysis.ai/models/claude-opus-5-5 "Artificial Analysis Intelligence Index, max, default fallback reasoning effort, published 26 November 2026")  | [65.8%](https://www.tbench.ai/leaderboard "Terminal-Bench 4.1, max effort, Claude Code agent, published 25 November 2026")       | [93.3%](https://arcprize.org/leaderboard "ARC-AGI 2, ARC Prize verified; default leaderboard view (best reasoning effort), published 22 September 2026") |
| Kimi K3.1 Pro Moonshot            | 0 of 3           | [47](https://artificialanalysis.ai/models/kimi-k3-1-pro "Artificial Analysis Intelligence Index, model page default, published 26 November 2026")                        | [59.7%](https://www.tbench.ai/leaderboard "Terminal-Bench 4.1, max effort, Claude Code agent, published 25 November 2026")       | Not listed                                                                                                                                               |
| DeepSeek V4.1 Flash 1017 DeepSeek | 0 of 3           | [32](https://artificialanalysis.ai/models/deepseek-v4-1-flash-1017 "Artificial Analysis Intelligence Index, max reasoning effort, published 26 November 2026")           | [38.5%](https://www.tbench.ai/leaderboard "Terminal-Bench 4.1, max effort, Claude Code agent, published 25 November 2026")       | [78.1%](https://arcprize.org/leaderboard "ARC-AGI 2, ARC Prize verified; default leaderboard view (best reasoning effort), published 17 October 2026")   |

Sorted by the AA Index. Scores are the boards' own independent runs, not ours: AA Index as of 26 November 2026; Terminal-Bench 4.1 as of 26 November 2026; ARC-AGI 2 as of 26 November 2026\. Each score links to its board.

## What did each model say it did?

The prompt, the file it points to, and every try's closing message, exactly as it came back.

**The prompt Sent word for word to every model, every try**

**System:** You are a senior software engineer working in a git repository on a Linux-like machine. You have one tool, \`bash\`, which runs a shell command in the repository root and returns its output. There is no network access. Python is \`python\` (3.12) with pytest installed; run the tests with \`python -m pytest -q\`. Work step by step: read the code, make the change, run the tests. Edit files with shell tools (cat with a heredoc, sed, or python). When you are completely done, reply with a short summary and no tool call.

This is the sqlglot repository (a SQL parser, transpiler and optimizer). A user filed this issue:

\--- # unnest\_subqueries: a scalar subquery next to a window function is wrapped in MAX(), so the optimized query fails or returns one row

When \`unnest\_subqueries\` hoists an uncorrelated scalar subquery into a CROSS JOIN, it wraps the column in \`MAX()\` if the outer query looks aggregated. That check looks for any \`exp.AggFunc\` in the projections, and window functions (\`RANK\`, \`LAG\`, \`COUNT(\*) OVER ()\`, ...) are \`AggFunc\`s, so an ungrouped query with a window function gets \`MAX()\`. A query whose only aggregate is in \`HAVING\` doesn't get it.

\*\*Fully reproducible code snippet\*\*

Read and write dialect \`duckdb\` (Postgres gives the same SQL); main at 089891f2.

```
from sqlglot import parse_one
from sqlglot.optimizer import optimize

schema = {"t1": {"a": "int", "b": "int"}, "t2": {"b": "int"}}
sql = "SELECT t1.a, t1.b * 1.0 / (SELECT SUM(b) FROM t2) AS pct, RANK() OVER (ORDER BY t1.b DESC) AS rnk FROM t1"
optimize(parse_one(sql, read="duckdb"), schema=schema, dialect="duckdb").sql("duckdb")
# WITH "_u_0" AS (SELECT SUM("t2"."b") AS "_col_0" FROM "t2" AS "t2") SELECT "t1"."a" AS "a", "t1"."b" * 1.0 / MAX("_u_0"."_col_0") AS "pct", RANK() OVER (ORDER BY "t1"."b" DESC) AS "rnk" FROM "t1" AS "t1" CROSS JOIN "_u_0" AS "_u_0"
```

Expected: the same query with \`"\_u\_0"."\_col\_0"\` instead of \`MAX("\_u\_0"."\_col\_0")\`.

Results of the query as written and of its \`optimize()\` output, on DuckDB 2.0.0 and PostgreSQL 14.25 (both agree):

| query | as written | optimized | |---|---|---| | the query above | 5 rows | \`column "a" must appear in the GROUP BY clause\` | | \`SELECT t1.c, COALESCE((SELECT MAX(e) FROM t3), 0) AS m, LAG(t1.a) OVER (ORDER BY t1.a) AS prev FROM t1\` | 5 rows | same GROUP BY error | | \`SELECT COUNT(\*) OVER () \* 1.0 / (SELECT COUNT(\*) FROM t2) AS ratio FROM t1\` | 5 rows of 1.25 | 1 row of 0.25 | | \`SELECT (SELECT MAX(e) FROM t3) + 1 AS m FROM t1 HAVING COUNT(\*) > 1\` | 1 row | \`column "\_col\_0" must appear in the GROUP BY clause\` (no \`MAX()\` added) |

\---

Fix the bug in the library. The optimized SQL must return the same rows as the query as written, for these queries and for the other kinds of queries this rewrite handles; do not just skip the rewrite everywhere. duckdb is installed. Run the relevant tests with \`python -m pytest -q tests/test\_optimizer.py\`. Hidden tests will check the fix.

**Claude Opus 5.5, try 1 Fail, 9 of 70 rewrites wrong, 6.6 min, 15 steps**

I fixed the bug in \`sqlglot/optimizer/unnest\_subqueries.py\`. Window functions no longer get the hoisted column wrapped in \`MAX()\`, and a query whose only aggregate is in \`HAVING\` (or \`ORDER BY\`, or \`QUALIFY\`) now does. All four queries from the issue return the same rows as written when run on DuckDB.

\*\*Cause:\*\* in \`unnest()\`, a scalar subquery hoisted into a \`CROSS JOIN\` got \`MAX()\` if the outer query had a \`GROUP BY\` or if \`find\_in\_scope(..., exp.AggFunc)\` found anything in the projections. Window functions count as \`AggFunc\`, so a query with only \`RANK()\`, \`LAG()\` or \`COUNT(\*) OVER ()\` was treated as aggregated. The check also never looked at \`HAVING\`, \`ORDER BY\` or \`QUALIFY\`.

\*\*Fix:\*\*

Cut at 700 characters.

**GPT-6.2 Astra, try 1 Fail, 6 of 70 rewrites wrong, 11.0 min, 50 steps**

No closing message. Used all 50 tool steps without finishing.

**Gemini 4 Neon, try 1 Fail, 14 of 70 rewrites wrong, 6.8 min, 50 steps**

No closing message. Used all 50 tool steps without finishing.

**Gemini 4 Carbon, try 1 Fail, 14 of 70 rewrites wrong, 7.8 min, 50 steps**

No closing message. Used all 50 tool steps without finishing.

**Claude Fable 5.2, try 1 Fail, 14 of 70 rewrites wrong, 13.2 min, 21 steps**

No closing message. One reply ran past the 16,000-token output limit, which ended the try.

**DeepSeek V4.1 Flash 1017, try 1 Fail, 9 of 70 rewrites wrong, 15.1 min, 50 steps**

No closing message. Used all 50 tool steps without finishing.

**DeepSeek V4.1 Flash 1017, try 2 Fail, 10 of 70 rewrites wrong, 5.0 min, 22 steps**

Implemented the fix in \`sqlglot/optimizer/unnest\_subqueries.py\`.

\### What changed

The scalar-subquery hoisting logic now determines whether the outer query is genuinely aggregated using:

\- \`GROUP BY\` - \`HAVING\` - aggregate projections that are \*\*not\*\* window functions (\`\_has\_aggregate\_projection\`) - aggregate \`ORDER BY\` expressions (\`\_has\_order\_aggregate\`)

Previously it used a raw \`find\_in\_scope(..., exp.AggFunc)\`, which incorrectly treated \`RANK\`, \`LAG\`, \`COUNT(\*) OVER ()\`, etc. as grouping aggregates, causing the hoisted scalar column to be wrapped in \`MAX()\` and collapsing/erroring on window-only queries. It also missed queries whose only aggregate was in \`HAVING\`.

\### Verification

Cut at 700 characters.

**DeepSeek V4.1 Flash 1017, try 3 Fail, 10 of 70 rewrites wrong, 9.0 min, 50 steps**

No closing message. Used all 50 tool steps without finishing.

**Kimi K3.1 Pro, try 1 Fail, 9 of 70 rewrites wrong, 10.7 min, 33 steps**

Fixed \`unnest\_subqueries\` to distinguish true aggregation from window functions:

\- Window-only queries now reference the hoisted scalar column directly without \`MAX()\`. - Genuine aggregation still uses \`MAX()\`, including aggregates found only in \`HAVING\`, \`ORDER BY\`, or \`QUALIFY\`. - Added DuckDB regression tests covering all reported queries and verifying the rewrite remains a \`CROSS JOIN\`.

Validation: \`python -m pytest -q tests/test\_optimizer.py\` — \*\*177 passed\*\*.

**Kimi K3.1 Pro, try 2 Fail, 9 of 70 rewrites wrong, 9.9 min, 25 steps**

Fixed \`unnest\_subqueries\` so:

\- Window functions such as \`RANK\`, \`LAG\`, and \`COUNT(\*) OVER ()\` no longer incorrectly trigger \`MAX()\` wrapping. - Aggregation implied by \`HAVING\`, \`ORDER BY\`, or \`QUALIFY\` correctly retains \`MAX()\` where required. - Genuine aggregate queries continue to use the existing rewrite.

Added executable regression fixtures covering these cases. Verified all four reported queries return identical results on DuckDB before and after optimization.

Tests: \`python -m pytest -q tests/test\_optimizer.py\` — \*\*176 passed\*\*.

**Kimi K3.1 Pro, try 3 Fail, 9 of 70 rewrites wrong, 15.4 min, 29 steps**

Implemented the scalar-subquery unnesting fix.

\- Replaced raw \`AggFunc\` detection with window-aware aggregate detection, preventing \`MAX()\` wrapping for \`RANK\`, \`LAG\`, and windowed \`COUNT\`. - Preserved \`MAX()\` for genuine aggregation, including aggregates in \`HAVING\`, \`ORDER BY\`, \`QUALIFY\`, and window specifications. - Added DuckDB execution-backed regression fixtures covering all reported query shapes.

Validation: \`python -m pytest -q tests/test\_optimizer.py\` — \*\*176 passed\*\*.

## How was this run?

The same way for every model and every try, graded by tests the model never saw.

- **Run** 26 November 2026, 7:25 PM to 9:52 PM PT. Every model got the same system prompt and the same task prompt, word for word, in a fresh copy of the repo for every try.
- **Tries** Up to 3 per model per task; each row says how many. The run had a $25 spend cap, so tries went in rounds, cheapest models first, and stopped at the cap. Claude Fable 5.2 got no try on the cachetools bug hunt. Every try is shown, passed or not.
- **Agent** Through the Straitly API (OpenAI chat completions format) with our own test key. One tool, bash, run in a macOS sandbox with no network. Up to 50 tool steps and 16,000 output tokens a reply; tool output cut to 6,000 characters. Each model's default temperature and reasoning.
- **Grading** sqlglot's own test suite at the bug's commit, plus the tests from the upstream fix (PR #9339): every runnable case in its fixture file is rewritten by the model's code and run on DuckDB next to the original, and must return the same rows. The model never saw the hidden tests. Pass means every test passed.
- **Time** Wall time for a whole try, timed on our own machine, tool runs and network included. It is one dated run per model, so it says how long each model took on these tasks, not how fast any API is, Straitly's included.
- **Slow first replies** Gemini 4 Carbon took 10 s on average before their first reply. That wait is the model's own thinking before it acts, and it showed on every task.
- **List cost** Every call's input, cached input and output tokens at the maker's list price, read on the run day. DeepSeek uses the peak or off-peak rate in force when each try started. Gemini 4 Carbon's rate is the one in force until 30 November 2026.
- **Straitly price** The same tokens at the Straitly catalog price on the run day. Gemini 4 Neon shows a link to its model page instead.
- **Reruns** Two bug-hunt tries stopped part way when our own shell closed, before any grading, and were started again from scratch. One DeepSeek bug-hunt try read a stock copy of cachetools that our sandbox had left readable; we closed that hole, threw the try away and ran it again. Two Kimi K3.1 Pro bug-hunt tries were cut off part way by an API error (HTTP 502, upstream provider not answering) before grading; both were thrown away and the try run again with longer retries. The same error ended its third refactor try; that one is left out and was not run again. Nothing was rerun for a better answer.

### Rates used

| Model                             | List           | Cache read | Straitly price                                                        |
| --------------------------------- | -------------- | ---------- | --------------------------------------------------------------------- |
| Claude Opus 5.5 Anthropic         | $4.00 / $20.00 | $0.2       | [$2.40 / $12.00](https://straitly.ai/models/claude-opus-5-5)          |
| GPT-6.2 Astra OpenAI              | $8.00 / $40.00 | $0.4       | [$4.80 / $24.00](https://straitly.ai/models/gpt-6.2-astra)            |
| Gemini 4 Neon Google              | $3.00 / $15.00 | $0.15      | [See model page](https://straitly.ai/models/gemini-4-neon)            |
| Gemini 4 Carbon Google            | $2.00 / $10.00 | $0.1       | $2.00 / $10.00                                                        |
| Claude Fable 5.2 Anthropic        | $8.00 / $40.00 | $0.2       | [$4.80 / $24.00](https://straitly.ai/models/claude-fable-5.2)         |
| DeepSeek V4.1 Flash 1017 DeepSeek | $0.15 / $0.60  | $0.003     | [$0.090 / $0.36](https://straitly.ai/models/deepseek-v4-1-flash-1017) |
| Kimi K3.1 Pro Moonshot            | $2.00 / $10.00 | $0.2       | [$1.14 / $5.70](https://straitly.ai/models/kimi-k3.1-pro)             |

List prices from each maker's pricing page, read on the run day. Each call is priced on its own, cache reads at the cache rate. DeepSeek's rate is the one in force when each try started (peak hours cost double); its off-peak rate is shown.

## What else do people ask?

[Ask a question](https://straitly.ai/contact)

- ### Which AI model is best at this task?
None passed on 26 November 2026: 0 of 11 tries. GPT-6.2 Astra got closest.
- ### How was it graded?
By running it, never by reading it: sqlglot's own test suite at the bug's commit, plus the tests from the upstream fix (PR #9339): every runnable case in its fixture file is rewritten by the model's code and run on DuckDB next to the original, and must return the same rows. The model never saw the hidden tests.
- ### Could a model have memorized the answer?
The fix was merged on 24 November 2026, after the newest model here came out (18 November), so no model can have seen it. The issue's suggested fix was taken out of the prompt.
- ### Why more than one try?
An agent does not take the same path twice. Repeat tries show whether a pass repeats or was luck. Here each model got 1 to 3 tries; every try is on the page, passed or not.

## Sources

The task's upstream sources, the public boards and each maker's pricing page, read on the run day. Spot something out of date? Tell us at [straitly.ai/contact](https://straitly.ai/contact).

1. \[1\] [sqlglot issue #9314](https://github.com/tobymao/sqlglot/issues/9314) github.com, checked 26 November 2026
2. \[2\] [sqlglot pull request #9339](https://github.com/tobymao/sqlglot/pull/9339) github.com, checked 26 November 2026
3. \[3\] [Artificial Analysis Intelligence Index](https://artificialanalysis.ai/) artificialanalysis.ai, checked 26 November 2026
4. \[4\] [Terminal-Bench leaderboard](https://www.tbench.ai/leaderboard) tbench.ai, checked 26 November 2026
5. \[5\] [ARC Prize leaderboard](https://arcprize.org/leaderboard) arcprize.org, checked 26 November 2026
6. \[6\] [Anthropic pricing](https://platform.claude.com/docs/en/about-claude/pricing) platform.claude.com, checked 26 November 2026
7. \[7\] [OpenAI pricing](https://developers.openai.com/api/docs/pricing) developers.openai.com, checked 26 November 2026
8. \[8\] [Gemini API pricing](https://ai.google.dev/gemini-api/docs/pricing) ai.google.dev, checked 26 November 2026
9. \[9\] [DeepSeek pricing](https://api-docs.deepseek.com/quick%5Fstart/pricing) api-docs.deepseek.com, checked 26 November 2026
10. \[10\] [Kimi API pricing](https://platform.kimi.ai/docs/pricing/chat) platform.kimi.ai, checked 26 November 2026
11. \[11\] [Straitly model catalog](https://straitly.ai/models) straitly.ai/models, checked 26 November 2026

**What each source says**

sqlglot issue #9314

The bug the real-bug task asks for: unnest\_subqueries wraps a scalar subquery in MAX() next to a window function.

sqlglot pull request #9339

The upstream fix, merged 24 November 2026, and the tests it added; those tests grade the task.

Artificial Analysis Intelligence Index

Intelligence Index 5.0.2, one score per model from Artificial Analysis' own runs of its evaluation suite.

Terminal-Bench leaderboard

Terminal-Bench 4.1 resolution rate, the best verified agent run per model.

ARC Prize leaderboard

ARC-AGI 2 scores verified by ARC Prize, default leaderboard view.

Anthropic pricing

Claude Opus 5.5 $4 / $20 and Claude Fable 5.2 $8 / $40 per 1M input / output tokens, base rate; cache reads $0.20.

OpenAI pricing

gpt-6.2-astra $8 / $40 per 1M input / output tokens, Standard, prompts up to 272K tokens; cached input $0.40.

Gemini API pricing

Gemini 4 Neon $3 / $15 per 1M input / output tokens, paid tier. Gemini 4 Carbon $2 / $10 through 30 November 2026 and $4 / $20 from 1 December 2026.

DeepSeek pricing

V4.1 Flash $0.15 / $0.60 per 1M input (cache miss) / output tokens off-peak; double that in peak hours, 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays.

Kimi API pricing

kimi-k3.1-pro $2 / $10 per 1M input (cache miss) / output tokens; cache hits $0.20.

Straitly model catalog

The per-model price list /models prints, read on the run day.

Read next: [Refactor a billing library](https://straitly.ai/shootouts/multi-file-refactor) , [Hunt 16 bugs in cachetools](https://straitly.ai/shootouts/agent-bug-hunt) , [All shootouts](https://straitly.ai/shootouts) , [All comparisons](https://straitly.ai/compare).

## Start with one request.

Run the same task on every model with one key. [See pricing](https://straitly.ai/pricing).

[Console](https://straitly.ai/app) [Talk to sales ](https://straitly.ai/contact)

---
Markdown version of https://straitly.ai/shootouts/real-bug-fix.
