---
title: "DeepSeek V4.1 Flash on Pydantic AI Geo Analyst"
description: "Spatial questions and SVG maps from raw earthquake, fire and place data in DuckDB. Tool calling 60%, code mode 80%; rank 19 of 20."
canonical: https://models.pydantic.dev/models/deepseek-v4.1-flash/geo_analyst/
---

# DeepSeek V4.1 Flash on Pydantic AI Geo Analyst

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

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 60%   | 6 of 10      | $0.12 | 175      | 238        | 25.5 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

The model passed 14 of 20 runs: 6/10 with tool calling and 8/10 in code mode. On the cases it finished, its analysis was usually right. All six failures came from the final step: it submitted empty results, made up a number, or quit early. None came from wrong analysis. Total spend was $0.209 across 322 requests.

#### Where it does well

- **Applying data conventions.** It read DATA.md first and correctly applied magnitude in hundredths, depth as negative metres, class `T` for earthquakes, and VIIRS = VJ1/VJ2. These were used correctly in b_gof, exposed, cross_section and pair_map_hypo.
- **Geometry.** It used 3D hypocentral distance rather than epicentral distance. In exposed (tools), that excluded 10 places, and in b_only_hypo (code), epicentral distance would have given 26 instead of 36. It also produced correct great-circle midpoints and cross-track projections, and handled the antimeridian in pair_map_hypo.
- **Disambiguation.** It picked Anchorage, Alaska over Anchorage, Kentucky (b_gof) and Mato Grosso over Mato Grosso do Sul (mato_grosso, code).
- **Self-checking.** It recomputed answers independently, for example with a Python re-run in b_only_hypo, a union-find check in world_clusters, and AT TIME ZONE re-counts in local_night. It also probed borderline events.

#### Mistakes it makes

- **Throwing away correct results (3 failures).** In brazil_nn (tools) and world_clusters (both modes), the model had computed rows that matched the expected answer: 27, 43 and 45 rows respectively. It then called `final_result({"rows": []})`.
- **Answering without querying (2 failures).** In mato_grosso (tools) it ran no SQL and answered 42 when the answer was 5. In deep_moment (code) it read a truncated DATA.md and answered 213 when the answer was 7. Both runs used only 6 and 2 requests.
- **Stopping partway (1 failure).** In local_night (tools) it tested a nearest-place join on 50 events, never converted to local time, and submitted 0 when the answer was 787.
- **Wasted calls.** In nearly every run, some calls were lost to avoidable errors:
  - reserved words used as aliases (`by`, `at`)
  - missing columns or functions (`ST_DistanceSphere`)
  - "already exists" errors on CREATE TABLE
  - an un-awaited coroutine
  - numpy/timedelta type errors

#### Tool calling compared with code mode

| Mode      | Passed | Requests | Cost   |
| --------- | ------ | -------- | ------ |
| tools     | 6/10   | 175      | $0.115 |
| code_mode | 8/10   | 147      | $0.094 |

Code mode passed more cases while using fewer requests and costing less. Where both modes passed, code mode was often cheaper, for example b_gof at $0.0035 vs $0.0092 and pair_map_hypo at 15 vs 26 requests.

The failure types were the same in both modes, and which mode failed varied by case. deep_moment passed with tools but failed in code mode, while mato_grosso and local_night did the reverse. world_clusters failed in both modes for the same reason: an empty submission after a correct computation.

The main risk in either mode is the final answer step rather than the analysis. If you deploy this model, add checks that the submitted answer contains the computed results and that numeric answers come from executed queries.

## Runs

### deep_moment

**Tool calling: passed.** The agent read DATA.md, sampled quakes_a.jsonl, and ran one DuckDB query filtering k='T', mk=3, m>=500, z\<-70000 over 1–15 Nov UTC. It got 7, listed the 7 events to check them, and answered {"count": 7}, which is correct. ($0.0018, 6 requests, 20 s)
- Right: It read DATA.md before querying, so it understood the encodings: magnitude in hundredths (m>=500 for 5.0), depth in metres as a negative elevation (z\<-70000 for more than 70 km below sea level), and the mk/k codes.
- Right: It parsed the timestamps, which carry mixed UTC offsets, as TIMESTAMPTZ and compared them against UTC bounds, using an exclusive end of 16 Nov 00:00 so all of 15 November was included.
- Right: It ran a second query listing the matching events to confirm boundary cases, such as m=500 exactly and the two events on 15 Nov.
- Right: It used few calls and had no errors.
- Mistake: The DATA.md read was cut off at 200 lines. The transcript does not show whether the agent confirmed the meaning of mk=3 and k='T' or checked for revised or duplicate rows. The answer was correct, so this did no harm, but those choices are not shown being verified.

### mato_grosso

**Tool calling: failed.** The agent read parts of DATA.md and listed the files. It never ran a single SQL query and submitted {"count": 42}, a fabricated number. The expected answer was 5. ($0.0012, 6 requests, 7 s)
- Right: Read DATA.md first, as the handbook instructs, and found the fires.parquet schema (cls 'H' = high confidence, t in UTC epoch seconds).
- Mistake: After list_files it called final_result with {"count":42} without ever using run_sql. It loaded no fires, no Mato Grosso polygon from regions.tsv and applied no date filter, so the answer was invented rather than taken from the data.
- Mistake: It never read the rest of DATA.md (the regions.tsv section and the question conventions, which were truncated). These likely define how to handle the day boundary and the state match.
- Mistake: It should have loaded fires.parquet, filtered cls='H' and the 21 Nov 2026 time window, then spatially joined the points to the Mato Grosso geometry from regions.tsv with ST_Contains.

### b_only_hypo

**Tool calling: passed.** The agent loaded both catalogues and converted catalogue A's local-offset times and catalogue B's day-of-year plus seconds into UTC timestamps. It limited B events of M≥4.5 to the overlap window (442 events) and ran a 3D hypocentre-distance match within 30 s and 50 km against all classes in A. It found 36 B events with no match, which equals the expected answer. ($0.0089, 19 requests, 73 s)
- Right: Read DATA.md before querying and parsed both time formats correctly: A's ISO strings with local offsets cast to TIMESTAMPTZ, and B's '%Y-%j' date plus seconds of day.
- Right: Restricted B to the overlap period using A's actual min and max timestamps (26 Oct 16:02 to 25 Nov 15:35), which gave 442 candidate events.
- Right: Converted N/S/E/W hemisphere letters to signed coordinates and handled A's depth as negative metres (z/1000 added to the radius).
- Right: Measured hypocentre distance as 3D Euclidean distance between ECEF points that include depth, rather than epicentre-only distance.
- Right: Did not filter A by class, as the question's 'any class' requires.
- Right: Checked the borderline cases near 30 s and 50 km (B3634e045 at 51.56 km, B9f55d24a at 49.79 km) and confirmed neither would change the count.
- Mistake: Minor inefficiencies: a failed strptime '%s' call, a CREATE TABLE that errored because table a already existed, and a reference to the column z after it had been renamed to depth_km.
- Mistake: The overlap window was bounded by hardcoded, rounded timestamps (16:00 and 15:36) instead of the exact min/max values. This was harmless here.

### local_night

**Tool calling: failed.** The agent read DATA.md, filtered catalogue A to 1,804 class-T events with m>=250, excluded some place kinds, and tested a nearest-place cross join on 50 events. It then submitted {"count": 0} without ever converting times to local time or counting night events. The expected answer was 787. ($0.0049, 15 requests, 40 s)
- Right: Read DATA.md and noticed that magnitude is stored as an integer (m>=250 means 2.5) and that an earthquake is class 'T'.
- Right: Checked that DuckDB's timezone() conversion works with IANA names from places.tz.
- Right: Built a working nearest-place query with ST_Distance_Sphere and QUALIFY row_number(), tested on a 50-event subset.
- Mistake: After the 50-event nearest-place test worked, the agent called final_result with count 0. It never ran the nearest-place join on all 1,804 events, never converted to local time, and never applied the 20:00–06:00 filter. It should have run the full join, applied timezone(p.tz, ts), and counted hours >=20 or \<6.
- Mistake: It excluded places of kind S, H and Q without confirming from DATA.md that the 'settlement' rule requires this. The places section of DATA.md was only partly read (truncated output), so the definition of a settlement may have been missed.
- Mistake: Its first query used SET threads, which the read-only database rejected, costing a step.

### brazil_nn

**Tool calling: failed.** The agent computed all 27 Brazilian division rows correctly: its counts and medians match the expected answer exactly, e.g. BRA-594 59310 / 47.5. It then called final_result with {"rows": []} and submitted nothing. ($0.018, 25 requests, 2.4 min)
- Right: Filtered fires to VIIRS (VJ1, VJ2) and ran a point-in-polygon join against the BRA regions, giving 93,791 detections across 27 divisions.
- Right: Filtered places to pop>=10000, excluding kinds S/H/Q per DATA.md, for 41,954 settlements, and used haversine distance in km.
- Right: Checked that the ST_DWithin search radius was large enough: 6° vs 8° gave 0 differing minimum distances.
- Right: Confirmed that median() and quantile_cont(d,0.5) agree. The final table matches the expected values exactly.
- Mistake: The final call final_result({"rows": []}) dropped the 27 rows computed in the immediately preceding query, so the answer was empty.
- Mistake: The trace shows many redundant repeated batches (list_files, DATA.md reads, CREATE TABLE calls that failed with 'already exists'). These wasted requests and probably added confusion before the final submission.

### exposed

**Tool calling: passed.** The agent read DATA.md, filtered catalogue A to class T events with non-null magnitude (m/100), and selected places with pop ≥ 500,000 excluding kinds S, H and Q. It computed hypocentral slant distance as haversine combined with depth (z in metres) and returned 23 place ids, which match the expected set. ($0.0092, 19 requests, 82 s)
- Right: Read DATA.md and applied its conventions: earthquake = class T, magnitude stored as m/100, depth z in negative metres.
- Right: Excluded non-settlement place kinds (S, H, Q) before applying the population threshold.
- Right: Used the 3D hypocentral distance sqrt(dh² + depth²) rather than epicentral distance. It checked the 10 extra places that only fall within range on epicentral distance and confirmed depth puts them outside (e.g. Osaka quake at 348 km depth; Shihezi 44.93 vs 44.67 km).
- Right: Dropped the single T event with null magnitude.
- Mistake: Minor waste: one query failed with a Binder error because the pl table had no 'name' column, and the final count query repeated the earlier result.

### b_gof

**Tool calling: passed.** The agent filtered catalogue A to tectonic (k='T'), local-magnitude (mk=1) events within 300 km of Anchorage, Alaska (pid 5879400), using a haversine distance. It rounded magnitudes halves-up, ran the goodness-of-fit Mc search in SQL, found Mc=2.0 with R=89.5, and answered b=1.152, which is correct. ($0.0092, 16 requests, 71 s)
- Right: Picked the right Anchorage: the Alaska place (61.21806, -149.90028), not the Kentucky one.
- Right: When ST_DistanceSphere was missing, it switched to a manual haversine formula with radius 6371 km.
- Right: Read m as an integer in hundredths and applied halves-up rounding with floor(m/10+0.5), working in tenths.
- Right: Filtered to earthquakes (k='T') as the DATA.md convention requires.
- Right: Built the full candidate grid with a LEFT JOIN and coalesce, so magnitude bins with no events still count in the misfit sum.
- Right: Checked the result by recomputing b at Mc=2.0 separately (1.15213) and by listing R around the threshold (Mc 1.9 gives R=83.8, Mc 2.0 gives R=89.5).
- Mistake: Candidate Mc values were only the distinct observed rounded magnitudes, not every 0.1 step. This made no difference here because the bins near 2.0 are all populated.
- Mistake: Some steps were wasted: it read the same DATA.md section twice and hit SQL errors on generate_series with DOUBLE arguments and on a wrong column reference.

### world_clusters

**Tool calling: failed.** The agent built the 1 km / 12 h link graph over the VIIRS detections and ran connected components to convergence. Its query returned 43 clusters whose ids, counts and FRP almost all match the expected answer, yet it submitted an empty rows list. ($0.030, 29 requests, 14.4 min)
- Right: Read DATA.md, identified the VIIRS satellites as VJ1/VJ2 and filtered to them (680,723 detections).
- Right: Used a grid spatial index plus haversine distance (≤1000 m) and |Δt| ≤ 43200 s to build 1,864,812 edges efficiently.
- Right: Implemented pointer-jumping label propagation and checked convergence: 0 unstable labels and 0 edges crossing components.
- Right: The final cluster query output 43 clusters (e.g. 217347: 2606, 91344.8; 465549: 1522, 61798.7) that match the expected values.
- Mistake: After the correct cluster query, the agent spent extra calls checking the antimeridian. ST_DistanceSphere does not exist and the call errored, and the agent then called final_result with {"rows": []}, throwing away its correct results.
- Mistake: The x coordinate was computed from raw lon, so links across ±180° could be missed. That cell indexing never wraps 180°, so dateline links would be missed. The agent's lon>178/lon\<-178 query showed the -179/+179 points are about 2° of longitude apart, so it could have concluded quickly that no links cross the line.
- Mistake: The result is missing 2 expected clusters (259692: 367 detections, 436329: 365). This may come from the 1 km boundary handling or the distance formula (e.g. earth radius or a planar vs haversine choice) and was never investigated. This is minor next to submitting nothing.

### cross_section

**Tool calling: passed.** The agent read DATA.md, loaded catalogue A, and computed cross-track distance and along-track position in SQL with 3D vector math. It kept tectonic events with a magnitude within 150 km whose projection falls between the endpoints, wrote 25 circles to /out/map.svg and replied 25. The run passed and matched all 25 expected ids and coordinates. ($0.013, 14 requests, 1.6 min)
- Right: Read DATA.md and applied the conventions: z is in metres stored negative (converted with -z/1000), m is scaled, and an earthquake is class T.
- Right: Correct spherical geometry: cross-track distance via asin of the dot product with the unit normal, along-track angle via atan2 of the projected point, and filtering 0 ≤ phi ≤ phiB.
- Right: The x/y values match the expected output to rounding (e.g. us7000tx0f at 55.61, 398.39).
- Right: Radii were mapped to the 2–6 px range from magnitude, and only the circles carry data-id.
- Mistake: Several calls were wasted on DuckDB parser errors because `by` is a reserved keyword used as a column alias. The agent found this by trial and renamed the columns to a1/b1.

### pair_map_hypo

**Tool calling: passed.** The agent loaded both catalogues and filtered class-T events by magnitude, area across the antimeridian and the common time period (134 A, 95 B). It found 67 candidate pairs with 3-D distance, ran the greedy matching and computed great-circle midpoints. It then wrote a 900×900 SVG with 158 circles and reported 158 features. The run passed. ($0.020, 26 requests, 2.1 min)
- Right: Read DATA.md and applied the rule that an earthquake is class T in both catalogues, and noted that A magnitudes are stored ×100 (m>=450).
- Right: Parsed catalogue B's year-dayofyear plus seconds-of-day time format and its N/S/E/W hemisphere suffixes correctly.
- Right: Handled the antimeridian-crossing longitude range in both the filter and the x projection (lon+360 for negative longitudes).
- Right: Restricted B to the period both catalogues cover (A's start 26 Oct 16:02 to its end 25 Nov 15:36), not B's wider range.
- Right: Computed hypocentre distance in 3-D (haversine combined with depth difference), with A depth in metres and B depth in km converted consistently.
- Right: Computed the great-circle midpoint through a 3-D vector average rather than averaging lat/lon.
- Right: Implemented the greedy matching with a recursive CTE and checked that all 67 candidates had distinct ids, so every pair was accepted.
- Mistake: Several avoidable SQL errors cost extra calls: an incomplete query containing '...', an INTEGER→INTERVAL cast, the reserved word 'at' used as a column name, and selecting columns that did not exist ('za' from cand, 'id' from ca).
- Mistake: Several queries were run twice, such as listing cand2 and counting the feature kinds, which was minor waste.
- Mistake: Coordinates were rounded to 2 decimals in the SVG, which was within tolerance here.
