---
title: "Gemini 4 Carbon on Pydantic AI Geo Analyst"
description: "Spatial questions and SVG maps from raw earthquake, fire and place data in DuckDB. Tool calling 100%, code mode 100%; rank 1 of 20."
canonical: https://models.pydantic.dev/models/gemini-4-carbon/geo_analyst/
---

# Gemini 4 Carbon on Pydantic AI Geo Analyst

> Spatial questions and SVG maps from raw earthquake, fire and place data in DuckDB. Tool calling 100%, code mode 100%; rank 1 of 20.
>
> Markdown copy of https://models.pydantic.dev/models/gemini-4-carbon/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/gemini-4-carbon.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $2.34 | 164      | 175        | 58.3 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

The model passed all 20 cases: 10 benchmark tasks, each run in both modes. The tasks covered seismic catalogues, fire detections, spatial joins and SVG output. Across the 10 tasks, tools mode used 164 requests and cost $2.34. Code mode used 115 requests and cost $1.74. Wasted calls are its main weakness, along with a few results that were right only by luck.

#### Where it does well

- **Reads the conventions first.** It read DATA.md before querying in almost every run. It then applied the encoded units correctly: magnitude ×100 or tenths, depth as negative metres, k='T' for earthquakes, and excluding kinds S/H/Q from settlements.
- **Resolves ambiguous names.** It chose Anchorage, Alaska over Kentucky in `b_gof`, and Mato Grosso (BRA-602) over Mato Grosso do Sul in `mato_grosso`.
- **Gets the geometry right.** It used true 3D hypocentral distances in `b_only_hypo`, `exposed` and `pair_map_hypo`. It handled the antimeridian and used great-circle midpoints in `pair_map_hypo`.
- **Catches rounding edge cases.** In `world_clusters` it switched to DECIMAL to round 30720.55 half-up. In `b_gof` code mode it tested both half-rounding rules.
- **Cross-checks its results independently.** It confirmed answers with a second method: a brute-force cross join in `local_night`, an alternate edge set of identical size (1,874,135) in `world_clusters`, and Python ECEF against SQL in `b_only_hypo`.

#### Mistakes it makes

None of these mistakes changed an answer, but several are risky.

- **Correct by luck.** In tools mode for `pair_map_hypo`, it never implemented the required greedy one-to-one matching. The answer was right only because the 67 candidates were already unique.
- **Assumptions it did not verify:**
  - It never proved its bounding-box prefilters were wide enough (`brazil_nn`, both modes).
  - It hardcoded rounded overlap windows instead of using exact extents (`b_only_hypo` and `pair_map_hypo`, both modes).
  - It assumed a UTC day without checking DATA.md (`mato_grosso`).
  - It left near-ties in the nearest settlement unresolved (`local_night`).
- **Wasted effort:**
  - It ran repeated exploratory queries.
  - It added decorative land, graticule and legend elements to SVGs that the task did not ask for. In `pair_map_hypo` code mode this produced a 278 KB file.

#### Tool calling compared with code mode

Code mode was cheaper on 7 of 10 tasks and used fewer requests on 8 of 10. However, most of the saving came from one task, `pair_map_hypo`:

| Run                    | Requests (tools → code) | Cost (tools → code) |
| ---------------------- | ----------------------- | ------------------- |
| `pair_map_hypo`        | 36 → 17                 | $0.98 → $0.36       |
| Other 9 tasks combined | 128 → 98                | $1.36 → $1.38       |

Code mode was also more expensive on `cross_section`, at $0.32 against $0.17.

Code mode was more rigorous on matching: it implemented the greedy one-to-one matching in `pair_map_hypo`. It was also more error-prone:

- Twice it emitted a reply made only of `<end_of_image>` tokens, which failed JSON validation (`b_gof`, `mato_grosso`).
- It hit several Python runtime errors: a TypeError, an xml import and a timedelta cast.
- It hit the 100-nested-tool-call limit by calling `run_sql` inside a loop (`world_clusters`).

Tools mode failures were limited to small SQL slips, such as `USING SAMPLE` syntax and a call to the nonexistent function `ROUNDEVENS`.

## Runs

### deep_moment

**Tool calling: passed.** The agent read DATA.md, inspected the schema of catalogue A, and filtered for mk=3 (moment magnitude), m>=500, z\<-70000, k='T' and UTC 1–15 November. It got 7, which matches the expected answer. ($0.089, 9 requests, 79 s)
- Right: Read DATA.md first and checked the raw field formats: t has local offsets, z is negative in metres, m is magnitude×100.
- Right: Ran a broad exploratory query, then joined the raw and parsed timestamps to check the UTC conversion near the date boundaries.
- Right: Applied the moment-magnitude code (mk=3), the strict depth rule (z < -70000) and an exclusive end of 2026-11-16 UTC in the final count query.
- Mistake: Minor inefficiency: it ran several exploratory queries with widened windows (Oct 31–Nov 17, m>=480, z\<=-60000) before the final count. This was harmless but added extra steps.
- Mistake: The transcript does not show the agent explicitly confirming in DATA.md how review status (rv) and event type (k) should be treated. It filtered on k='T' without visibly checking that rule, though the result was correct.

### mato_grosso

**Tool calling: passed.** The agent located Mato Grosso (BRA-602) in regions.tsv and filtered fires.parquet to cls='H' within the UTC day of 21 Nov 2026 (epoch 1795219200–1795305600). A point-in-polygon test returned 5, which it confirmed with a second exact query and submitted as the correct answer. ($0.082, 10 requests, 3.4 min)
- Right: Read DATA.md before querying.
- Right: Picked BRA-602 Mato Grosso and did not confuse it with Mato Grosso do Sul (BRA-600).
- Right: Compared ST_Intersects, ST_Covers and ST_Contains, and all three gave 5 high-confidence points, so boundary handling made no difference.
- Right: Spot-checked edge fids against all regions: some fell in Bolivia's Santa Cruz, the rest in Mato Grosso.
- Right: Re-ran the count without the bounding-box prefilter and with a timestamp comparison, and checked the geometry was valid (true, count 5).
- Mistake: The transcript never shows the agent checking DATA.md for a local-time day convention; it assumed a UTC day. The answer matched, so either UTC is the convention or the choice did not matter here.
- Mistake: There were a few redundant verification queries, such as the ±1h window listing, but they cost little.

### b_only_hypo

**Tool calling: passed.** The agent loaded both catalogues, normalised times to UTC and depths to km, and limited catalogue B to the overlap window (A from 2026-10-26 16:02 UTC). It counted B events with magnitude ≥4.5 that had no A event within 30 s and within 50 km 3D hypocentral distance, got 36, and passed. ($0.19, 19 requests, 6.0 min)
- Right: Read DATA.md before writing any queries.
- Right: Parsed A timestamps with their offsets into UTC and converted z (metres, negative down, some positive) to a radius in km.
- Right: Parsed B's year-day plus seconds-of-day times and its N/S/E/W coordinates correctly.
- Right: Took the overlap window from the actual data extents (min/max of A times) and applied it to B.
- Right: Used a true 3D chord distance between hypocentres instead of epicentral distance, and confirmed it against a Cartesian computation.
- Right: Checked near-threshold cases (distances of 45–55 km, time gaps ≥25 s) to see how fragile the count was.
- Right: Got 36 twice, from a LEFT JOIN count and from a NOT EXISTS query.
- Right: Matched against A events of any class, as the question asks.
- Mistake: The overlap window was set with hard-coded rounded bounds ('2026-10-26 16:00' to '2026-11-25 15:36') instead of the exact min/max timestamps. It happened to make no difference here.
- Mistake: Checking the near-threshold cases used a few extra queries, though they were cheap.
- Mistake: The agent did not state which overlap definition it used; it chose the actual data extents rather than the documented coverage start of 26 October.

### local_night

**Tool calling: passed.** The agent read DATA.md, loaded catalogue A and places, and kept events of kind T with m >= 250 (2.5 in hundredths): 1804 events. It found each event's nearest settlement (excluding kinds S, H and Q) using a bounded haversine search, converted the times with the IANA zone, and counted 787 night events. A brute-force 3D dot-product cross join confirmed 787, which matches the expected answer. ($0.21, 22 requests, 7.1 min)
- Right: Read DATA.md and applied its conventions: magnitude stored in hundredths (m >= 250), the earthquake-only kind filter (k='T'), and the settlement definition excluding S/H/Q.
- Right: Checked that every tz value in places is a valid DuckDB time zone name (pg_timezone_names check returned no missing zones).
- Right: Checked that parsed timestamps carry the correct UTC offsets and that timezone() gives correct local times (Tokyo and New York test).
- Right: Verified the nearest-neighbour bound (0 violations) and then cross-checked the answer with an exhaustive cross join using arg_max on the dot product, which also gave 787.
- Right: Checked events near the 20:00 and 06:00 boundaries to confirm the half-open interval was handled correctly.
- Right: Checked parsed row counts against raw line counts for both files.
- Mistake: The bounding-box and sampling approach (a first call failed on USING SAMPLE syntax, then a 5-degree grid of reference settlements) took several extra calls; the final brute-force cross join of 1804 events against roughly 162k settlements ran without trouble and would have been enough on its own.
- Mistake: The agent listed the near-ties in nearest-settlement time zone (e.g. Mentone/Loving, about 0.1 km apart) but did not check whether they could affect the count; the tie-break by pid was arbitrary, though the result happened to be right.

### brazil_nn

**Tool calling: passed.** The agent loaded the Brazilian regions, joined the VIIRS (VJ1/VJ2) detections to them with ST_Intersects (checking it against ST_Covers and ST_MakeValid), computed the haversine distance from each detection to the nearest settlement with pop >= 10,000 within a ±6° box, and took exact medians. All 27 rows match the expected answer. ($0.17, 18 requests, 8.1 min)
- Right: Read DATA.md and followed the stated conventions: haversine on radius 6371.0 km, and 'on edge counts as inside', checked by comparing ST_Intersects with ST_Covers.
- Right: Spotted the one invalid polygon (Goiás) and confirmed that ST_MakeValid made no difference to membership (diff counts all 0).
- Right: Excluded non-settlement place kinds (S, H, Q) from the settlement set, which matched the expected results.
- Right: Computed the median by hand with the even-count averaging rule and cross-checked it against DuckDB median(); both agreed.
- Right: Checked for duplicate fids and for dropped rows when parsing places.psv.
- Mistake: The ±6° bounding-box prefilter was never shown to be wide enough. The maximum nearest distance found was 387 km, which sits well inside 6° of latitude, but no explicit check was made that the true nearest settlement could not fall outside the box. It happened to be fine.
- Mistake: Some early exploration, such as listing the BRB/BRN regions, was not needed but cost little.

### exposed

**Tool calling: passed.** The agent loaded places and catalogue A, filtered to settlements (excluding kinds S/H/Q) with pop >= 500,000 and tectonic events with a magnitude, and computed the 3D hypocentral distance. It returned 23 place ids that match the expected set. ($0.10, 9 requests, 3.0 min)
- Right: Read DATA.md first and used its conventions: magnitude stored as m/100, depth z in metres (negative below the surface), sections and kind H/Q not counted as settlements, and the k='T' filter.
- Right: Computed true 3D hypocentral distance (chord with depth), not surface distance.
- Right: Cross-checked with a Cartesian 3D distance on the full cross join without bounding-box pruning, so no candidates were lost to the prefilter.
- Right: Ran a sanity query showing that every excluded match was a kind-S section, confirming the exclusions changed only the intended rows.
- Mistake: The first query's ±10°/±15° lat/lon bounding-box prefilter could in principle miss pairs at high latitudes. It was harmless here because the agent re-ran without it.
- Mistake: Minor redundancy: two distance formulations were computed, which was not strictly needed.

### b_gof

**Tool calling: passed.** The agent looked up Anchorage, Alaska (pid 5879400) and filtered catalogue A to events with local magnitude (k='T', mk=1) within 300 km by haversine. It rounded magnitudes half-up with floor((m+5)/10), ran the goodness-of-fit Mc search in SQL, and returned b=1.152 at Mc=2.0, which matches the expected answer. ($0.12, 12 requests, 3.7 min)
- Right: Picked the Alaska Anchorage (61.21806, -149.90028, America/Anchorage) over the Kentucky one, and checked the tz to confirm it.
- Right: Grouped events by magnitude type and kind before filtering, so the local-magnitude subset (k='T', mk=1, 1613 events) was identified explicitly.
- Right: Rounded halves up with floor((m+5)/10) on the integer tenths field, and counted the half-value cases (11 negative, 4 positive), where a round-away-from-zero rule would give a different answer.
- Right: Built the full Mc grid search in one SQL query, using the task's own b, a, predicted-count and R formulas.
- Right: Recomputed b at Mc=2.0 separately (N=616, mean 2.326948) to get 1.152134, which rounds to 1.152.
- Mistake: The lon/15 queries for timezone boundaries had nothing to do with the question and wasted calls.
- Mistake: The R table was truncated in the output, so the transcript does not show which row first reached R ≥ 85. The agent went straight to Mc=2.0 without displaying that confirmation, although the answer is correct.
- Mistake: Only the 5 events within 299–301 km of the 300 km boundary were inspected; there was no sensitivity check on the choice of Earth radius.

### world_clusters

**Tool calling: passed.** The agent filtered the fires to VIIRS (VJ1/VJ2, 680,723 detections) and built 1 km / 12 h edges with a lat/lon/time grid join and haversine distance. It found connected components with iterative hook-and-shortcut SQL rounds and reported the 45 clusters of 300 or more detections, with counts and FRP rounded half-up to 0.1 MW. All values match the expected answer, and the run passed. ($0.23, 20 requests, 6.6 min)
- Right: Correctly identified VIIRS as sat VJ1/VJ2 and frp_kw as kW, dividing by 1000 to get MW.
- Right: The grid join (0.01° lat, 0.03° lon, 12 h time bins) with ±1 neighbour offsets, followed by an exact haversine check, kept the problem tractable. The agent also checked how many edges were near the 1 km boundary and confirmed none had a time gap of exactly 12 h.
- Right: Cross-checked the edge set with an independent 3D unit-vector grid join, which produced the identical 1,874,135 edges. This rules out missed pairs at high latitudes.
- Right: Verified convergence of the connected-components rounds (0 remaining edges, 0 non-roots, every cid equal to the minimum node), so the row id is the lowest fid.
- Right: Noticed the half-way FRP totals such as 30720.55 and 31150.65, where double-precision ROUND gave 30720.5. It switched to DECIMAL arithmetic for half-up rounding, giving 30720.6.
- Mistake: Minor inefficiency: the first rounding probe divided a DECIMAL by an integer, which yields a DOUBLE, so it took a few extra queries (including a failed call to the nonexistent ROUNDEVENS) to settle the rounding.
- Mistake: Six connected-components rounds were run in one batch without checking progress between them; this worked, but convergence was only confirmed afterwards.

### cross_section

**Tool calling: passed.** The agent loaded catalogue A and filtered to k='T' events with a magnitude. It projected epicentres onto the great circle using a vector frame in SQL, then wrote an SVG with 25 circles whose ids and coordinates match the expected answer exactly. It replied with 25 and passed. ($0.17, 9 requests, 7.3 min)
- Right: Read DATA.md first and applied the catalogue convention of keeping only k='T' events (9233 of 9566) and requiring m not null (9232).
- Right: Computed cross-track distance and along-track angle correctly with an orthonormal frame (e1, e2 = n×e1). The filter alpha between 0 and theta12 enforced the 'nearest point between end points' condition.
- Right: Converted z (negative metres) to depth correctly: y = -z/1400.
- Right: Checked a wider window (160 km, ±margin) to see the borderline events and confirmed id uniqueness before writing.
- Right: Gave only the circles a data-id attribute and kept radii within 2.5–5.5 px. All 25 x/y values match the expected values to 3 decimals.
- Mistake: Minor inefficiency: the large CTE was repeated across four nearly identical queries instead of being stored once as a view or table.
- Mistake: The final 'note' field is just '25', which is acceptable, though the svg content was also echoed into the output.

### pair_map_hypo

**Tool calling: passed.** The agent loaded both catalogues and limited them to the overlap period (A starts 26 Oct 16:02) and the antimeridian-crossing box. It built 3D hypocentre distances and found 67 candidate pairs, each event appearing only once, so matching was trivial. It then computed great-circle midpoints, projected everything onto 900x900 pixels (30 px/deg) and wrote an SVG with 158 circles. The run passed. ($0.98, 36 requests, 11.8 min)
- Right: Read DATA.md and handled the formats correctly: catalogue A has a local-offset ISO time, magnitude ×100 and depth as negative metres; catalogue B has a year-day time with seconds and N/S/E/W hemisphere suffixes.
- Right: Restricted both catalogues to the overlap period, starting at A's first event (2026-10-26 16:02).
- Right: Handled the antimeridian in the area filter with lon>=160 OR lon\<=-170, and in projection by adding 360 to negative longitudes.
- Right: Checked candidates near the 50 km threshold, confirmed that the haversine-chord distance matches an XYZ distance, and checked edge magnitudes.
- Right: Computed pair midpoints with a 3D vector average, which gives the great-circle midpoint, and the coordinates match the expected answer (e.g. us7000tte4 at 44.681,17.738).
- Right: Clipped land to both halves of the area and shifted the western half correctly.
- Mistake: The greedy one-to-one acceptance was never actually implemented; the agent used every candidate as an accepted pair. This was only valid because its query showed 67 candidates with 67 distinct A ids and 67 distinct B ids, so it was correct by luck rather than by design.
- Mistake: The upper bound of the period was hardcoded to 15:36 on 25 Nov rather than taken as min(max_a, max_b). It did no harm because B ends at 12:08 and A runs later.
- Mistake: Some effort went into decorative land paths that the task did not ask for.
