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

# Gemini 3.8 Flash on Pydantic AI Geo Analyst

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

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 80%   | 8 of 10      | $2.20 | 410      | 408        | 45.1 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

The model reached the correct answer in all 20 runs where it submitted one. Code mode passed 10 of 10 cases. Tool calling passed 8 of 10. Both tool-calling failures were `UsageLimitExceeded` at 80 requests, not wrong answers:

- **brazil_nn**: its last query already matched the expected answer, but it never submitted.
- **world_clusters**: it had confirmed the correct 45 clusters but never computed the FRP sums.

#### Where it does well

- **Following the docs.** It reliably applied DATA.md conventions: class T means earthquake, `m` is stored in hundredths, `z` is negative metres, the radius is 6371 km, and settlements exclude kinds S/H/Q.
- **Checking its own work.** It routinely tested near-threshold cases and cross-checked results independently:
  - exposed: Shihezi at 44.89 vs 44.67 km
  - b_only_hypo: Python and SQL both gave 36
  - local_night: dot-product and haversine nearest neighbours disagreed on 0 quakes
- **Avoiding unsafe shortcuts.** For nearest neighbours it used exact methods, either brute force or a grid join with fallback. In local_night, 213 quakes had no settlement within 5°, so a bounding-box join would have missed them.
- **Tricky formats.** It handled the antimeridian (pair_map_hypo), catalogue B's year-day timestamps, offset timestamps (deep_moment code mode), and same-named places such as Anchorage and Mato Grosso.

#### Mistakes it makes

- **Wasted requests.** This happened in nearly every run: repeated probes, unused RTREE indexes and EXPLAINs, and abandoned pipelines. In tool mode it caused both failures.
- **Truncated documentation.** It relied on DATA.md reads that were cut off and inferred field meanings from sample data instead (deep_moment, cross_section tools, brazil_nn code). The guesses were right.
- **Unjustified filters.** It added filters the task did not justify: k='T' in cross_section (tools) and exposed (code), and the S/H/Q exclusion in exposed (tools). In both k='T' cases its own check confirmed the filter was harmless.
- **Fragile shortcuts that happened to work:**
  - It hand-typed rounded overlap bounds (b_only_hypo tools, pair_map_hypo code).
  - It skipped the greedy matching step because candidates happened to be unique (pair_map_hypo tools).
  - In b_gof (tools), its own check showed DuckDB's `round()` is not half-up for negatives, but it kept using it.
  - It assumed UTC days without checking (mato_grosso, both modes).
- **Coding slips.** It used the reserved word `by` as an alias, wrote a sin/cos typo in exposed (code), and called unavailable Python modules (`random`, `heapq`, `xml`).

#### Tool calling compared with code mode

|                               | Tools | Code mode |
| ----------------------------- | ----- | --------- |
| Passed                        | 8/10  | 10/10     |
| Total requests                | 410   | 344       |
| Total cost                    | $2.20 | $1.82     |
| Requests, 8 cases both passed | 250   | 239       |
| Cost, 8 cases both passed     | $1.38 | $1.25     |

Code mode used fewer requests in 8 of 10 cases. The exceptions were exposed (37 vs 24) and pair_map_hypo (54 vs 47). It cost more only on exposed and tied on deep_moment.

The biggest gap is on heavy cases:

- **brazil_nn**: 50 requests in code mode versus 80 and a failure with tools.
- **world_clusters**: 55 requests in code mode versus 80 and a failure with tools. Code mode could batch work, while tool mode ran each label-propagation round as a separate call.

Code mode's own waste came mostly from sandbox errors such as missing modules and type errors.

## Runs

### deep_moment

**Tool calling: passed.** The agent read DATA.md, queried quakes_a.jsonl in DuckDB with filters for class T, mk=3, m>=500, z\<-70000 and UTC dates 1–15 November. It found 7 events, matching the expected answer. ($0.050, 13 requests, 54 s)
- Right: Applied the documented conventions: moment magnitude means mk=3, an earthquake is class T, and the date range includes both ends, so it used t < '2026-11-16' in UTC.
- Right: Ran a boundary check with a wider window and looser thresholds (m>=480, z\<-60000, 31 Oct–16 Nov). This confirmed which events sat near the edges, e.g. us7000tyga at 4.9 was excluded and us7000tyfh at 15 Nov 17:48 was included.
- Right: Ordered the candidates by depth to confirm the 70 km cutoff. us7000txm8 at -74384 is in; us7000txb8 at -59652 is out.
- Right: Checked that no non-T events would have matched, for completeness.
- Mistake: The first read_text of DATA.md was cut off ('[3070 more characters]') and the second read began at line 50. The quakes_a key table, which defines the units and signs of z and m, was probably never fully read. The agent instead guessed from sample rows that z is negative metres and m is magnitude×100. The guess proved right, but it was not confirmed against the documentation.
- Mistake: It never looked into the `rv` field (likely a revision number) or checked for duplicate ids or revisions. If the file held several revisions per event, the count could have been inflated. The result was correct, but this went unverified.

### mato_grosso

**Tool calling: passed.** The agent read DATA.md, located Mato Grosso (BRA-602) in regions.tsv, filtered fires.parquet to cls='H' on 2026-11-21 (UTC) and ran a point-in-polygon test, which returned 5 detections. It submitted {"count": 5}, which matches the expected answer. ($0.055, 16 requests, 84 s)
- Right: Matched names with ILIKE and so separated Mato Grosso (BRA-602) from Mato Grosso do Sul (BRA-600).
- Right: Checked the geometry type and bounding box, then ran both ST_Intersects and ST_Contains as a cross-check; both gave 5.
- Right: Re-ran the count using explicit epoch bounds (1795219200 to 1795305600) and grouped by cls (L=2, H=5, N=74), which confirmed the filter worked.
- Mistake: The transcript never shows the agent checking whether DATA.md defines the day by local time or UTC for fire detections. It used UTC dates without comment. The answer matched, so this was either correct or harmless here.
- Mistake: Several calls added little, such as the ST_Point(-55,-12) sanity check and the timestamp conversion of a single value.

### b_only_hypo

**Tool calling: passed.** The agent parsed both catalogues and restricted catalogue B (mag ≥ 4.5) to the overlap window, about 26 Oct 16:00 to 25 Nov 15:36. It computed 3D hypocentral distances in ECEF coordinates and anti-joined against catalogue A on 30 s / 50 km, which left 442 B events with 406 matched and 36 unmatched. It answered 36, which is correct. ($0.18, 38 requests, 3.4 min)
- Right: Read DATA.md first and checked each catalogue's time span to set the overlap window.
- Right: Correctly parsed catalogue B's year-day plus seconds-of-day time format and its N/S/E/W coordinate suffixes.
- Right: Noticed that catalogue A's JSON stores local offset times and confirmed that DuckDB converts them correctly to UTC epochs.
- Right: Treated A's z as signed metres (negative is down) and B's depth as km, and used 3D straight-line distance for the hypocentre.
- Right: Ran sanity checks: near-threshold cases at 49.8 km and 51.6 km, the largest matching time difference (6.3 s), and the class, rv and magnitude spread of the matched A events.
- Mistake: Did not compute the overlap window from the data. The agent typed bounds rounded to the minute ('2026-10-26 16:00:00' and '2026-11-25 15:36:00') instead of using A's actual first and last event times. A B event falling in a gap of up to two minutes could have been counted wrongly. It worked here, partly by luck, though the agent did check that no B events fell around 26 Oct 15:00–17:00.
- Mistake: Spent a few extra calls on diagnostics that did not change the answer, such as the haversine comparison and the rv/k breakdowns.

### local_night

**Tool calling: passed.** The agent filtered catalogue A to tectonic events (k='T') with m>=250, which is magnitude 2.5 in hundredths, giving 1804 quakes. It found each quake's nearest settlement by brute-force great-circle distance, converted the origin times to that settlement's tz, and counted local times from 20:00 to before 06:00. The answer, 787, matched the expected count. ($0.24, 51 requests, 3.9 min)
- Right: Read DATA.md and applied its conventions: magnitude stored in hundredths (m>=250), earthquake means class T, and settlements exclude place kinds S, H and Q.
- Right: Computed the nearest settlement exactly by cross-joining all 162k settlements, rather than using a bounding-box shortcut. The agent's own check showed 213 quakes had no settlement within 5°, so a box join would have missed them.
- Right: Cross-checked the dot-product nearest neighbour against a haversine argmin; the two disagreed on 0 quakes.
- Right: Checked ties at a tolerance of 1e-12 and found none that changed the time zone; the remaining ties, such as Hasaki/Choshi, were both Asia/Tokyo.
- Right: Confirmed the DST transition is handled by DuckDB's AT TIME ZONE, and confirmed the night window two ways (time comparison and hour extraction), both giving 787.
- Mistake: Several wasteful steps: an RTREE index was built and EXPLAINed but never used, and a tie query timed out after 30 seconds. Further validation queries (non-T events, pop=0 places, duplicate ids) did not change the answer.

### brazil_nn

**Tool calling: error.** The agent computed the correct per-state counts and median distances for all 27 Brazilian states, matching the expected answer exactly. It used up the 80-request limit on redundant checks and never submitted, so the run failed with UsageLimitExceeded. ($0.34, 80 requests, 5.4 min)
- Right: Filtered VIIRS correctly (sat VJ1/VJ2), settlements correctly (kind not S/H/Q, pop >= 10000) and assigned fires to the BRA regions with ST_Intersects, getting 93,791 fires across 27 regions.
- Right: Used a bounded nearest-neighbour approach: ST_DWithin joins with a 2-degree window, a check on whether each result was guaranteed correct, and a full cross join for the 458 unresolved fires.
- Right: Checked that ST_Distance_Sphere matches haversine with R=6371 km.
- Right: Noticed that the first explicit-median query used float division (n+1)/2 and got wrong values, fixed it with //, and confirmed quantile_cont/median gives the same result.
- Right: The final query (last call) produced counts and medians that match the expected answer for every region.
- Mistake: Never called the final answer/submit tool after the last query at the end of the transcript had the correct results, so the run ended in UsageLimitExceeded.
- Mistake: Wasted many requests on redundant checks: listing ST_Drivers, re-listing BRA regions twice more, repeated ST_DWithin count probes at 1.0/2.5/5.0/2.0/4.0 degrees, building an unused fire_min_dist_1/remaining_fires pipeline, several toy median tests, a quantile_exact attempt, function listings, a countries.geojson lookup for 'Brazilian I.', and null checks on places.
- Mistake: Re-ran the full fire-in-region join against the raw parquet just to confirm the same count of 93,791.

### exposed

**Tool calling: passed.** The agent read DATA.md, filtered places with pop >= 500,000 that are not section/historical kinds, and kept class-T catalogue A events. It computed 3D straight-line hypocentre distances with depth z in metres (negative below the surface) and returned 23 place ids, which match the expected set. ($0.13, 24 requests, 2.4 min)
- Right: Read DATA.md and followed its conventions: straight-line hypocentre distance on a 6371 km sphere, earthquakes = class T, and m stored in hundredths.
- Right: Handled the sign and units of depth correctly by using 6371 + z/1000, with z negative in metres.
- Right: Swapped its first latitude-only bounding-box join for a full CROSS JOIN, which avoided missing matches.
- Right: Checked near-threshold cases, e.g. Shihezi at 44.89 vs 44.67 km is correctly excluded and Los Angeles at a margin of 0.87 km is included.
- Right: Cross-checked the result with an independent law-of-cosines formula and got the same 23 ids.
- Mistake: Excluded place kinds S, H and Q without the transcript showing a DATA.md rule that justifies it; it happened to match the expected answer.
- Mistake: Made some redundant verification queries: the non-T events check and repeated full cross joins.

### b_gof

**Tool calling: passed.** The agent filtered catalogue A to class-T, local-magnitude (mk=1) events within 300 km of Anchorage, Alaska (1,613 events). It ran the goodness-of-fit Mc scan in DuckDB, found Mc=2.0 as the lowest candidate with R=89.52, and correctly answered b=1.152. ($0.13, 34 requests, 2.8 min)
- Right: Read DATA.md and applied its conventions: the 'earthquake = class T' rule, mk=1 for local magnitude, and haversine distance with R=6371.0 km.
- Right: Found the right Anchorage (61.21806, -149.90028) among two same-named places and confirmed it lies in Alaska using regions.tsv.
- Right: Built a full 0.1-step magnitude grid with a LEFT JOIN, so zero-count bins (3.8, 4.0) counted in the predicted-vs-observed sum.
- Right: Implemented the b, a, predicted-count and R formulas exactly as stated and confirmed R=89.52 at Mc=2.0 by listing each bin.
- Right: Printed the unrounded b (1.152133509) before rounding it to 3 decimals.
- Mistake: The task says to round halves up. The agent's comparison query found 9 negative values (e.g. -0.45, -0.55) where DuckDB's round() goes away from zero instead of up (-0.5 vs -0.4). It still built the events table with round(m/100.0, 1) rather than the half-up floor((m+5)/10)/10 it had already written. This was harmless only because every affected event is below 0, far under the chosen Mc of 2.0.
- Mistake: Minor wasted calls: a timezone/longitude probe (lon/15 and the offset suffix) unrelated to the question, a repeated Anchorage lookup, and a recomputation without the class-T filter.

### world_clusters

**Tool calling: error.** The agent built a 3D-voxel plus 12-hour time-slice spatial join in DuckDB, created about 1.87M edges among VIIRS detections and ran iterative label propagation with pointer jumping. It reached 45 clusters of 300 or more detections, which matches the expected 45 rows, but hit the 80-request limit before computing FRP sums or returning an answer. ($0.48, 80 requests, 12.7 min)
- Right: Correctly limited the data to VIIRS satellites (VJ1, VJ2), 680,723 detections.
- Right: Converted lat/lon to 3D chord distance with a threshold equal to a 1 km great-circle distance, and checked near-boundary pairs against haversine (0 mismatches out of 159).
- Right: Got around the 30 s query timeouts by splitting edge creation into a same-slice CREATE and an adjacent-slice INSERT.
- Right: Connected components via min-label contraction converged in 4 rounds and gave 45 clusters of 300 or more, which matches the expected count.
- Mistake: Spent many requests on exploratory dead ends: function and extension probing, a recursive CTE that timed out, toy recursive tests, prototyping on a single 0.5° box with ~6 manual rounds, and a whole coarse 0.05° cell-component pass (~8 calls) that was never used.
- Mistake: Several EXPLAIN/PRAGMA attempts and repeated timed-out edge-building queries also used up budget.
- Mistake: Never ran the final step: joining active_nodes to viirs to sum frp_kw/1000 per cluster with HAVING count >= 300. Ran out of requests right after confirming the 45-cluster count.
- Mistake: Ran each label-propagation round as a separate call instead of batching several rounds in one multi-statement query, which used more of the request budget.

### cross_section

**Tool calling: passed.** The agent built great-circle basis vectors in DuckDB, projected catalogue A epicentres to get cross-track distance and along-track angle, and selected 25 events within 150 km whose nearest point lies between the end points. It wrote an SVG with 25 circles whose coordinates match the expected answer and correctly reported 25; the run passed. ($0.18, 27 requests, 5.0 min)
- Right: Built an orthonormal frame (a, e2, n) for the great circle and checked it: dot products came out 0 and norms 1.
- Right: Computed cross-track distance as asin(p·n)·6371 and along-track position as atan2(p·e2, p·a), restricted to 0 ≤ sigma ≤ sigma_ab, which matches the 'nearest point lies between end points' condition.
- Right: Converted depth correctly from the negative-metre z field (-z/1000 km) and scaled 700 km to 500 px.
- Right: Initially filtered k='T', but then reran without the type filter and without the magnitude filter and confirmed the same 25 events, so nothing was wrongly excluded.
- Right: Checked events near the 150 km boundary and near the end points (e.g. us7000tx0f at 135.2 km, us7000ttnt with sigma just past sigma_ab) before finalising.
- Right: Output met the format rules: circles of radius 4 and data-id only on circles.
- Mistake: Three queries failed with parser errors because `by` is a reserved word in DuckDB, so it was used as a column alias. A throwaway `CREATE TABLE t1` was also run while debugging, which wasted calls.
- Mistake: The k='T' filter was not justified by the task. It was harmless only because the later check showed no non-T events qualified.
- Mistake: Never read the remainder of DATA.md past line ~200 (the quakes_a section in the first read was truncated), so it relied on inferring the meaning of z and m from the data.

### pair_map_hypo

**Tool calling: passed.** The agent filtered both catalogues to the area and overlap period, found 67 one-to-one candidate pairs using 3D hypocentre distance, computed great-circle midpoints, and projected 158 features (67 pairs, 67 unmatched A, 24 unmatched B M≥4.5) into a 900x900 equirectangular SVG. The run passed. ($0.42, 47 requests, 7.2 min)
- Right: Parsed catalogue B's year-dayofyear plus seconds-of-day timestamps correctly and found the overlap start from catalogue A's earliest event (2026-10-26).
- Right: Handled the antimeridian-crossing area with (lon >= 160 OR lon \<= -170) and shifted negative longitudes by +360 when projecting, giving x=(lon-160)\*30 and y=(-10-lat)\*30.
- Right: Used 3D hypocentre distance with depth (A's z converted from negative metres to km), as the task asked for hypocentres.
- Right: Checked that every candidate was unique per A id and per B id, which showed the greedy ordering would accept all 67 pairs.
- Right: Computed the midpoint by normalising the sum of unit vectors and checked it with haversine distances (equidistant from both epicentres and on the arc).
- Right: Applied the M≥4.5 rule to unmatched B events only, leaving out 4 unmatched B events below 4.5.
- Right: Checked the magnitude scaling of A's m field (÷100) and the event type codes (all 'T').
- Mistake: Never implemented the greedy ordered matching (time diff, distance, A id, B id); it relied on candidates happening to be unique. This was correct here but would not generalise.
- Mistake: Repeated the same long CTE about ten times, and paged the SVG output out through SQL before writing it with write_file instead of building it once.
- Mistake: Its last call tried to read /out/map.svg back through DuckDB to verify it, which failed on permissions, so the written file was never verified.
