---
title: "Gemini 4 Hydrogen 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-hydrogen/geo_analyst/
---

# Gemini 4 Hydrogen 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-hydrogen/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-hydrogen.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $1.49 | 129      | 176        | 16.3 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

The model passed all 20 runs: 10 cases, each run once with tool calling and once in code mode. Totals:

| Mode      | Passed | Requests       | Cost  |
| --------- | ------ | -------------- | ----- |
| Tools     | 10/10  | 129 (avg 12.9) | $1.49 |
| Code mode | 10/10  | 115 (avg 11.5) | $1.15 |

Costs ranged from about $0.04 (deep_moment, mato_grosso) to $0.50 (pair_map_hypo, tools).

#### Where it does well

- **Reads DATA.md first and decodes the stored fields.** It handled:
  - magnitudes stored in hundredths (m>=250, m>=500)
  - catalogue A depth in signed metres vs catalogue B depth in km
  - mk=3 as moment magnitude
  - place kinds S/H/Q excluded as non-settlements
  - local-offset and year-day timestamps converted to UTC
- **Picks the right entity when names are ambiguous.** It chose Anchorage, Alaska over Kentucky (b_gof) and Mato Grosso BRA-602 over Mato Grosso do Sul (mato_grosso).
- **Gets the geometry right.**
  - Antimeridian unwrapping and 3D midpoints in pair_map_hypo.
  - Great-circle projection in cross_section.
  - Invalid Goiás polygon fixed with ST_MakeValid in brazil_nn.
  - Graph connected components computed in SQL in world_clusters.
- **Cross-checks its own answers.** It routinely used a second method: Covers/Contains/Intersects, chord vs haversine, SQL vs Python brute force. It also probed events near the thresholds.
- **Catches subtle errors.**
  - In local_night (tools), it noticed that a lossy latitude prefilter produced 5733 km "nearest" distances and switched to a full cross join.
  - In world_clusters, it fixed float-rounding problems with an integer sum (tools) or Decimal (code mode).

#### Mistakes it makes

None of these changed an answer.

- **Hard-coded time windows.** In b_only_hypo and pair_map_hypo (both modes), it hand-rounded the overlap window (16:00–15:36) instead of deriving it from the data.
- **Conventions applied without a visible check.** In deep_moment, mato_grosso, b_gof and world_clusters, it used k='T', cls='H', UTC days or the haversine radius without the transcript showing where that came from.
- **Shortcuts that would not generalise.**
  - pair_map_hypo (tools) skipped an explicit greedy matching step because the candidates already happened to be one-to-one.
  - b_gof (code mode) used floor-based rounding that is questionable for negative halves.
- **Wasted calls from avoidable errors.**
  - `by` used as a reserved-word alias: cross_section, and twice in world_clusters (tools).
  - Multi-statement batches that returned only the last result: mato_grosso (tools), b_only_hypo (code).
  - Sandbox limitations in code mode: no `xml.etree` or `html` module, `write_text` rejecting an encoding argument, a missing `asyncio` import, and `timedelta` type errors.
- **Redundant work.** It re-ran CTEs and repeated nearest-neighbour passes.

#### Tool calling compared with code mode

Accuracy was identical. Code mode was about 22% cheaper and used 11% fewer requests overall. Most of that gap comes from one case: pair_map_hypo cost $0.50 over 27 requests with tools versus $0.20 over 16 in code mode. Without that case, totals are almost equal ($0.98 vs $0.95).

Neither mode wins case by case:

- **Code mode was cheaper on:** cross_section, world_clusters, b_only_hypo, exposed and mato_grosso.
- **Tools were cheaper on:** b_gof, brazil_nn, local_night and deep_moment.

Code mode made it easy to add independent Python checks. Its typical failures were sandbox and library errors, while tool mode's were SQL syntax mistakes.

## Runs

### deep_moment

**Tool calling: passed.** The agent read DATA.md and inspected the catalogue A schema. It filtered quakes_a.jsonl on UTC dates 1–15 Nov, k='T', mk=3 (moment magnitude), m>=500 and z\<-70000, which returned 7 events, and it answered 7, which is correct. ($0.037, 6 requests, 17 s)
- Right: Read DATA.md before querying and checked the raw lines to see that timestamps carry local offsets, then converted them to UTC.
- Right: Applied the encodings correctly: magnitude scaled ×100 (m>=500), depth in metres as a negative elevation (z\<-70000), and mk=3 for moment magnitude.
- Right: Checked id uniqueness (9566 rows, 9566 distinct ids) before counting, so duplicates were ruled out.
- Right: Ran a broader sanity query over a widened window with relaxed thresholds. It showed events with mk=2 (a different magnitude type) and boundary cases near the edges, which supported the strict filter.
- Mistake: Minor: it filtered on k='T' without stating why, and the transcript does not show it checking which other k values exist. This was probably justified by DATA.md but was not checked visibly.
- Mistake: Minor: the wider sanity query's results were not explicitly reconciled before answering, though the answer was still correct.

### mato_grosso

**Tool calling: passed.** The agent read DATA.md, found the Mato Grosso polygon (BRA-602) in regions.tsv, filtered fires to 21 Nov 2026 UTC with cls='H', and counted 5 points inside the state with ST_Covers. It answered 5, which is correct. ($0.043, 7 requests, 23 s)
- Right: Read DATA.md before querying.
- Right: Told Mato Grosso (BRA-602) apart from Mato Grosso do Sul (BRA-600).
- Right: Checked that the session timezone is UTC and confirmed the epoch bounds for the day.
- Right: Ran ST_Covers, ST_Contains and ST_Intersects side by side and checked distinct fids; all gave 5.
- Right: Pulled high-confidence detections within 0.5° of the border and ±1h of the day to make sure no edge cases were missed. The three nearby points (fids 256541, 256554, 256555) fall outside the polygon.
- Mistake: The first run_sql call batched three statements and only the last result (DESCRIBE) came back, so the country and region lookups had to be re-run. This was minor waste.
- Mistake: The transcript does not show whether the agent checked DATA.md for a day convention (UTC vs local time) or for how the confidence codes are defined. It went straight to UTC days and cls='H'. That matched the expected answer, but the excerpt does not show it confirmed the convention.

### b_only_hypo

**Tool calling: passed.** The agent parsed both catalogues, converted catalogue B's year-day plus seconds-of-day times and its N/S/E/W coordinates, and limited B to the overlap window (about 26 Oct 16:00 to 25 Nov 15:36 UTC) with mag >= 4.5, giving 442 events. It then anti-joined against A on |dt| \<= 30 s and 3D hypocentre distance \<= 50 km, got 36, and confirmed that number with an independent Cartesian NOT EXISTS query. The answer 36 matches the expected one. ($0.15, 16 requests, 86 s)
- Right: Read DATA.md first and handled catalogue A's signed z in metres (6371 + z/1000) and catalogue B's positive depth in km (6371 - depth) correctly when computing hypocentre distance.
- Right: Built B's timestamps from the YYYY-DDD date plus seconds-of-day and treated them as UTC with AT TIME ZONE 'UTC'.
- Right: Checked the formats of B's lat, lon and date strings with regex counts and found no bad rows.
- Right: Restricted B to the period both catalogues cover, using the min/max of A's times converted to UTC.
- Right: Checked how fragile the result was with a near-miss query at 45 s / 80 km: the closest misses were 51.6 km and 39 s, well clear of the thresholds.
- Right: Cross-checked the 36 with a second method, a Cartesian xyz distance inside a NOT EXISTS query.
- Mistake: Used a hand-rounded overlap window (16:00 to 15:36 UTC) instead of A's exact min and max times (16:02:31.9 and 15:35:51). The earlier window check found no B events in those gaps, so the result was unaffected.
- Mistake: Tried a SET statement on the read-only database and made a column-spec error in one read_csv call. Both were minor wasted calls that it recovered from.

### local_night

**Tool calling: passed.** The agent filtered catalogue A to tectonic events (k='T') with m>=250 (magnitude ×100), giving 1804 quakes. It found each quake's nearest settlement (excluding kinds S, H, Q) by a full cross join, converted the UTC time to that settlement's tz and counted 787 at night, which matches the expected answer. ($0.095, 12 requests, 1.6 min)
- Right: Read DATA.md first and applied its conventions: magnitude stored ×100 (m>=250), event-type filter k='T', and settlement kinds excluding S/H/Q.
- Right: Noticed that the `abs(lat diff) <= 15` prefilter gave a max nearest distance of 5733 km. Switched to a full CROSS JOIN, which brought it down to 3372 km and removed the risk of wrong nearest matches.
- Right: Checked for nearest-place ties: 8 exact ties, all with the same tz, so they could not change the result.
- Right: Checked that every place tz is a valid DuckDB time zone and that no quake fell exactly on the 20:00 or 06:00 boundary.
- Right: Cross-checked the count by ranking on haversine distance instead of chord distance and by testing both hour-based and TIME-based night filters; all gave 787.
- Right: Confirmed there are no duplicate event ids and that places.psv parses fully (172098 data rows).
- Mistake: The first nearest-place query used a lossy latitude-band prefilter whose result could have been wrong. The agent caught this, but the step was an extra full-scale query.
- Mistake: Minor: one query failed with a GROUP BY binder error and was rerun; some later checks (the line count of places.psv) added little.

### brazil_nn

**Tool calling: passed.** The agent filtered VIIRS detections (VJ1/VJ2) to Brazil's 27 states with ST_Covers and found each detection's nearest settlement (pop ≥ 10,000, excluding kinds S/H/Q) by haversine distance. It then computed per-state medians and returned counts and medians to one decimal, all matching the expected answer. ($0.12, 13 requests, 1.7 min)
- Right: Read DATA.md and checked the sat/px_m breakdown, then correctly treated VJ1/VJ2 (375 m) as the VIIRS detections.
- Right: Checked that the point-in-polygon result was the same under ST_Covers, ST_Contains and ST_Intersects (93791 each). Also confirmed the invalid Goiás geometry gave the same membership after ST_MakeValid.
- Right: Verified the nearest-settlement distances by rerunning with a wider ±10°/±12° window against the full worldwide settlement table and found 0 differences. This addresses the 'in any country' requirement.
- Right: Computed the median two ways, by explicit row-number averaging and with DuckDB MEDIAN, and checked how close each value sat to a rounding boundary.
- Mistake: The first nearest-distance pass, with a ±3°/±4° window, was superseded by the ±6°/±8° pass and then the ±10°/±12° check. This was a few redundant queries but harmless.
- Mistake: The agent excluded places of kind S, H and Q based on DATA.md conventions, but did not show in the transcript why. The result matched, so this was presumably the correct rule.

### exposed

**Tool calling: passed.** The agent read DATA.md and profiled catalogue A and the places file. It filtered to earthquakes (k='T'), scaled magnitude (m/100) and depth (z in metres), and computed true 3D hypocentral distances to settlements with pop ≥ 500,000 that are not of kind S/H/Q. It returned 23 place ids that exactly match the expected answer. ($0.077, 9 requests, 46 s)
- Right: Read DATA.md before querying, applying the settlement definition (kind not S/H/Q) and catalogue A's codes and units.
- Right: Restricted events to k='T' (earthquakes), leaving out quarry blasts, explosions and other non-earthquake event types.
- Right: Converted the integer magnitude (m/100) and depth in metres (z/1000) correctly, and used a 3D hypocentre distance rather than a surface distance.
- Right: Checked the result two ways: an ECEF chord query with a ratio margin, then a haversine-based slant-range query. Both gave the same set.
- Right: Checked that excluding S-kind places (e.g. the Tokyo wards Setagaya and Adachi) actually changed the result, confirming the settlement rule mattered.
- Mistake: No substantive errors. The one event with a null magnitude was silently dropped, which is reasonable. The agent ran the cross-join distance query several times, which was slightly redundant but cheap.

### b_gof

**Tool calling: passed.** The agent found Anchorage, Alaska (pid 5879400), kept catalogue A events with k='T' and mk=1 within 300 km, rounded magnitudes half up using integer hundredths, ran the goodness-of-fit Mc search in SQL, and reported b=1.152 at Mc=2.0. This matches the expected answer. ($0.078, 8 requests, 60 s)
- Right: Picked the Alaska Anchorage (pid 5879400) over the Kentucky place with the same name.
- Right: Checked the magnitude kind and code breakdown and kept only the local-magnitude rows (k='T') with a non-null m.
- Right: Did the half-up rounding exactly on integer hundredths with FLOOR((m+5)/10), which avoids floating-point error.
- Right: Built the whole Mc/R grid in one query, filling empty bins with 0 so that zero counts still enter the residual sum.
- Right: Recomputed b at Mc=2.0 separately to confirm 1.152133.
- Mistake: Did not report which mk values and units it relied on; it inferred from the data that m is stored in hundredths. This appears consistent with DATA.md, but the transcript does not show it being checked against the dictionary.
- Mistake: Did a minor boundary check on events near 300 km but never confirmed the distance convention (haversine with R=6371) in DATA.md; the result passed anyway.

### world_clusters

**Tool calling: passed.** The agent filtered the data to the VIIRS satellites (VJ1, VJ2), built spatiotemporal links (haversine distance ≤1 km, time gap ≤43200 s) with a 3D grid join, and found connected components by iterated hook-and-jump in SQL. It returned 45 clusters of 300 or more detections whose counts and FRP sums match the expected answer, and the run passed. ($0.22, 20 requests, 2.1 min)
- Right: Correctly treated 'VIIRS' as satellites VJ1/VJ2 (375 m pixels) and excluded the MODIS sources MA/MT.
- Right: Built an efficient 3D-cell neighbour join (cell size 1.05 km), then cross-checked it with an independent lat/lon binning. Both gave 1,874,135 edges.
- Right: Probed edge pairs near the 1 km boundary to confirm the chord prefilter did not drop any valid links.
- Right: Ran hook and pointer-jump rounds until no cross-component edges remained, then checked that every root equals the minimum fid of its component.
- Right: Converted kW to MW correctly. It also caught that summing pre-divided doubles changed the rounding for 4 clusters and used integer sum / 1000 instead.
- Mistake: The two-statement 'CREATE … ; SELECT count(DISTINCT (bx, by, bz))' query failed with a parser error at 'by' (a reserved keyword used as a column name), and the retry that still referenced 'by' failed the same way, costing two wasted calls before the columns were renamed cx/cy/cz.

### cross_section

**Tool calling: passed.** The agent loaded catalogue A and projected epicentres onto the great circle with vector math in DuckDB SQL. It kept events with k='T', a magnitude, a cross-track distance of at most 150 km and an along-track angle in [0, θ_ab], then wrote an SVG with 25 circles whose positions match the expected answer to about 0.01 px, and the run passed. ($0.16, 11 requests, 1.7 min)
- Right: Read DATA.md first and used the documented conventions: z in negative metres converted to depth km, m in hundredths of a magnitude unit, and filtering on k='T' (presumably the documented event-type code).
- Right: Computed the nearest point on the great circle with a correct orthonormal basis (normal n and tangent t) and scaled along-track distance by θ_ab, so the end point sits at x=1000.
- Right: Checked borderline events, such as us7000ttnt beyond the end point, and confirmed that the perpendicular distance agreed with a haversine distance to the projected point.
- Right: Kept circle radii within 2.5–5.65 px and put data-id only on the circles.
- Mistake: The first SQL attempt failed because `by` is a reserved word used as a column alias, costing one extra call.
- Mistake: Several redundant exploratory queries recomputed the same CTE chain; this was wasteful but harmless.
- Mistake: Coordinates were rounded to 2 decimals (e.g. 317.89 against 317.895), which was within tolerance.

### pair_map_hypo

**Tool calling: passed.** The agent filtered catalogue A (M≥4.5) and catalogue B (M≥4.0, within A's time span) to the antimeridian-crossing box and found 67 candidate pairs that were already one-to-one. It computed great-circle midpoints, projected them with a 160°E origin and +360 wrap, and wrote a 900×900 SVG with 158 data-id circles. The run passed. ($0.50, 27 requests, 5.4 min)
- Right: Handled the antimeridian correctly: the box used lon >= 160 OR lon \<= -170 and x was computed from (lon+360 if lon\<0) - 160 at 30 px per degree.
- Right: Computed great-circle midpoints through 3D unit-vector averaging and atan2, so the nine pairs straddling 180° landed at the right place.
- Right: Checked the 0.5° band around the box edges and the pairs out to 120 s and 100 km for borderline cases; neither turned up any.
- Right: Confirmed the candidate set was already one-to-one (67 candidates, 67 distinct A, 67 distinct B), so the greedy ordering could not change the result.
- Right: Used 3D hypocentral distance with depth, applying catalogue A's z in metres and B's depth in km.
- Right: Final counts of 67 matched, 67 unmatched A and 24 unmatched B at M≥4.5 match the expected 158 points.
- Right: Wrote the SVG with width/height of 900, circle radii of 3.5 and 4.5, data-id only on the circles, and clipped land polygons as context.
- Mistake: It never built an explicit greedy one-to-one matching step and relied on the candidates already being unique; that was correct for this data but would not generalise.
- Mistake: The time window for 'period both cover' was hard-coded to 2026-10-26 16:00 through 2026-11-25 15:36, rounded outward from A's actual range of 16:02:31 to 15:35:51 rather than taken from it. The intersection with B's span is what counts; this happened to give the same result.
- Mistake: Effort was wasted re-creating the qa/qb tables in almost every query, and on several failed SVG/ST_DumpPoints syntax attempts.
