---
title: "GLM 5.3 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/glm-5.3/geo_analyst/
---

# GLM 5.3 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/glm-5.3/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/glm-5.3.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 90%   | 9 of 10      | $2.88 | 220      | 281        | 49.5 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**: 9/10 with tool calling and 10/10 in code mode. The only failure was `pair_map_hypo` in tools mode. There the analysis was correct, but the run timed out before writing the required SVG. Every run read DATA.md before querying and applied its encoding conventions:

- magnitudes stored as integer hundredths
- depth `z` in negative metres
- class `T` meaning earthquake
- place kinds S/H/Q excluded as non-settlements

#### Where it does well

- **Geospatial correctness:** It computed true 3D hypocentral distances (`exposed`, `b_only_hypo`, `pair_map_hypo`). It handled the antimeridian with lon wrapping and great-circle along-track bounds (`cross_section` excluded far-side and beyond-endpoint events).
- **Numeric edge cases:**
  - In `b_gof` it caught that DuckDB's `//` truncates negative values toward zero (-139//10 = -13).
  - In `world_clusters` it caught that float `round` gives 30720.5 for 30720.55 and switched to exact half-up rounding.
  - It tested how `median()` handles even counts (`brazil_nn`).
- **Heavy verification:** It used brute-force cross-checks (40605 vs 40605 edges in `world_clusters`, a 300-fire sample in `brazil_nn`) and independent second methods (SQL vs Python, haversine vs spheroid). It also inspected events near each threshold boundary.
- **Disambiguation:** It chose the right Anchorage and Mato Grosso (BRA-602 rather than BRA-600). In code mode it confirmed Anchorage with a point-in-polygon test.

#### Mistakes it makes

- **Many wasted calls on small errors:** reserved-word aliases (`by`), out-of-scope columns, binder and type errors, and multi-statement SQL that silently failed. In code mode there were also sandbox quirks (missing imports, `next()` on lists). These almost never affected answers, but they inflated request counts.
- **Unverified assumptions near day boundaries:** In `mato_grosso` (both modes), all 5 detections were at 00:39 UTC, and the UTC-day convention was assumed without checking. In `local_night` (tools), a Recife/Noronha near-tie that could flip one event was never resolved. Overlap windows in `b_only_hypo` were hand-typed rather than taken from the data.
- **Poor prioritisation:** In `pair_map_hypo` (tools), it spent more than 15 calls building a decorative coastline background instead of first writing the 158 required circles. It timed out at 1200 s with no output. The notes label the cause "ran_out_of_requests".
- **Occasional no-op checks:** for example, the impossible `z >= -70000 AND z < -75000` condition in `deep_moment`.

#### Tool calling compared with code mode

| Mode      | Passed | Requests | Cost  |
| --------- | ------ | -------- | ----- |
| tools     | 9/10   | 220      | $2.88 |
| code_mode | 10/10  | 209      | $3.30 |

Excluding `pair_map_hypo`, tools used 175 requests and cost $2.01, while code mode used 185 requests and cost $2.66. Neither mode is consistently cheaper:

- **Code mode was cheaper** on `cross_section` (8 vs 26 requests), `b_gof`, `b_only_hypo` and `deep_moment`.
- **Tools were cheaper** on `world_clusters` (27 vs 47 requests), `brazil_nn`, `exposed` and `local_night`.

Code mode's decisive advantage was `pair_map_hypo`. It also wasted calls on the coastline, but it wrote and validated the SVG and passed in 24 requests ($0.64). Tools mode spent 45 requests ($0.87) on the same case and failed. Code mode also tended toward fuller independent re-derivations, such as Python reimplementations and Decimal checks.

## Runs

### deep_moment

**Tool calling: passed.** The agent loaded catalogue A, filtered for 1–15 November UTC, mk=3 (moment magnitude), m>=500 (hundredths), z\<-70000 (metres, negative below sea level) and class T, and got 7. That matches the expected answer. ($0.035, 10 requests, 48 s)
- Right: Read DATA.md and used the codes correctly: mk=3 for moment magnitude and class 'T' for earthquakes.
- Right: Checked the raw JSON and saw that times carry local offsets. Confirmed the session timezone was UTC so the date window was applied in UTC.
- Right: Worked out the units from the data: magnitude stored as hundredths (m>=500) and depth in metres, negative downward (z\<-70000).
- Right: Listed the 7 events and checked the events just outside the date window. Ran the count with and without the class filter, and both gave 7.
- Mistake: The final check query used `z >= -70000 AND z < -75000`, which can never be true, so it checked nothing. It did not change the answer.
- Mistake: The half-skimmed DATA.md was not read in full at first (it was truncated). The agent re-read it from line 50, but the middle section on fields and units may have been skipped and the units inferred instead. It turned out fine.

### mato_grosso

**Tool calling: passed.** The agent read DATA.md, found the Mato Grosso polygon (BRA-602) in regions.tsv, and counted fires with cls='H' on 21 Nov 2026 UTC inside it, getting 5. That matches the expected answer. ($0.025, 9 requests, 36 s)
- Right: Read DATA.md before querying.
- Right: Picked the right region, BRA-602 'Mato Grosso', over BRA-600 'Mato Grosso do Sul' after a LIKE search returned both.
- Right: Fixed the ST_Contains binder error by casting the point to GEOMETRY.
- Right: Listed the 5 detections and confirmed they fall in Mato Grosso and not Mato Grosso do Sul.
- Mistake: Parts of DATA.md were truncated, including the fire column details and the day convention. The agent assumed cls='H' means high confidence and that the day is the UTC day without checking. The answer was correct, but all 5 detections were at 00:39 UTC, so if a local-time convention applied they would fall on 20 November in local time. That assumption was risky and never checked.

### b_only_hypo

**Tool calling: passed.** The agent parsed both catalogues and converted times to UTC epoch ms (it handled the per-event offsets in A and the year/day-of-year format in B). It restricted B to the overlap window and to magnitude 4.5 or more, which gave 442 events. It then matched each against A within 30 s and within 50 km of 3D hypocentral distance, found 406 matched, and answered 36, which is correct. ($0.23, 24 requests, 4.9 min)
- Right: Read DATA.md first and checked the formats of both files before loading.
- Right: Converted A's ISO times with offsets and B's day-of-year plus seconds into a common UTC epoch, and recovered from the INT32 overflow by casting to BIGINT.
- Right: Limited B to the period both catalogues cover (from the start of A at 2026-10-26 16:02 UTC) instead of using all 839 B events.
- Right: Used 3D hypocentral distance (epicentral distance combined with depth difference) and allowed A events of any class.
- Right: Did sensitivity checks: events near the 30 s and 50 km boundaries, haversine against WGS84 spheroid distances (406 matched both ways), duplicate ids, nulls, and events at exactly magnitude 4.5.
- Mistake: Several wasted or broken queries: a placeholder query containing '?', a reference to a nonexistent raw7 column, a dummy subquery with a type error, and ST_Point/ST_Distance_Spheroid signature errors. None affected the result.
- Mistake: Set the overlap window with hand-typed bounds ('2026-10-26 16:00:00' to '2026-11-25 15:36:00') rather than taking them from the data. This was harmless here because no B event fell near the start boundary.

### local_night

**Tool calling: passed.** The agent filtered catalogue A to tectonic events (k='T') with m>=250, i.e. magnitude 2.5 or more in hundredths (1804 events). It found the nearest settlement for each, excluding kinds S, H and Q, using a haversine search with a latitude window plus a full cross-join fallback for far events. It converted each UTC instant to that settlement's IANA time zone and counted local hours >=20 or \<6, getting 787, which matches the expected answer. ($0.21, 30 requests, 4.9 min)
- Right: Read DATA.md and applied its conventions: magnitude stored as integer hundredths (m>=250), earthquake meaning class T, settlement meaning kind not in S/H/Q.
- Right: Parsed the timestamps, which carry offsets, as TIMESTAMPTZ instants and converted them with timezone(tz, tt) rather than trusting the embedded offsets.
- Right: Handled the windowed nearest-neighbour search correctly: it kept only results below 555.97 km (the guaranteed-correct radius for a 5° latitude band) and ran a full cross join for the remaining 203 events.
- Right: Checked that every IANA zone was valid, looked at events near the 06:00 and 20:00 boundaries, and inspected near-ties such as Dutch Harbor vs Unalaska (same zone) and the Noronha/Recife case.
- Mistake: A few wasted calls came from binder errors: calling regexp_extract on a TIMESTAMPTZ column, then referencing column t after building the table without it.
- Mistake: The tie analysis turned up us7000tx69, whose nearest settlement is in America/Recife while a nearly equidistant one is in America/Noronha. The two zones give local times of 19:39 and 20:39, so the night count depends on which is nearer. The agent queried both but never stated a resolution; the answer happened to come out correct.

### brazil_nn

**Tool calling: passed.** The agent filtered VIIRS fires (VJ1/VJ2), assigned them to the 27 Brazilian states by point-in-polygon, and found the nearest settlement with population of 10,000 or more using a 2-degree grid join plus a full-scan fallback for fires whose grid result exceeded 360 km. It reported counts and median distances that match the expected answer. ($0.12, 16 requests, 3.7 min)
- Right: Read DATA.md first and applied its conventions: VIIRS = sat VJ1/VJ2, and settlement kinds S/H/Q were excluded.
- Right: Ran a bbox-prefiltered ST_Contains join and later confirmed no fire fell in two states (93791 pairs = 93791 distinct fids).
- Right: Computed haversine distances on a 2-degree grid with a ±2-cell neighbourhood, then redid the 66 fires with d0 > 360 km against all settlements, so their nearest-settlement distances are exact.
- Right: Checked that DuckDB's median averages the two middle values for an even count (got 2.5 for 1–4) before relying on it.
- Right: Searched settlements in all countries, as the question requires.
- Mistake: The first verification query failed with a parser error because the CTE alias `v` was reused as `FROM v v`. It cost one extra call.
- Mistake: The 360 km verification threshold is a conservative bound that worked here, but the agent never stated why it is safe. A 2-cell margin of 2 degrees is about 222 km in latitude and less in longitude, so a tighter justification would have been better.
- Mistake: The verification table came out identical to the grid result (same 387.06 km max), so the full-scan fallback was redundant this time.

### exposed

**Tool calling: passed.** The agent loaded catalogue A and places, filtered to tectonic events with a magnitude and to settlements (kind not S/H/Q) with pop ≥ 500,000. It then computed straight-line hypocentre distances that include depth and returned the 23 place ids that match the expected answer. ($0.12, 13 requests, 3.3 min)
- Right: Read DATA.md and applied its conventions: earthquakes are class T, magnitude is stored as m/100, z is in metres (negative is down), and settlements exclude kinds S/H/Q.
- Right: Used a true 3D hypocentre distance (chord from the surface point to the point at depth) rather than the epicentral arc.
- Right: Cross-checked the dot-product distances against a haversine-based computation and got identical values.
- Right: Checked that non-T events would add no extra pairs, and deduplicated places hit by more than one quake (24 pairs, 23 places).
- Mistake: Two cross-check queries failed: one with a parenthesis syntax error and one referencing q.lat, a column the precomputed table does not have. Both needed retries, which cost a few extra calls but did no harm.
- Mistake: Nothing in the transcript shows how the 'S','H','Q' kind exclusion was derived from DATA.md (that part of the output was truncated). The filter is plausible, and the result matched.

### b_gof

**Tool calling: passed.** The agent picked Anchorage, Alaska (pid 5879400) and filtered catalogue A to tectonic events (k='T') with mk=1 within 300 km by haversine. It rounded the magnitudes (stored as integers in hundredths) halves up with floor((m+5)/10), ran the goodness-of-fit scan in SQL, found Mc=2.0 (N=616, R=89.52) and answered b=1.152, which is correct. ($0.16, 20 requests, 4.1 min)
- Right: Read DATA.md, picked up that magnitudes are stored as integer hundredths and that 'earthquake' means class T, and filtered on k='T' (1613 of 1732 events).
- Right: Chose the Alaska Anchorage record (A2, pop 289600) over the Kentucky one.
- Right: Spotted that DuckDB's integer // truncates toward zero for negative values (it tested -139//10 = -13) and switched to floor() so halves round up for negative magnitudes.
- Right: Computed b, a, predicted counts and R exactly as the formulas in the question specify, over every candidate Mc.
- Right: Checked for boundary events near 300 km and confirmed the result with alternative rounding (rmB) and a sensitivity check that included all event classes.
- Mistake: The first ev table used integer // rounding, which is wrong for negative magnitudes. This was caught and fixed before any result depended on it.
- Mistake: A CREATE TABLE collided with an existing table, costing one extra call. A few further verification queries were redundant but did no harm.

### world_clusters

**Tool calling: passed.** The agent filtered to VIIRS (VJ1/VJ2) detections and built spatio-temporal link edges with a grid/time-bucket join plus a haversine check of 1 km or less and a time gap of 43200 s or less. It found connected components with iterative min-label propagation in SQL and reported the 45 clusters of 300 or more detections with counts and FRP converted to MW using half-up rounding. All 45 matched the expected answer and the run passed. ($0.78, 27 requests, 62 s)
- Right: Read DATA.md, identified VJ1/VJ2 as the VIIRS satellites, and checked that fid is unique and that no field is null.
- Right: Built an efficient candidate join on a lat grid and 12 h time buckets, padding the lon window by cos(lat), so the edge count stayed manageable (1,874,135 edges).
- Right: Checked the largest cluster's edges against a brute-force pairwise join in its region (40605 vs 40605, 0 missing, 0 extra) and confirmed its 2606 members with a recursive BFS.
- Right: Confirmed label propagation converged: 0 edges cross labels and no labels are left unflattened.
- Right: Spotted the exact-.x5 rounding ties in the sums, found that DuckDB's double round gave 30720.5 for 30720.55, and switched to exact integer half-up rounding (30720.6).
- Right: Checked cluster sizes near the 300 cutoff (299 is excluded, 301 is included) to make sure the threshold was applied correctly.
- Mistake: The round 2–4 batch failed on a typo (duplicate alias x in the round 4 j2 statement), so one call was wasted, though the earlier statements in that batch had already run.
- Mistake: A stray test query using a nonexistent column frp_dw was wasted effort.
- Mistake: The convergence loop was unrolled by hand into multiple batches instead of looping until no cross-label edges remained. This was a minor inefficiency.

### cross_section

**Tool calling: passed.** The agent computed great-circle cross-track and along-track distances in DuckDB with a 3-D vector method, filtered catalogue A to class T events with a magnitude, within 150 km of the circle and with along-track between 0 and L. It found 25 events and wrote an SVG whose ids and coordinates match the expected answer exactly. The run passed. ($0.33, 26 requests, 6.2 min)
- Right: Read DATA.md and applied the rule that an earthquake is class T, and checked that this did not change the result (all 25 were T).
- Right: Correctly converted z (negative metres) into depth in km and scaled it with y = depth × 500/700.
- Right: Treated the great circle as a full circle and enforced 0 ≤ s ≤ L, which excluded the far-side Oklahoma/California events and the five events beyond the NE end point (e.g. us7000ttnt, 7.8 km off the circle).
- Right: Cross-checked the result with a second, independent method (cross-track/along-track bearing formulas); the two agreed to 6 decimals.
- Right: Checked borderline events near the 150 km cutoff and near the end points.
- Right: The SVG meets the spec: width/height attributes, circle radii within 2.5–5.5, data-id only on the circles.
- Mistake: Several SQL errors cost extra calls: `by` used as an alias (a reserved word), radius_km not carried through CTEs, and the column m referenced after it had been renamed to mag.
- Mistake: Tried to read /out/map.svg back with read_text, which only allows /data, so this was a wasted call (minor).

### pair_map_hypo

**Tool calling: error.** The agent loaded both catalogues, filtered events by region and magnitude, built candidate pairs and ran the greedy one-to-one matching. It got 67 pairs, 67 unmatched A events and 24 unmatched B events of M≥4.5, 158 features in all, which matches the expected 158 points. It then spent the remaining time turning coastline polygons into SVG path strings by hand and timed out at 1200 s without writing /out/map.svg. ($0.87, 45 requests, 20.0 min)
- Right: Read DATA.md and parsed catalogue B's year-day dates, N/S/E/W hemisphere suffixes and scaled magnitudes correctly.
- Right: Restricted B to the period both catalogues cover and handled the area crossing the dateline with lon 160..180 OR -180..-170.
- Right: Computed hypocentre distance with 3D Cartesian coordinates that include depth, and ran the greedy matching through a recursive CTE ordered by |dt|, distance, aid, bid.
- Right: Computed great-circle midpoints with the vector-sum method and shifted longitudes below 160 by +360 for the x coordinate; the feature count of 158 (67+67+24) and coordinates such as us6000uc4v (337.0, 441.0) agree with the expected answer.
- Right: Used the 30 px per degree scaling: 30° spans 900 px both across and down.
- Mistake: After the features table was ready (the feature count query), the agent never wrote the SVG. Writing circles alone would have met the requirements, but it went off to build a decorative coastline background instead.
- Mistake: It spent more than 15 calls on country polygon rendering: ST_Union aggregation errors, ST_GeometryN not existing, ST_Dump struct handling, ST_PointN type casts, and then paging path strings out in 200-character chunks. This used up the 1200 s budget.
- Mistake: At the end it ran a dateline midpoint check that returned nothing and still had not produced the file. It should have written /out/map.svg with the 158 circles first and added any background afterwards.
