Skip to contentAPILayer: production APIs with free plansExplore APILayer
Cover illustration: 48 AI Agents Rediscovered a Maya Site That Was Already Published. Build the Search They Needed
Favour Onuoha

Posted on · 7 min read

48 AI Agents Rediscovered a Maya Site That Was Already Published. Build the Search They Needed

On this page · 12 sections

In October 2026, Pietro Miotti pointed 48 AI agents at about 1,200 km² of public NASA lidar over the Maya region. The agents looked at the images, flagged a settlement that didn't seem to be registered, and helped him write a report to INAH, Mexico's archaeology institute. INAH checked its records and found no registered site at that location.

His write-up, My AI Agents (Re)discovered a Maya Site in 72 Hours, passed 1,000 points on Hacker News last week. The "(Re)" is there because of an update he added on November 11: the site had already been covered in a 2025 paper. In his words:

The agents missed it while going through the literature, so they rediscovered it rather than discovered it

We think that update is the most useful part of the post for anyone building agents. The image analysis worked. The step that failed was the boring one: checking whether somebody had already published it.

So we tested how hard that paper is to find, and built the tool we'd give an agent for that step. It's a search_prior_work tool in JavaScript on the Zenserp API, which returns Google results as JSON. Everything below ran on November 16, 2026.

One thing to be clear about first. We don't know which queries his agents ran, or where the site is (he kept the coordinates in a confidential annex). We only tested how findable the paper is from different starting points.

#What is the Zenserp API?

Zenserp runs a Google search for you and returns the results page as JSON. The organic array has each result's position, title, URL and snippet, and there are parameters for country, language, result count and paging.

For an agent, that means no headless browser, no consent screens and no HTML to parse. You send a query and get back something a model can read.

The account has a status endpoint that tells you how many searches you have left. Ours said 48 when we started, so we planned the whole test around a small number of queries.

The same results can drive a rank tracker, a brand monitor, or a research assistant that cites its sources.

One request, with the key in a header:

Bash
curl -G "https://app.zenserp.com/api/v2/search" \
  -H "apikey: YOUR_KEY" \
  --data-urlencode "q=NASA G-LiHT lidar Maya lowlands settlement mapping"

Here are the first three results that came back, with the long redirect URL shortened:

JSON
{
  "organic": [
    {
      "position": 1,
      "title": "Evaluating Broadscale Deep Learning for Maya Settlement ...",
      "url": "https://link.springer.com/article/10.1007/s10816-025-09741-5",
      "destination": "https://link.springer.com › article",
      "description": "Lidar data is an efficient way to detect ancient Maya features across the Yucatan Peninsula. G-LiHT Lidar (approximately 35,584 km2). NASA ..."
    },
    {
      "position": 2,
      "title": "New regional-scale Classic Maya population density ...",
      "url": "https://www.sciencedirect.com/science/article/pii/S2352409X25003219",
      "destination": "https://www.sciencedirect.com › science › article › pii",
      "description": "airborne lidar mapping provides extensive and fine-grained data to document ancient Maya settlement on a previously unattainable scale. NASA's Goddard LiDAR, ..."
    },
    {
      "position": 3,
      "title": "G-LiHT\" and Other Lidar Data a Closer Look at Classic ...",
      "url": "https://www.google.com/goto?url=CAESvgEBxCJF10Ck...&gsessionid=yQ3-Fc7d...",
      "destination": "https://stonecenter.tulane.edu › events › middle-american...",
      "description": "Middle American Research Institute Brown Bag Talk Series ..."
    }
  ]
}

Result 2 is the paper from Miotti's update: Estrada-Belli et al., 2025, in the Journal of Archaeological Science: Reports (doi:10.1016/j.jasrep.2025.105288).

Titles and snippets are cut off with "..." the way Google shows them. And look at result 3's URL. That's the first quirk.

#Most Result URLs Were Google Redirects

We ran four queries and got 35 results. In 26 of them, url wasn't the page's address. It was a https://www.google.com/goto?url=... redirect with an opaque token.

That matters more for an agent than for a person. A model that's asked to cite its sources will paste that redirect into its answer. It can't tell a journal from a Facebook group by looking at it, and the link carries a session ID that we wouldn't expect to keep working.

The redirect does resolve. A request to it answers HTTP 302 with the real address in the Location header, so our tool makes that one request per result and keeps the destination. (The destination field gives you the host as a breadcrumb, which is enough if you only need to classify the result.)

#The Query Decided Whether the Paper Showed Up

These are the four queries and where the 2025 paper ranked.

"unregistered Maya archaeological site found with lidar" is how you'd describe the finding. It returned 8 results and the paper wasn't one of them. Result 1 was an Instagram reel. The rest were news and blog posts about other lidar discoveries, plus a YouTube Short.

"Maya settlement lidar survey Campeche published sites" did better. It returned real journal articles, from Antiquity and PLOS One. The 2025 paper still wasn't there.

"NASA G-LiHT lidar Maya lowlands settlement mapping" names the dataset. (Miotti's post says the lidar was NASA's but doesn't name it. G-LiHT is NASA Goddard's airborne lidar, and the results above mention it.) The paper was result 2.

"Maya lidar settlement survey 2025 journal article" names the kind of publication. The paper was result 1.

So describing the discovery found news about discoveries. Describing the data, or the kind of document that would report it, found the document. An agent that searches once, in the words of its own finding, gets back excitement and no literature.

#The Same Query Gave Different Results the Second Time

We ran the first query again while testing the tool. This time it returned 5 results, not 8, and one of them was a Nature paper that hadn't been there before.

Then we ran the two queries that had found the 2025 paper. Neither returned it the second time.

Google's results move, and a search API passes that on to you. For an agent, the rule that follows is simple: finding a paper proves it exists, and not finding one proves nothing. Our tool says that in its output, in words the model will read.

We also asked for num=20 on every query and got 8 or 9 results back each time. Use paging (start) if you need depth, and don't assume the count you asked for.

#The Tool

Bash
npm install @anthropic-ai/sdk zod
JavaScript
// prior-work.mjs: a "has someone already published this?" search for AI agents (Zenserp).
import { betaZodTool } from "@anthropic-ai/sdk/helpers/beta/zod";
import { z } from "zod";

const SOCIAL = /(instagram|youtube|facebook|tiktok|reddit|x|twitter)\.com$/;
const PAPERS = /(sciencedirect\.com|springer\.com|cambridge\.org|plos\.org|wiley\.com|tandfonline\.com|jstor\.org|nature\.com|harvard\.edu|arxiv\.org|doi\.org|researchgate\.net|academia\.edu)$/;

// Many results carry a google.com/goto redirect instead of the page's address. One request resolves it.
async function realUrl(url) {
  if (!url.startsWith("https://www.google.com/goto")) return url;
  const res = await fetch(url, { redirect: "manual", headers: { "user-agent": "Mozilla/5.0" } });
  return res.headers.get("location") ?? null;
}

async function search(q, attempt = 1) {
  const url = new URL("https://app.zenserp.com/api/v2/search");
  url.searchParams.set("q", q);
  const res = await fetch(url, { headers: { apikey: process.env.ZENSERP_API_KEY } });
  // We got a 502 Bad Gateway on the second query of a batch. One retry after a pause cleared it.
  if (res.status >= 500 && attempt < 3) {
    await new Promise((r) => setTimeout(r, 1500 * attempt));
    return search(q, attempt + 1);
  }
  const body = await res.json().catch(() => ({}));
  if (!res.ok || body.error) throw new Error(`zenserp ${res.status}: ${body.error ?? res.statusText}`);
  return body.organic ?? [];
}

export async function priorWork(queries) {
  const seen = new Map();
  for (const q of queries) {
    for (const r of await search(q)) {
      if (!r.url || !r.title) continue; // image and video packs have neither
      const url = await realUrl(r.url);
      if (!url || seen.has(url)) continue;
      const host = new URL(url).hostname.replace(/^www\./, "");
      if (host.endsWith("gstatic.com")) continue; // one result's url was a favicon image
      const kind = PAPERS.test(host) ? "paper" : SOCIAL.test(host) ? "social" : "web";
      seen.set(url, { kind, title: r.title, url, snippet: r.description, found_by: q });
    }
  }
  const results = [...seen.values()].sort((a, b) => (b.kind === "paper") - (a.kind === "paper"));
  const count = (k) => results.filter((r) => r.kind === k).length;
  return {
    queries,
    papers: count("paper"), web: count("web"), social: count("social"),
    // Zero papers means "search again with different words", not "nobody has published this".
    verdict: count("paper") ? "published work found: read it before claiming anything new" : "no papers found: inconclusive",
    results,
  };
}

export const searchPriorWork = betaZodTool({
  name: "search_prior_work",
  description:
    "Search the web for existing publications before claiming something is new, unregistered or undiscovered. Pass 2 to 5 queries that come at the finding from different sides: what was found, the dataset or method used, and the kind of publication that would report it. A result with zero papers is inconclusive, not proof of novelty.",
  inputSchema: z.object({ queries: z.array(z.string()).min(2).max(5) }),
  run: async ({ queries }) => JSON.stringify(await priorWork(queries)),
});

The input is a list of queries, not one. That's the lesson from the ranking test built into the schema: the model has to come at the finding from more than one side.

Each result gets a kind. The PAPERS list is ours and it's short. Add the publishers and preprint servers for your field. Results are sorted with papers first, so they survive if you trim the output to save tokens.

The two guards came from things that went wrong. The 502 arrived on the second query of a three-query batch and killed the whole run, so search now retries. And one Instagram result came back with a gstatic.com favicon image as its url, which the tool drops.

#What the Tool Returned

We called priorWork directly with three of the queries from the ranking test: the finding, the dataset and the publication type. It took 25.6 seconds, which includes resolving every redirect one at a time. The summary:

JSON
{"papers":3,"web":6,"social":0,"verdict":"published work found: read it before claiming anything new"}

The three papers, as the tool returned them (snippets cut):

JSON
[
  {"kind":"paper","title":"Evaluating Broadscale Deep Learning for Maya Settlement ...","url":"https://link.springer.com/article/10.1007/s10816-025-09741-5","found_by":"NASA G-LiHT lidar Maya lowlands settlement mapping"},
  {"kind":"paper","title":"New regional-scale Classic Maya population density ...","url":"https://www.sciencedirect.com/science/article/pii/S2352409X25003219","found_by":"NASA G-LiHT lidar Maya lowlands settlement mapping"},
  {"kind":"paper","title":"Lidar survey of ancient Maya settlement in the Puuc region of ...","url":"https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0249314","found_by":"Maya lidar settlement survey 2025 journal article"}
]

The second one is the 2025 paper, and found_by shows it was the dataset query that surfaced it. The query that described the finding contributed four news and blog results and no papers.

Then we called it through the tool's run() with the dataset and publication queries only. That took 9.4 seconds and returned 2 papers, 5 web results and 1 social result. The 2025 paper wasn't among them. That's the run we described above, and it's why the verdict never says "nothing found, you're clear".

#Running It in an Agent

The SDK's tool runner handles the loop:

JavaScript
// agent.mjs
import Anthropic from "@anthropic-ai/sdk";
import { searchPriorWork } from "./prior-work.mjs";

const client = new Anthropic(); // reads ANTHROPIC_API_KEY

const message = await client.beta.messages.toolRunner({
  model: "claude-haiku-5-5",
  max_tokens: 4096,
  system:
    "Before you describe any finding as new, unregistered or undiscovered, call search_prior_work with queries about the finding, the dataset or method, and the type of publication that would report it. Cite the URLs it returns. If it finds no papers, say the check was inconclusive and name what a human should verify.",
  tools: [searchPriorWork],
  messages: [{ role: "user", content: process.argv.slice(2).join(" ") }],
});
console.log(message.content.filter((b) => b.type === "text").map((b) => b.text).join(""));

The system prompt does the same job as the tool description, from the other side. It tells the model when the check is required and what it's allowed to conclude from an empty result.

#How to Stay Inside the Search Quota

Every query is one search, and a prior-work check uses up to five. Cache each query's results on your server for a day. An agent that loops will ask the same thing again, and yesterday's search results are fine for a literature check.

Check the status endpoint before a batch:

Bash
curl "https://app.zenserp.com/api/v2/status" -H "apikey: YOUR_KEY"
JSON
{"remaining_requests":35}

If the number is lower than the batch needs, stop and tell the user. A check that ran two of five queries looks like a finished check in the output.

Resolving redirects costs time, not quota. If 25 seconds is too slow, resolve them in parallel with Promise.all, or skip the request and classify by the destination field.

#How to Vibe Code the Tool

Ask an AI assistant for "a web search tool for my agent" and you'll get one query in, raw results out. The redirect handling and the wording of the verdict have to be in the prompt:

Write prior-work.mjs exporting priorWork(queries) and searchPriorWork, a betaZodTool from
"@anthropic-ai/sdk/helpers/beta/zod" with zod input { queries: string[] (2 to 5) }. For each
query call https://app.zenserp.com/api/v2/search?q=... with the header apikey from
ZENSERP_API_KEY and read body.organic. Retry up to twice on a 5xx with a pause. Skip results
with no url or title. If a url starts with https://www.google.com/goto, request it with
redirect: "manual" and use the Location header. Drop gstatic.com urls. Dedupe by url across
queries. Label each result kind "paper", "social" or "web" from its hostname, sort papers
first, and record found_by (the query). Return {queries, papers, web, social, verdict, results}.
When papers is 0 the verdict must say "inconclusive", never that nothing exists.

Then check it by hand. Search for a paper you know exists, by DOI, and make sure it comes back as kind: "paper" with a real publisher URL and no google.com in it. Search for something obscure and read the verdict. If it says anything like "no prior work", fix the wording before a model reads it and repeats it.

#Things to Sort Out Before You Launch

Decide what counts as a paper in your field. Our host list is tuned to this one example. Patents, preprints, government registers and conference sites all need adding if your agent works in those areas.

A snippet isn't the paper. The tool tells the agent that something relevant exists and where. To know whether a site, a compound or an idea is actually covered, something has to open the document and read it. In the Maya case the paper is a regional survey, and none of the snippets we got back mentioned a single site by name.

And keep the human step. INAH's reply said there was no registered site at that location, which was true, and the paper still existed. Two checks agreed and the conclusion was still wrong for three weeks. Have your agent report what it searched for, so the person reading can see what wasn't checked.

#Wrapping Up

The tool does three things a single search doesn't: it asks from several sides, it tells papers from noise, and it refuses to treat an empty result as an answer. You can get a key at zenserp.com, and it's one of the APIs from APILayer.

Happy building.