{"slug": "your-ai-agent-should-never-get-an-empty-search-result-three-fixes-we-shipped", "title": "Your AI agent should never get an empty search result: three fixes we shipped", "summary": "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.", "body_md": "# Your AI agent should never get an empty search result: three fixes we shipped\n\nA 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.\n\nYesterday a developer signed up for NestDaddy, connected it to a news agent through our [LangChain integration](https://nestdaddy.com/blog/langchain-live-web-search-news) and started asking questions. Some were in English, some in Chinese: AI model launches, monthly car sales, events at a theme park.\n\nEvery call succeeded. HTTP 200, fast, valid JSON. And several of them came back with an empty list.\n\nFor 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.\n\nSo 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.\n\n```\nPress Run to call the API.\n```\n\n[Get your free API key](https://nestdaddy.com/mcp)\n\n## Cause 1: Chinese and Japanese have no spaces\n\nOur 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.\n\nChinese and Japanese do not. Here is what a word-based index sees for a Chinese headline about BYD's October sales:\n\n``` php\n比亚迪10月销量创新高   ->   one \"word\": '比亚迪10月销量创新高'\n```\n\nA 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.\n\n**The fix:** for Chinese and Japanese text we also index overlapping two-character pieces (bigrams), and split the query the same way:\n\n``` php\n比亚迪 销量   ->   比亚  亚迪  销量\n```\n\nNow the query and the headline share pieces, and the match works like it does for spaced languages. The same query today:\n\n```\n{\"title\": \"10月厂商销量：比亚迪破25万！特斯拉4年来首次未过万！\", \"source_domain\": \"chejiahao.autohome.com.cn\", \"match\": \"exact\"}\n{\"title\": \"10月澳洲市场：比亚迪销量再破万，经销商协会坐不住了\", \"source_domain\": \"k.sina.com.cn\", \"match\": \"exact\"}\n{\"title\": \"2026年上半年自主五强销量排行：比亚迪断层领先\", \"source_domain\": \"chejiahao.autohome.com.cn\", \"match\": \"exact\"}\n```\n\nWe also added more Chinese-language news sources, so there is more to find.\n\n## Cause 2: \"no exact match\" was treated as \"nothing\"\n\nMost 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`.\n\n**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:\n\n| match | What it means | \n|---|---|\n| `exact` | every word of the query matches, within the days you asked for | \n| `partial` | most of the important words match, always including the most specific one | \n| `older` | exact or partial, but older than the days you asked for | \n| `live` | fetched live for this query because the archive had nothing yet | \n| `related` | the newest articles sharing any important word; context, not an answer | \n\nThe \"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`.\n\nHere is that long theme park query today:\n\n```\n{\n  \"match\": \"partial\",\n  \"count\": 2,\n  \"results\": [\n    {\"title\": \"Winter Holiday to Return in Splendor to Universal Beijing Resort from November 20\",\n     \"source_domain\": \"english.beijing.gov.cn\", \"match\": \"partial\"},\n    {\"title\": \"Universal Beijing Resort Guide: What's New in 2026 and the Year's Events\",\n     \"source_domain\": \"hauntedattractionnetwork.com\", \"match\": \"partial\"}\n  ]\n}\n```\n\nThe first result is the winter season announcement a person asking that question wants, even though no headline contains the word \"Christmas\".\n\nAnd 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.\n\n## Cause 3: some questions have one right answer\n\nAgents ask a lot of questions like these:\n\n- `python 3.14 release date`\n- `weather Tokyo`\n- `latest Next.js version`\n- `bitcoin price`\n\nA 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.\n\n**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`.\n\n```\n{\n  \"answer\": {\n    \"type\": \"software_release\",\n    \"answer_text\": \"Python 3.14: released 2025-10-07, latest 3.14.10 (2026-10-25), end of life 2030-10-31\",\n    \"source\": \"endoflife.date (MIT)\",\n    \"source_url\": \"https://endoflife.date/python\"\n  }\n}\n```\n\nThe sources are open and credited in every answer:\n\n| Question | Source | \n|---|---|\n| Software versions, release dates, end of life | [endoflife.date](https://endoflife.date) | \n| Weather anywhere | [Open-Meteo](https://open-meteo.com) | \n| Crypto prices | public exchange market data | \n| People, places, \"what is\" | Wikipedia | \n| Programming errors | Stack Overflow | \n\n`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.\n\n## How to use this in your agent\n\nYou do not need to change anything: the same endpoints simply stop returning empty answers. But two small additions make an agent noticeably better.\n\n**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.\n\n``` python\nimport os\nimport requests\n\nKEY = os.environ[\"NESTDADDY_API_KEY\"]\nBASE = \"https://nestdaddy.com/api/v1\"\n\ndef news(query, days=30, limit=5):\n    r = requests.get(f\"{BASE}/news/search\", params={\"q\": query, \"days\": days, \"limit\": limit},\n                     headers={\"X-API-Key\": KEY}, timeout=30)\n    r.raise_for_status()\n    data = r.json()\n    on_topic = data[\"match\"] in (\"exact\", \"partial\", \"older\", \"live\")\n    note = \"\" if on_topic else \"No article matched this question directly. These are the closest recent articles.\"\n    return {\"note\": note, \"articles\": [\n        {\"title\": a[\"title\"], \"url\": a[\"url\"], \"source\": a[\"source_domain\"],\n         \"published\": a[\"published_timestamp\"], \"match\": a[\"match\"]}\n        for a in data[\"results\"]]}\n```\n\n**2. Use the direct answer when there is one.** If `answer` is present, give the model `answer_text` first and the pages second.\n\n``` python\ndef web(query, limit=5):\n    r = requests.get(f\"{BASE}/search\", params={\"q\": query, \"limit\": limit},\n                     headers={\"X-API-Key\": KEY}, timeout=30)\n    r.raise_for_status()\n    data = r.json()\n    answer = data.get(\"answer\") or {}\n    pages = [p for p in data[\"results\"] if p[\"type\"] != \"answer\"]\n    return {\"answer\": answer.get(\"answer_text\"), \"answer_source\": answer.get(\"source\"),\n            \"pages\": [{\"title\": p[\"title\"], \"url\": p[\"url\"], \"snippet\": p[\"snippet\"]} for p in pages]}\n\nprint(web(\"python 3.14 release date\")[\"answer\"])\n# Python 3.14: released 2025-10-07, latest 3.14.10 (2026-10-25), end of life 2030-10-31\n```\n\nIf you use the [NestDaddy MCP server](https://nestdaddy.com/mcp) 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.\n\n## What we learned\n\nA 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.\n\nSo our rule is now simple: every query gets the most useful answer we can give, and tells you honestly how close it is.\n\nIf your agent asks something and gets a poor answer, send us the query at [\\[email protected\\]](https://nestdaddy.com/cdn-cgi/l/email-protection). That is exactly how this round of fixes started.\n\n[Get a free API key](https://nestdaddy.com/apis) and try the queries above yourself.", "url": "https://wpnews.pro/news/your-ai-agent-should-never-get-an-empty-search-result-three-fixes-we-shipped", "canonical_source": "https://nestdaddy.com/blog/ai-agent-empty-search-results", "published_at": "2026-11-18 00:00:00+00:00", "updated_at": "2026-11-18 00:43:04.313554+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "natural-language-processing", "ai-search", "developer-tools"], "entities": ["NestDaddy", "LangChain", "BYD", "Tesla", "Universal Beijing Resort"], "also_reported_by": [], "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.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/your-ai-agent-should-never-get-an-empty-search-result-three-fixes-we-shipped", "markdown": "https://wpnews.pro/news/your-ai-agent-should-never-get-an-empty-search-result-three-fixes-we-shipped.md", "text": "https://wpnews.pro/news/your-ai-agent-should-never-get-an-empty-search-result-three-fixes-we-shipped.txt", "jsonld": "https://wpnews.pro/news/your-ai-agent-should-never-get-an-empty-search-result-three-fixes-we-shipped.jsonld"}}