cd /news/ai-agents/your-ai-agent-should-never-get-an-em… · home › topics › ai-agents › article
[ARTICLE · art-171445] src=nestdaddy.com ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Your AI agent should never get an empty search result: three fixes we shipped

NestDaddy shipped three fixes to its news search API after a developer's Chinese-language queries to a LangChain-connected news agent returned empty result lists despite HTTP 200 responses. The fixes add overlapping two-character bigram indexing for Chinese and Japanese, a five-step match ladder (exact, partial, older, live, related) reported in a new `match` field instead of returning empty lists, and direct answers for single-answer questions; partial matches now must contain the rarest query word present in the archive, after an early version answered "BYD October sales" with an article about US retail sales. The company said an empty list is "close to the worst possible answer" for an agent because the model either reports nothing found or fills the gap from memory.

key takeaway

Index Chinese and Japanese text as overlapping two-character bigrams and split queries the same way, and replace empty results with a match ladder whose partial step must include the rarest query word in the archive.

read7 min views4 publishedNov 18, 2026
Your AI agent should never get an empty search result: three fixes we shipped
Image: Nestdaddy (auto-discovered)

A developer built a news agent on our API, asked in Chinese and got nothing back. Here is why search APIs return empty lists to AI agents, the three fixes we shipped (word splitting for Chinese and Japanese, a match ladder instead of empty results, direct answers for questions with one right answer), and how to use them in your agent.

Yesterday a developer signed up for NestDaddy, connected it to a news agent through our LangChain integration and started asking questions. Some were in English, some in Chinese: AI model launches, monthly car sales, events at a theme park.

Every call succeeded. HTTP 200, fast, valid JSON. And several of them came back with an empty list.

For an AI agent, an empty list is close to the worst possible answer. The model has nothing to ground on, so it either says "I could not find anything" or fills the gap from memory. The developer tried a few more queries, then stopped. We would have stopped too.

So today we fixed it. This post explains the three causes we found, what we changed, and how to use the new fields in your own agent.

Press Run to call the API.

Get your free API key

Cause 1: Chinese and Japanese have no spaces #

Our news archive uses a standard full-text index. It splits text into words at spaces and punctuation, which works for English, Malay, Indonesian, Spanish and most languages that use spaces between words.

Chinese and Japanese do not. Here is what a word-based index sees for a Chinese headline about BYD's October sales:

比亚迪10月销量创新高   ->   one "word": '比亚迪10月销量创新高'

A search for 比亚迪 销量 ("BYD sales") looks for the words 比亚迪 and 销量. The index has neither, only that one long token. No match, ever, however many relevant articles are stored.

The fix: for Chinese and Japanese text we also index overlapping two-character pieces (bigrams), and split the query the same way:

比亚迪 销量   ->   比亚  亚迪  销量

Now the query and the headline share pieces, and the match works like it does for spaced languages. The same query today:

{"title": "10月厂商销量:比亚迪破25万!特斯拉4年来首次未过万!", "source_domain": "chejiahao.autohome.com.cn", "match": "exact"}
{"title": "10月澳洲市场:比亚迪销量再破万,经销商协会坐不住了", "source_domain": "k.sina.com.cn", "match": "exact"}
{"title": "2026年上半年自主五强销量排行:比亚迪断层领先", "source_domain": "chejiahao.autohome.com.cn", "match": "exact"}

We also added more Chinese-language news sources, so there is more to find.

Cause 2: "no exact match" was treated as "nothing" #

Most search APIs, ours included until today, return an empty list when no document matches every word of the query. That is a reasonable rule for a search box, where a person can rephrase. It is a bad rule for an agent, which often sends long, specific queries like Universal Beijing Resort Christmas event.

The fix: news search now walks down a ladder and stops at the first step that finds something. Every result says which step found it, in a new match field:

match What it means
exact every word of the query matches, within the days you asked for
partial most of the important words match, always including the most specific one
older exact or partial, but older than the days you asked for
live fetched live for this query because the archive had nothing yet
related the newest articles sharing any important word; context, not an answer

The "most specific word" rule matters. Our first version of partial answered BYD October sales with an article about US retail sales in October: two words out of three, all of them the wrong ones. Now a partial match must contain the rarest word in the query that exists in the archive, which here is BYD.

Here is that long theme park query today:

{
  "match": "partial",
  "count": 2,
  "results": [
    {"title": "Winter Holiday to Return in Splendor to Universal Beijing Resort from November 20",
     "source_domain": "english.beijing.gov.cn", "match": "partial"},
    {"title": "Universal Beijing Resort Guide: What's New in 2026 and the Year's Events",
     "source_domain": "hauntedattractionnetwork.com", "match": "partial"}
  ]
}

The first result is the winter season announcement a person asking that question wants, even though no headline contains the word "Christmas".

And when the archive has nothing at all, the live step looks the query up in real time, returns what it finds and keeps it, so the next person who asks gets an exact answer straight from the archive.

Cause 3: some questions have one right answer #

Agents ask a lot of questions like these:

  • python 3.14 release date
  • weather Tokyo
  • latest Next.js version
  • bitcoin price

A page index is the wrong tool for them. Pages that mention "Python 3.14" are often old announcements, changelogs or someone's course page. The right answer is a fact from the source that owns it.

The fix: web search now recognises these questions and asks an open data source in parallel with the index, then puts a direct answer at the top. It arrives twice: as an answer object with an answer_text line, and as the first result with "type": "answer", because many clients only read results.

{
  "answer": {
    "type": "software_release",
    "answer_text": "Python 3.14: released 2025-10-07, latest 3.14.10 (2026-10-25), end of life 2030-10-31",
    "source": "endoflife.date (MIT)",
    "source_url": "https://endoflife.date/python"
  }
}

The sources are open and credited in every answer:

Question Source
Software versions, release dates, end of life endoflife.date
Weather anywhere Open-Meteo
Crypto prices public exchange market data
People, places, "what is" Wikipedia
Programming errors Stack Overflow

weather Tokyo now starts with Tokyo, Japan: clear sky, 12.4°C now; today 9.0-19.1°C, instead of a page about volcanic eruptions.

How to use this in your agent #

You do not need to change anything: the same endpoints simply stop returning empty answers. But two small additions make an agent noticeably better.

1. Tell the model how close the news results are. An exact hit can be quoted. A related one is background, and the model should say so.

import os
import requests

KEY = os.environ["NESTDADDY_API_KEY"]
BASE = "https://nestdaddy.com/api/v1"

def news(query, days=30, limit=5):
    r = requests.get(f"{BASE}/news/search", params={"q": query, "days": days, "limit": limit},
                     headers={"X-API-Key": KEY}, timeout=30)
    r.raise_for_status()
    data = r.json()
    on_topic = data["match"] in ("exact", "partial", "older", "live")
    note = "" if on_topic else "No article matched this question directly. These are the closest recent articles."
    return {"note": note, "articles": [
        {"title": a["title"], "url": a["url"], "source": a["source_domain"],
         "published": a["published_timestamp"], "match": a["match"]}
        for a in data["results"]]}

2. Use the direct answer when there is one. If answer is present, give the model answer_text first and the pages second.

def web(query, limit=5):
    r = requests.get(f"{BASE}/search", params={"q": query, "limit": limit},
                     headers={"X-API-Key": KEY}, timeout=30)
    r.raise_for_status()
    data = r.json()
    answer = data.get("answer") or {}
    pages = [p for p in data["results"] if p["type"] != "answer"]
    return {"answer": answer.get("answer_text"), "answer_source": answer.get("source"),
            "pages": [{"title": p["title"], "url": p["url"], "snippet": p["snippet"]} for p in pages]}

print(web("python 3.14 release date")["answer"])

If you use the NestDaddy MCP server in Claude, Cursor or another MCP client, both changes are already there: the web_search and news_search tools pass the answer and the match level to the model.

What we learned #

A search API built for people can afford an empty result. A search API built for agents cannot, because the agent will not rephrase the way a person does, and the developer watching it will decide in a few calls whether to keep going.

So our rule is now simple: every query gets the most useful answer we can give, and tells you honestly how close it is.

If your agent asks something and gets a poor answer, send us the query at [email protected]. That is exactly how this round of fixes started.

Get a free API key and try the queries above yourself.

── more in #ai-agents 4 stories · sorted by recency
── more on @nestdaddy 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/your-ai-agent-should…] indexed:0 read:7min 2026-11-18 · —