From 8f235a148dea96369c43fc0000a2d14877a80dc8 Mon Sep 17 00:00:00 2001 From: kim Date: Sat, 18 Jul 2026 13:08:01 +0900 Subject: [PATCH] =?UTF-8?q?v4.1.19:=20news=5Fsearch=20country=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=206=EA=B0=9C=20=EC=9D=B4=EC=83=81?= =?UTF-8?q?=20=EC=9E=85=EB=A0=A5=EC=8B=9C=20=EC=97=90=EB=9F=AC=20=EB=8C=80?= =?UTF-8?q?=EC=8B=A0=20=EC=95=9E=205=EA=B0=9C=EB=A7=8C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NewsData.io는 country를 6개 이상 넘기면 하드 에러("Number of country cannot exceeded 5")를 내는데, "소아시아 뉴스"처럼 자연스럽게 6개 이상의 국가코드로 매핑되는 요청에서 모델이 왕복을 한 번 날리게 되던 문제 — 5개 초과분은 조용히 잘라내도록 수정. Co-Authored-By: Claude Sonnet 5 --- src/tools/news.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tools/news.ts b/src/tools/news.ts index 6a0530f..2d7a2d8 100644 --- a/src/tools/news.ts +++ b/src/tools/news.ts @@ -42,8 +42,8 @@ export const newsSearchTool = { name: 'news_search', description: 'Get real news headlines from the last 48 hours via NewsData.io — use this instead of web_search for any "오늘 뉴스"/"today\'s news"/breaking news request. Returns real articles with actual publish dates and sources, not generic web pages.', schema: { - query: 'Optional keyword/topic to filter by (e.g. "economy", "South America"). Omit for general top headlines.', - country: 'Optional ISO 3166-1 alpha-2 country code (e.g. "kr" for Korea, "us" for USA, "br" for Brazil). Accepts a comma-separated list for multiple countries in one call, MAX 5 (e.g. "de,fr,gb,it,es" — verified working, each result tagged with its source country; a 6th+ country errors with "Number of country cannot exceeded 5"). There is NO code for continents/regions ("eu"/"europe" will error with "country does not exist") — for a "European news" request, pass up to 5 major European country codes instead (e.g. "de,fr,gb,it,es"). Omit country entirely for worldwide.', + query: 'Optional keyword/topic to filter by (e.g. "economy", "South America"). Omit for general top headlines. IMPORTANT: this is matched literally against article text, not translated — for a broad "top news for this country/region" request with no specific topic, do NOT pass the user\'s original-language request text as query (e.g. a Korean phrase will match zero articles in a country whose news is written in English/Turkish/etc). Omit query in that case and rely on country/category alone.', + country: 'Optional ISO 3166-1 alpha-2 country code (e.g. "kr" for Korea, "us" for USA, "br" for Brazil). Accepts a comma-separated list for multiple countries in one call, MAX 5 (e.g. "de,fr,gb,it,es" — verified working, each result tagged with its source country); if more than 5 are given, only the first 5 are used. There is NO code for continents/regions ("eu"/"europe" will error with "country does not exist") — for a "European news" request, pass up to 5 major European country codes instead (e.g. "de,fr,gb,it,es"). Omit country entirely for worldwide.', language: 'Optional ISO 639-1 language code (e.g. "ko", "en"). IGNORED whenever country is also set — NewsData.io silently drops the country filter and returns irrelevant results when language doesn\'t match the country\'s dominant language (e.g. country="de"+language="en" returns US news, not German). Only pass language when country is omitted.', category: 'Optional: business, entertainment, environment, food, health, politics, science, sports, technology, top, tourism, or world. "world" is IGNORED when country is also set (NewsData.io silently drops the country filter for that combo) — for a specific country\'s news, omit category or use "top"/"politics"/etc. instead.', }, @@ -51,7 +51,7 @@ export const newsSearchTool = { type: 'object', properties: { query: { type: 'string', description: 'Optional keyword/topic filter. Omit for general top headlines.' }, - country: { type: 'string', description: 'Optional ISO 3166-1 alpha-2 country code, e.g. "kr", "us", "br", "jp". Comma-separated list for multiple countries, MAX 5 (e.g. "de,fr,gb,it,es"). No continent code exists — for "European news" pass up to 5 country codes (e.g. "de,fr,gb,it,es"), not "eu".' }, + country: { type: 'string', description: 'Optional ISO 3166-1 alpha-2 country code, e.g. "kr", "us", "br", "jp". Comma-separated list for multiple countries, MAX 5 (e.g. "de,fr,gb,it,es") — extras beyond 5 are dropped, not an error. No continent code exists — for "European news" pass up to 5 country codes (e.g. "de,fr,gb,it,es"), not "eu".' }, language: { type: 'string', description: 'Optional ISO 639-1 language code, e.g. "ko", "en". Ignored when country is set (see country field) — only pass one or the other.' }, category: { type: 'string', description: '"business"|"entertainment"|"environment"|"food"|"health"|"politics"|"science"|"sports"|"technology"|"top"|"tourism"|"world"' }, }, @@ -62,7 +62,10 @@ export const newsSearchTool = { if (!apiKey) return { success: false, error: 'NewsData.io API key not configured (set news.newsdata_api_key in .smallclaw/config.json)' }; const query = String(args?.query || '').trim(); - const country = String(args?.country || '').trim().toLowerCase(); + // NewsData.io hard-errors ("Number of country cannot exceeded 5") instead of just using + // the first 5 — silently truncating here saves the model a wasted round-trip on requests + // that naturally name 6+ countries (e.g. "소아시아" mapped to 6 nearby country codes). + const country = String(args?.country || '').trim().toLowerCase().split(',').map(c => c.trim()).filter(Boolean).slice(0, 5).join(','); // NewsData.io silently drops the country filter (falling back to a generic English-language // world-news pool instead of erroring) in two independently-confirmed cases — verified // 2026-07-16 against the live API: