---
title: "Claude Sonnet 5.5 on Pydantic AI Geo Analyst"
description: "Spatial questions and SVG maps from raw earthquake, fire and place data in DuckDB. Tool calling 90%, code mode 100%; rank 12 of 20."
canonical: https://models.pydantic.dev/models/claude-sonnet-5.5/geo_analyst/
---

# Claude Sonnet 5.5 on Pydantic AI Geo Analyst

> Spatial questions and SVG maps from raw earthquake, fire and place data in DuckDB. Tool calling 90%, code mode 100%; rank 12 of 20.
>
> Markdown copy of https://models.pydantic.dev/models/claude-sonnet-5.5/geo_analyst/. Index for agents: https://models.pydantic.dev/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://models.pydantic.dev/api/select` with a JSON body such as `{"description": "what the agent does"}`. It returns up to five ranked models with reasons. Format: https://models.pydantic.dev/select.md
- Search models by name: `GET https://models.pydantic.dev/api/search?query=<text>`
- List, filter and sort models: `GET https://models.pydantic.dev/api/models`, for example `?weights=open&max_price=2&sort=efficiency`
- One model in full: `GET https://models.pydantic.dev/api/models/<slug>`

Add `intent=<intent>&stack=<stack>&harness=<harness>` to the query string of the first three. An `OPTIONS` request to any endpoint returns its schema. The same four are tools of the MCP server at `https://models.pydantic.dev/mcp`. More: https://models.pydantic.dev/usage.md

About the benchmark: https://models.pydantic.dev/benchmarks/geo_analyst.md. The model on every Pydantic AI benchmark: https://models.pydantic.dev/models/claude-sonnet-5.5.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time    |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | ------- |
| Tool calling | 90%   | 9 of 10      | $0.56 | 71       | 76         | 4.6 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

The model passed **19 of 20** runs. It passed all 10 cases in code mode and 9 of 10 with tool calling. The only failure was `pair_map_hypo` in tools mode. Total spend was about $0.91: $0.56 for tools and $0.35 for code mode.

#### Where it does well

- **Reads and applies data conventions.** In every case it read DATA.md first. It then decoded the encoded fields correctly: magnitude stored ×100, depth as negative elevation in metres, and catalogue B's day-of-year, seconds-of-day and N/S/E/W suffixes.
- **Gets the geometry right.** It used true 3D hypocentral distance (`b_only_hypo`, `exposed`, `pair_map_hypo`). It computed great-circle cross-track and along-track positions (`cross_section`) and handled the antimeridian with `lon>=160 or lon<=-170`.
- **Resolves ambiguous names.** It chose Anchorage, Alaska over Kentucky (`b_gof`) and separated Mato Grosso from Mato Grosso do Sul (`mato_grosso`).
- **Keeps large joins fast without losing correctness.** It used bounding-box prefilters with cross-join fallbacks (`brazil_nn`) and confirmed the prefilter radius covered the threshold (`exposed`). In `world_clusters` it built a 1 km/12 h grid join that produced about 1.87M edges.
- **Checks for duplicates.** It often compared `count(*)` with `count(distinct …)`.

#### Mistakes it makes

- **The one failure was an arithmetic slip it did not catch.** In `pair_map_hypo` (tools), it treated the 160°E–170°W span as 50° instead of 30°, which scaled every x coordinate by 0.6. The query output showed `max(x)=484.25` on a 900 px canvas, but the model ignored it. It then retyped the SVG by hand and wrongly claimed the map filled the image.
- **Leaves assumptions unverified.** It took kind and class filters from truncated DATA.md output without checking them (`local_night`, `exposed`, `cross_section`, `mato_grosso`). It also hard-coded overlap time bounds before querying the actual range (`b_only_hypo` in both modes, `pair_map_hypo` code).
- **Wastes calls.** Examples:
  - Batched `run_sql` statements where only the last result came back (`b_only_hypo`, `cross_section`, `mato_grosso`).
  - Made no-op `select 1`/`print(1)` calls.
  - Used a wrong parameter name (`brazil_nn`) and an invalid QUALIFY (`exposed`).
  - Hit the 100-nested-call limit in `world_clusters` (code mode).
- **Picks answers by eye.** In `b_gof` (code mode) it read the result from a truncated printout instead of selecting it in code.

#### Tool calling compared with code mode

| Mode      | Pass  | Requests | Cost   |
| --------- | ----- | -------- | ------ |
| tools     | 9/10  | 71       | $0.559 |
| code_mode | 10/10 | 49       | $0.350 |

Code mode was more accurate and cheaper. It used about 31% fewer requests and cost about 37% less. The gap is largest on iterative or heavy tasks:

- **`world_clusters`:** 7 requests and $0.061 in code mode, against 15 requests and $0.135 with tools. With tools, label propagation took about 9 repeated `run_sql` rounds.
- **`pair_map_hypo`:** passed in code mode with 5 requests and $0.060. With tools it failed after 10 requests and $0.151.

On simple single-query lookups the two modes cost about the same. For example, `deep_moment` cost $0.020 in both modes, and `b_only_hypo` cost $0.035 in code mode against $0.034 with tools.

## Runs

### deep_moment

**Tool calling: passed.** The agent read DATA.md, then ran one DuckDB query on quakes_a.jsonl filtering k='T', mk=3, m>=500, z\<-70000 and UTC times from 1 to 15 November. It got 7, which matches the expected answer. ($0.020, 4 requests, 9 s)
- Right: Read DATA.md before querying and used the encoded fields correctly: magnitude stored ×100 (m>=500), depth as negative elevation in metres (z\<-70000), and the magnitude-type code mk=3.
- Right: Compared times as timestamptz instants with a half-open UTC window, \[2026-11-01, 2026-11-16).
- Right: Ran a second query that listed the candidate events with a looser depth bound (z\<-69000) to check the timestamp type and the events near the boundaries.
- Mistake: The convention for the date window (UTC or local) was not confirmed in the visible part of DATA.md, but the boundary events (05:15 and 17:48 UTC on 15 November, 04:24 UTC on 16 November) did not change the count either way.

### mato_grosso

**Tool calling: passed.** The agent read DATA.md, built a table of Brazilian 'Mato Grosso%' regions from regions.tsv, and counted fires with cls='H' that fall inside the Mato Grosso polygon with t between the epochs for 2026-11-21 and 2026-11-22 (UTC). The query returned 5, which matches the expected answer. ($0.022, 5 requests, 12 s)
- Right: Read DATA.md before querying and used the region polygon with an ST_Intersects point-in-polygon join instead of a bounding box or a name lookup.
- Right: Restricted the count to r.name='Mato Grosso', which correctly excluded BRA-600 'Mato Grosso do Sul'; a later `select ... from r` call confirmed both regions were in the table.
- Right: Checked that epoch(TIMESTAMP '2026-11-21') = 1795219200, confirming the day boundary it used for t.
- Mistake: The multi-statement run_sql calls only return the last statement's result. The intermediate checks were never seen: the rid/name/kind listing, the total and high-confidence counts for the day, and in the second call the region listing. This forced an extra call.
- Mistake: The agent never looked at the fires.parquet schema or sample rows in the transcript. It assumed `cls='H'` means high confidence and that `t` is in epoch seconds rather than milliseconds, without showing either was checked. The answer was correct, but these assumptions went unverified.

### b_only_hypo

**Tool calling: passed.** The agent read DATA.md, loaded both catalogues, converted catalogue B's day-of-year, seconds-of-day and hemisphere-letter fields, and counted B events of M≥4.5 inside the overlap window that had no A event within 30 s and 50 km of 3D hypocentral distance. It got 36, which matches the expected answer. ($0.034, 6 requests, 17 s)
- Right: Read DATA.md before writing any queries.
- Right: Parsed B's 'YYYY-DDD' date plus seconds-of-day into a timestamp, and turned the N/S/E/W suffixes into signed lat/lon.
- Right: Measured true 3D hypocentral distance with the law of cosines on radii (6371 - depth), converting A's z from metres with z/1000.
- Right: Applied the 30 s window with abs(epoch difference) \<= 30 and used NOT EXISTS, so A events of any class counted.
- Right: Limited B to the period both catalogues cover, then checked that A's min/max times (16:02:31 on 26 Oct and 15:35:51 on 25 Nov) fall inside the bounds it used.
- Mistake: In the first run_sql call it chained several SELECTs, but only the last result came back (typeof). It had to re-query to see the data, which cost an extra call.
- Mistake: It hard-coded the overlap bounds ('2026-10-26 16:00:00' to '2026-11-25 15:36:00') before querying A's actual time range and only checked them afterwards. Using min/max(a.ts) directly would have been more robust.
- Mistake: It did not check B for duplicate ids or magnitude-type issues before counting. The count(distinct) query's result was never shown.

### local_night

**Tool calling: passed.** The agent read DATA.md, filtered catalogue A to earthquakes (k='T') with m>=250 (magnitude stored in hundredths), giving 1804 events. It excluded places of kind S/H/Q, found each quake's nearest place by haversine cross join, converted the time to that place's tz and counted local hours >=20 or \<6. The result was 787, which matches the expected answer. ($0.024, 5 requests, 19 s)
- Right: Read DATA.md first and applied its conventions: the event-type filter k='T', magnitude scaled by 100 (m>=250), and exclusion of some place kinds.
- Right: Parsed `t` as a timestamptz, so the misleading 15-degree-zone offset was handled correctly as an exact instant.
- Right: Computed true great-circle nearest neighbours with arg_min over the full cross join, then checked there were no null tz values and no duplicate ids.
- Right: Spot-checked the timezone conversion on sample rows.
- Right: Took only four SQL calls, with no wasted steps.
- Mistake: Spot-check only: the place-kind exclusion list ('S','H','Q') and the k='T' filter came from the truncated part of DATA.md and were not re-checked against the data, for example by listing the distinct values of kind and k. It worked here, but it rests on reading the documentation correctly.

### brazil_nn

**Tool calling: passed.** The agent read DATA.md, loaded the Brazil regions, the VIIRS fires (VJ1/VJ2) and the settlements with population of 10,000 or more, then joined fires to regions spatially. It computed haversine nearest-settlement distances with a bounding-box prefilter plus a cross-join fallback and took the median per region. All 27 rows matched the expected answer and the run passed. ($0.051, 8 requests, 38 s)
- Right: Read DATA.md first and applied the settlement filter (kind not in S/H/Q, pop>=10000) and the VIIRS satellite filter (VJ1, VJ2).
- Right: Checked that no fire landed in more than one region: count(\*) and count(distinct fid) were both 93791.
- Right: Kept the nearest-neighbour search correct and efficient. The bounding-box prefilter (±1.2° lat, ±1.5° lon) was only trusted for d\<90 km, and the remaining fires were recomputed with a full cross join.
- Right: Used DuckDB's median, which averages the two middle values for even counts as the question requires, and rounded to one decimal.
- Mistake: The first run_sql call failed on a wrong parameter name (maxlineSize instead of max_line_size), costing one call.
- Mistake: The aggregation query was run twice with the same result (once with a count distinct, once without), which was redundant.

### exposed

**Tool calling: passed.** The agent read DATA.md and loaded catalogue A, keeping kind 'T' events with magnitude (m/100). It loaded places with pop≥500,000, excluding kinds S/H/Q. It computed 3D chord distances from each hypocentre (z as elevation in metres) to surface place points, filtered by d < 10^(0.5M-0.7), and returned 23 ids that match the expected set. ($0.033, 6 requests, 19 s)
- Right: Read DATA.md first and applied its conventions: m stored as magnitude×100, z as elevation in metres (negative means depth), and event-kind and place-kind filters.
- Right: Used the true 3D straight-line distance to the hypocentre instead of the epicentral great-circle distance.
- Right: Checked that the maximum threshold (~501 km at M6.8) fits inside the |Δlat|\<5° prefilter (~555 km), so the prefilter could not drop valid pairs.
- Right: Fixed the QUALIFY binder error by wrapping the query in a subquery.
- Mistake: The first query used QUALIFY without a window function and failed, costing one extra call.
- Mistake: A pointless 'select 1' call was made before answering.
- Mistake: The result was truncated in the transcript and the agent never listed distinct pids separately. It relied on the visible rows plus the truncated remainder, which turned out correct.

### b_gof

**Tool calling: passed.** The agent filtered catalogue A local-magnitude events within 300 km of Anchorage, Alaska, ran the goodness-of-fit Mc search in SQL, found Mc = 2.0 with R ≈ 89.5 and returned b = 1.152, which matches the expected answer. ($0.041, 6 requests, 19 s)
- Right: Picked the Alaska Anchorage record (61.218, -149.900), not the Kentucky place of the same name.
- Right: Wrote the whole Mc grid search in one SQL query: N, mean, b, a, predicted counts per bin and R for every candidate Mc.
- Right: Its first query rounded negative magnitudes away from zero and only scanned the magnitude grid from 0 upwards. The second query fixed both, using floor((m+5)/10) for halves-up rounding and range(-30,100) for the grid, which gave correct R values for negative candidates.
- Right: Took the lowest candidate with R ≥ 85 (Mc = 20 in tenths, R = 89.52) and reported b = 1.152133 → 1.152.
- Mistake: The first run_sql used round(m/100.0+1e-9,1), which rounds negative halves away from zero rather than up, and a magnitude grid starting at 0. This gave wrong R values for negative candidates, so the query had to be redone; it did not change the answer here.
- Mistake: Accepted the Anchorage record with kind 'A2' without checking DATA.md to confirm that this kind counts as a settlement. The DATA.md read was cut off and was not re-read in full.
- Mistake: Made a pointless `select 1` call before answering.

### world_clusters

**Tool calling: passed.** The agent restricted the fire detections to VIIRS (VJ1+VJ2) and built 1 km / 12 h link edges with a 3D-grid plus time-bucket spatial join and haversine check. It then found connected components by iterative min-label propagation until zero cross-label edges remained. Its 45 clusters matched the expected answer and the run passed. ($0.13, 15 requests, 62 s)
- Right: Read DATA.md first and checked the satellite codes. It correctly treated VIIRS as VJ1 and VJ2 and excluded MA and MT (MODIS).
- Right: Used an efficient 1 km 3D cartesian grid with 12 h time buckets, checking neighbouring cells, so the pairwise join stayed tractable (1.87M edges). It applied an exact haversine ≤ 1.0 km test and |dt| ≤ 43200 s.
- Right: Ran label propagation with pointer-jumping and verified convergence explicitly by counting edges whose endpoints had different labels, continuing until that count reached 0.
- Right: Converted frp_kw to MW (divided by 1000) and rounded to one decimal place. It reported the minimum fid per cluster and applied the ≥ 300 threshold.
- Mistake: Label propagation needed many manual rounds, about 9 run_sql calls, each repeating the same SQL. A recursive CTE or a single loop would have been less wasteful, but the result was correct.
- Mistake: Did not check for null or empty frp values. The null check on lat/lon/t was computed but its result was not displayed. This had no effect on the outcome.

### cross_section

**Tool calling: passed.** The agent read DATA.md, loaded catalogue A and kept rows with k='T' and a non-null magnitude. It computed cross-track distance and along-track angle with 3D vector maths in SQL, selected 25 events, and wrote a correct SVG with 25 circles whose coordinates match the expected answer. ($0.048, 6 requests, 21 s)
- Right: Read DATA.md first and applied its conventions: only k='T' events with magnitude, and z read as elevation in metres so depth = -z/1000.
- Right: The cross-track test used asin of the dot product with the unit normal of the great circle. The along-track test used atan2 against the start vector and kept 0 ≤ ang ≤ L, which correctly enforces 'between the end points'.
- Right: The x/y scaling exactly matches the expected positions (e.g. us7000tu6i at 686.40, 270.57).
- Right: The work was efficient: a few SQL calls and one file write, and the SVG meets the size, data-id and radius constraints.
- Mistake: The first run_sql batch put the count query in the middle of the statement list, so only the last statement's result came back. The agent needed one extra call to get the count, which is a small inefficiency.
- Mistake: The final note says the arc length is about 1,069 km but does not lead with the bare feature count requested; it is stated in the first sentence, so this is a minor point.

### pair_map_hypo

**Tool calling: failed.** The agent filtered both catalogues, matched 67 pairs and wrote 158 circles to /out/map.svg; the ids and y coordinates match the expected answer, but every x coordinate is wrong because it took the 160°E–170°W span as 50° of longitude instead of 30°. ($0.15, 10 requests, 61 s)
- Right: Read DATA.md and correctly decoded catalogue A (magnitude ×100, z in negative metres) and catalogue B (year-day date, seconds of day, N/S/E/W suffixes).
- Right: Restricted both catalogues to the shared period and to class T events, and handled the area across the antimeridian with lon>=160 or lon\<=-170.
- Right: Computed the 3D hypocentral distance correctly and found 67 candidate pairs with 67 distinct A ids and 67 distinct B ids, so greedy acceptance was trivial.
- Right: Computed great-circle midpoints by averaging unit vectors; the final feature set (158 ids) and all y values match the expected answer.
- Right: The SVG has width and height attributes of 900, circles of radius 3, and data-id only on circles.
- Mistake: In the `create table f` query, the x projection used `((lon-160+360)%360)/50*900`. Going from 160°E east to 170°W spans 30° (20° to the antimeridian plus 10° beyond it), not 50°. It should have divided by 30. As a result, every x is scaled by 0.6 (for example B0e74f4ce at 385.0 instead of 641.67), and the map fills only about 484 px of the 900 px width.
- Mistake: The query result showed max(x)=484.25, a clear sign the area did not fill the image, but the agent did not act on it.
- Mistake: The final reply wrongly states 18 px per degree of longitude and claims the area fills the image.
- Mistake: The SVG content was retyped by hand from truncated query output instead of being generated programmatically, which risked transcription errors; the agent itself admits it never checked the file.
