v4.1.19: news_search country 파라미터 6개 이상 입력시 에러 대신 앞 5개만 사용
NewsData.io는 country를 6개 이상 넘기면 하드 에러("Number of country
cannot exceeded 5")를 내는데, "소아시아 뉴스"처럼 자연스럽게 6개 이상의
국가코드로 매핑되는 요청에서 모델이 왕복을 한 번 날리게 되던 문제 —
5개 초과분은 조용히 잘라내도록 수정.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+7
-4
@@ -42,8 +42,8 @@ export const newsSearchTool = {
|
|||||||
name: 'news_search',
|
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.',
|
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: {
|
schema: {
|
||||||
query: 'Optional keyword/topic to filter by (e.g. "economy", "South America"). Omit for general top headlines.',
|
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; 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.',
|
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.',
|
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.',
|
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',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
query: { type: 'string', description: 'Optional keyword/topic filter. Omit for general top headlines.' },
|
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.' },
|
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"' },
|
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)' };
|
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 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
|
// 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
|
// world-news pool instead of erroring) in two independently-confirmed cases — verified
|
||||||
// 2026-07-16 against the live API:
|
// 2026-07-16 against the live API:
|
||||||
|
|||||||
Reference in New Issue
Block a user