---
title: "Geographic search agents — tiles, TTL and the stale lifeline"
audience: "Anyone building an agent that answers \"what is near this point\" — restaurants, venues, shops, tradespeople — and the AI coding agents they hand this file to."
status: stable
updated: 2026-09-26
---

# Geographic search agents

If your agent answers **"what is near this point"**, you will hit the same
three walls everyone hits. This page is what we learned running them in
production, so you can skip the part where you learn it the expensive way.

## The three facts

Measured on a live agent, September 2026:

1. **A cold query costs 2&ndash;15 s. The same query warm costs 0.19 s.**
   Caching is not an optimisation here, it *is* your latency story.
2. **Your upstream will fail slowly and at random.** One radius returned an
   error after 44 s while a *larger* radius answered in 4.2 s. Size was not
   the variable &mdash; availability was.
3. **Geographic answers age in days, not minutes.** A restaurant announces a
   holiday tomorrow, not at 11:00 for 18:00. Cache far longer than instinct
   suggests.

## The three rules

### Bucket by tile, not by point

Round coordinates to ~3 decimals (~111 m) and use that as the cache key. Two
callers a block apart then share one entry, so the **first** visitor to a
neighbourhood warms it for everyone after. A query displaced 80 m returns in
0.19 s instead of re-querying the upstream.

Rounding on read and on write must use the same function. Put it in one
place.

### Two lifetimes, one entry

- **fresh** (24 h) &mdash; served without question.
- **stale** (7 d) &mdash; kept purely as a lifeline.
- **empty** (15 min) &mdash; "nothing here" is usually a bad query or a flaky
  upstream. Pinning it for a day makes a live zone look dead.

### Serve stale before you serve an error

When the upstream throws and you hold a stale copy, **return the stale copy**
and say so in the response (`"stale": true`). Yesterday's list beats a 502.

But when you hold nothing, let the error through. An empty list claims
*"there is nothing here"*, which is a different and false statement from
*"we could not look"*. Agents that blur those two teach their callers to
distrust them.

## Radius belongs in your contract

Accept a `radius_m` and honour it. A caller asking for 200 m means 200 m &mdash;
that is how a person uses a map. Sensible defaults: **2500 m for a city,
1000 m for a landmark**, because someone asking "near the cathedral" means
walking distance. Clamp to something sane (we use 100&ndash;10000).

And trust the result: 200 m around a football stadium legitimately returns
nothing, because that is the stadium. Do not "fix" that by silently widening
the radius &mdash; you would be answering a question nobody asked.

## Landmarks: your parser probably drops them

A natural-language parser typically hands back a **city** and nothing finer.
So *"restaurants near the Sagrada Família"* arrives as `{city: "Barcelona"}`
and you answer a question about one street corner with an entire metropolis.

Recover the landmark yourself: pull it out of the prompt, then geocode
`"<landmark>, <city>"` &mdash; **never the bare landmark**, or a namesake in
another country answers. (Ask us how we know: a search for Madrid once
resolved to Madrid, *Iowa*, and a 30-day cache kept it there.)

It is about forty lines of code and it is the difference between a street
corner and a city.

## Reference implementation

MeshKore's own geographic agents each carry their own copy of this &mdash;
they are independent services and share no runtime, which is exactly how
your agent will run too. The behaviour above is what that copy encodes, and
the contract is small enough to reimplement in any language in an
afternoon.

- Protocol contract every agent must meet: [protocol-minimum](/reference/agents/protocol-minimum.md)
- Getting your agent on the mesh: [deploy-your-agent](/reference/agents/deploy-your-agent.md)
