날씨: 이미 내린 비(이번 비 누적·어제 온 비)는 forecast가 아니라 current의 '이번 강수 누적'으로 답하게 힌트+도구 설명 보강

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5.5 committed 2026-10-19 09:59:48 +09:00
1 parent 17b8931e44
commit e82198fa77
3 files changed
+26 -2

No files matched your search

+1 -1
View File
@@ -939,7 +939,7 @@ export function createBuildTools(isOrchestrationSkillEnabled: () => boolean) {
// highs ran 1.5-2.5°C cooler (34.0 vs 36.5 for the same day), which matches its far
// denser domestic observation network. "current" is a real measurement, not a model
// estimate like the other two.
description: '한국 위치라면 이 도구를 먼저 쓸 것 (기상청 공식 API). type="current"는 관측 실황(기온·습도·풍향·풍속·강수형태) — 추정치가 아닌 실측값이라 국내에서 가장 신뢰도 높음. type="forecast"는 3일 단기예보(강수확률 포함). type="forecast"에는 날짜별 요약 외에 **시간별 예상 강수량(mm)과 합계, 3시간 간격 기온·습도·풍속·강수확률**이 포함되므로 "비 얼마나 와?", "내일 아침 몇 도야?", "오후에 바람 세?"도 이 도구 한 번으로 답할 것(기상청이 수치를 안 준다고 답하지 말 것). type="current"에는 **앞으로 6시간 초단기예보**("한 시간 뒤 비 와?")가 붙는다. 한국 도시명을 그대로 넣으면 된다. 3일을 넘는 예보나 UV·시간별 상세가 필요하면 weather_openmeteo로 보완할 것. **미세먼지/초미세먼지/PM2.5/PM10/황사/대기질은 이 도구에 없음 — weather_airkorea를 쓸 것** (이 도구를 반복 호출해도 답이 안 나옴). 해외 지역에는 사용 불가.',
description: '한국 위치라면 이 도구를 먼저 쓸 것 (기상청 공식 API). type="current"는 관측 실황(기온·습도·풍향·풍속·강수형태) — 추정치가 아닌 실측값이라 국내에서 가장 신뢰도 높음. type="forecast"는 3일 단기예보(강수확률 포함). type="forecast"에는 날짜별 요약 외에 **시간별 예상 강수량(mm)과 합계, 3시간 간격 기온·습도·풍속·강수확률**이 포함되므로 "비 얼마나 와?", "내일 아침 몇 도야?", "오후에 바람 세?"도 이 도구 한 번으로 답할 것(기상청이 수치를 안 준다고 답하지 말 것). 이미 내린 비("이번 비 누적", "어제 온 비", "지금까지 온 비")는 forecast가 아니라 type="current"의 "이번 강수 누적"·"오늘 누적" 줄로 답할 것. type="current"에는 **앞으로 6시간 초단기예보**("한 시간 뒤 비 와?")가 붙는다. 한국 도시명을 그대로 넣으면 된다. 3일을 넘는 예보나 UV·시간별 상세가 필요하면 weather_openmeteo로 보완할 것. **미세먼지/초미세먼지/PM2.5/PM10/황사/대기질은 이 도구에 없음 — weather_airkorea를 쓸 것** (이 도구를 반복 호출해도 답이 안 나옴). 해외 지역에는 사용 불가.',
parameters: {
type: 'object', required: ['location'],
properties: {
+11 -1
View File
@@ -11,6 +11,11 @@ const TIME_BEFORE_GAJI = /(?:오늘|내일|모레|글피|주말|이번\s?주|다
const UNTIL_RE = /(?:오늘|내일|모레|글피|주말|이번\s?주|\d{1,2}\s?일|[월화수목금토일]요일)\s*(?:까지|가지(?=\s|$|[?.!,]))/;
const AMOUNT_RE = /강수량|비\s?양|적설|몇\s?mm|얼마나\s*(?:오|올|내릴|내려)/;
const MAX_FOLLOWUP_CHARS = 40;
// 이미 내린 비를 묻는 말 — "이번 비 누적", "어제 온 비", "지금까지 온 비". 예보(forecast)가 아니라 실황(current)의
// '이번 강수 누적' 줄이 답이다. 2026-10-19: "현풍 이번 비 누적 강수량은?"에 forecast를 불러 앞으로 올 비(15mm)로
// 답했고, 이어 "어제 온 비"에도 24.6mm가 도구 결과에 있는데 "확정할 수 없다"고 했다. 한글 뒤 \b는 안 먹으므로 lookahead로 끝을 본다.
const PAST_RAIN_RE = /(?:이번|어제|그제|엊그제|지난|지금까지|간밤|밤사이|그동안|아까)\s*(?:에|동안)?\s*(?:온|내린|왔던)?\s*(?:비|강수|눈)(?=\s|$|[?.!,은는이가도])|누적\s*강수|비가?\s*(?:얼마나|많이)\s*(?:왔|내렸)/;
const FUTURE_RE = /내일|모레|글피|예보|앞으로|이따|다음\s?주|주말/;
const SHORT_NON_PLACE = /^(네|예|응|어|그래|그래요|고마워|고맙|감사|알겠|좋아|오케이|확인|됐어|됐다|아니야|아니요|아뇨|아냐|맞아|뭐|왜|진짜|정말|그럼|그리고|근데|하지만)/;
// 「아니 서울」「서울은?」「부산으로」처럼 장소만 고쳐 말하는 짧은 응답
@@ -25,9 +30,14 @@ export function weatherFollowUpHint(
const history = historyIn.length && historyIn[historyIn.length - 1].role === 'user' && String(historyIn[historyIn.length - 1].content || '').trim() === msg
? historyIn.slice(0, -1) : historyIn;
if (!msg || msg.length > MAX_FOLLOWUP_CHARS) return null;
if (!WEATHER_RE.test(msg)) return placeCorrectionHint(msg, history);
const pastRain = PAST_RAIN_RE.test(msg) && !FUTURE_RE.test(msg);
if (!WEATHER_RE.test(msg) && !pastRain) return placeCorrectionHint(msg, history);
const notes: string[] = [];
if (pastRain) {
notes.push('The user asks about rain that ALREADY fell (this rain event / yesterday / so far). Call weather_kma with type="current" (NOT "forecast") and answer from its "이번 강수 누적" line (cumulative since the rain began, with its start time and duration) and the "오늘 누적" line. Report those numbers directly and say which source each came from (e.g. AWS observation vs model estimate); do not say the amount cannot be determined when those lines are present, and never answer a past-rain question with forecast amounts.');
}
if (TIME_BEFORE_GAJI.test(msg)) {
notes.push(`"가지" in the user's message is almost certainly a typo for "까지" ("until/by") — read it as: ${msg.replace(/가지(?=\s|$|[?.!,])/, '까지')}`);
}
+14
View File
@@ -33,3 +33,17 @@ test('history 끝에 현재 메시지가 이미 들어 있어도 직전 날씨
const h = weatherFollowUpHint('아니 서울', [...HW, { role: 'user', content: '아니 서울' }])!;
assert.match(h, /"서울"/);
});
test('이미 내린 비(이번 비 누적/어제 온 비) → current 실황을 쓰라는 힌트', () => {
for (const q of ['현풍 이번 비 누적 강수량은?', '어제 온 비', '지금까지 온 비는?', '비 얼마나 왔어']) {
const h = weatherFollowUpHint(q, H);
assert.ok(h && /type="current"/.test(h), q);
}
});
test('앞으로 올 비·무관한 말에는 과거 비 힌트가 붙지 않는다', () => {
for (const q of ['내일 비 올까', '이번 주말 비 예보', '고마워']) {
const h = weatherFollowUpHint(q, H);
assert.ok(!h || !/ALREADY fell/.test(h), q);
}
});