From b6622ceb78ba15008f68601f43f21c5fb8374c66 Mon Sep 17 00:00:00 2001 From: kim Date: Sun, 25 Oct 2026 10:06:16 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A7=80=EB=8F=84=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=ED=9B=84=EC=86=8D=20=ED=84=B4:=20MAPS=20=EA=B7=9C=EC=B9=99?= =?UTF-8?q?=EC=9D=84=20=EC=A7=81=EC=A0=84=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EB=B0=9C=ED=99=94=EB=A1=9C=EB=8F=84=20=EC=BC=9C=EA=B3=A0,=20?= =?UTF-8?q?=EC=9E=A5=EC=86=8C=20=EC=97=86=EB=8A=94=20"=EC=A7=80=EB=8F=84?= =?UTF-8?q?=20=EC=97=B4=EC=96=B4=EC=A4=98"=EB=8A=94=20=EB=8C=80=ED=99=94?= =?UTF-8?q?=20=EC=A4=91=EC=9D=B8=20=EC=9E=A5=EC=86=8C=EB=A1=9C=20+=20?= =?UTF-8?q?=EA=B5=AC=EA=B8=80=20=EC=A7=80=EB=8F=84=20=EC=A4=84=EC=9D=98=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=EA=B8=B0=ED=98=B8=C2=B7=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=ED=91=9C=20=ED=97=88=EC=9A=A9=20=E2=80=94=20'=EB=AA=AC?= =?UTF-8?q?=ED=83=9C=EB=82=98=EC=A3=BC=20=EC=96=B4=EB=94=94=3F'=20?= =?UTF-8?q?=E2=86=92=20'=EC=A7=80=EB=8F=84=20=EC=97=B4=EC=96=B4=EC=A4=98'?= =?UTF-8?q?=EC=97=90=20=EC=96=B4=EB=94=94=EB=83=90=EA=B3=A0=20=EB=90=98?= =?UTF-8?q?=EB=AC=BB=EA=B3=A0,=20'=EB=AA=AC=ED=83=80=EB=82=98'=EB=A7=8C=20?= =?UTF-8?q?=EB=8B=B5=ED=95=9C=20=ED=84=B4=EC=9D=80=20'=EC=A7=80=EB=8F=84'?= =?UTF-8?q?=20=ED=82=A4=EC=9B=8C=EB=93=9C=EA=B0=80=20=EC=97=86=EC=96=B4=20?= =?UTF-8?q?=EA=B7=9C=EC=B9=99=EC=9D=B4=20=EB=B9=A0=EC=A7=84=20=EC=B1=84=20?= =?UTF-8?q?search=5Fimages=EB=A1=9C=20=EB=AC=B4=EA=B4=80=ED=95=9C=20?= =?UTF-8?q?=EC=8A=A4=ED=86=A1=EC=82=AC=EC=A7=84(=EB=8C=80=EB=A7=88?= =?UTF-8?q?=EC=B4=88=20=EC=82=AC=EC=A7=84=20=ED=8F=AC=ED=95=A8)=EC=9D=84?= =?UTF-8?q?=20=EB=B6=99=EC=98=80=EC=9C=BC=EB=A9=B0,=20'-=20=EA=B5=AC?= =?UTF-8?q?=EA=B8=80=20=EC=A7=80=EB=8F=84:=20URL'=EC=9D=80=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A4=84=EC=9D=B4=EB=9D=BC=20=EC=A7=80=EB=8F=84?= =?UTF-8?q?=EB=A1=9C=20=EC=95=88=20=EB=9C=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- src/gateway/chat/handle-chat.ts | 1 + src/gateway/chat/system-prompt.ts | 8 ++++++-- web-ui/js/app/markdown.js | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gateway/chat/handle-chat.ts b/src/gateway/chat/handle-chat.ts index e1b19f1..e1d958a 100644 --- a/src/gateway/chat/handle-chat.ts +++ b/src/gateway/chat/handle-chat.ts @@ -868,6 +868,7 @@ async function handleChat( executionMode, toolNames: tools.map((t: any) => String(t?.function?.name || '')), message, + prevUserMessage: String(history.filter(h => h.role === 'user').slice(-1)[0]?.content || ''), dateStr, timeStr, isTranslateSession, diff --git a/src/gateway/chat/system-prompt.ts b/src/gateway/chat/system-prompt.ts index 77d06c5..5043ac5 100644 --- a/src/gateway/chat/system-prompt.ts +++ b/src/gateway/chat/system-prompt.ts @@ -48,6 +48,8 @@ export interface SystemPromptInput { skillsCtx?: string; /** The user's message this turn — only used to gate CHEMISTRY NOTATION (see below). */ message?: string; + /** 직전 사용자 발화 — MAPS 게이트만 쓴다("지도 열어줘" → "몬타나"처럼 지명만 답하는 다음 턴). */ + prevUserMessage?: string; } /** @@ -224,6 +226,8 @@ export function buildChatSystemPrompt(input: SystemPromptInput): string { // one absent map, not an unguarded tool call. 2026-10-14부터 국내는 카카오맵 링크(map.kakao.com/link/map|search, // 키 불필요), 해외만 구글. 모델이 국내 지명에 구글 URL을 내도 markdown.js가 카카오 검색으로 바꿔 띄운다. // 경로(길찾기) 지도는 삽입되지 않으니 여기서 약속하지 않는다 — 운전 경로는 route_search의 링크. + // 직전 사용자 발화도 본다(10-25): "지도 열어줘"에 모델이 어디냐고 되묻고, 사용자가 "몬타나"만 답한 턴엔 키워드가 + // 없어 규칙이 빠져 search_images(무관한 스톡사진)로 갔다. // place_search(카카오맵)가 있을 때: 장소 주소·전화·거리는 도구로 찾는다. 기억으로 주소를 짓지 않는다. const placeSearchRuleBlock = toolNames.has('place_search') ? '\nPLACE SEARCH: For a specific place, business, or "near X" request in Korea (restaurants, pharmacies, stations, an address or phone number), call place_search FIRST and answer from its results — never write an address or phone number from memory. Default reference point is 구미시; pass location for another area. Put the 카카오맵 `지도:` URL from the result for the top place on its own line so it renders as an inline map, and mention the others by name. Opening hours are not in the result: point to its 상세 link instead of guessing.' @@ -232,8 +236,8 @@ export function buildChatSystemPrompt(input: SystemPromptInput): string { ? '\nROUTE SEARCH: For driving directions, travel time, distance, or toll questions within Korea, call route_search and answer ONLY from its numbers — never estimate a drive time or toll from memory. Default origin is the user\'s home (구미시 형곡동); pass origin if the user names one. Put the 길찾기 지도 link from the result alone on its own line, with no label in front — the client shows it as an inline route map. For 대중교통/도보/자전거 say route_search covers driving only and give that link.' : ''; const mapsRuleBlock = /지도|맵으로|위치(를|가|는)?|주소|어디(에|야|예요|에요|입니까|인가|니|냐|쯤|메)|어디\s*(있|찾|가|계|위치|살|사는|근처)|길\s*찾|가는\s*길|찾아가|찾아오|약도|도로명|지번|좌표|경위도|근처|인근|부근|가까운|\bmap\b|\baddress\b|directions|navigate|where\s+is|how\s+(do\s+i\s+|to\s+)get\s+to|nearby|landmark/i - .test(String(input.message || '')) - ? '\nMAPS: When the user asks where a place is, for its address, or to see a map of a location, output the map URL on its own line — the client turns that standalone line into an inline map. For places IN KOREA use 카카오맵: `https://map.kakao.com/link/map/,,` when you have coordinates (e.g. from place_search), otherwise `https://map.kakao.com/link/search/`. Use Google only for places OUTSIDE Korea: `https://www.google.com/maps/search/` (URL-encode, add city/country when ambiguous). Do NOT call browser_open for it and do NOT wrap it in `![](...)`. Still answer in text as well — the map is an addition, not a replacement. For driving routes in Korea use the route_search 길찾기 link instead (it renders as a route map); Google route links do not render.' + .test(`${input.prevUserMessage || ''}\n${input.message || ''}`) + ? '\nMAPS: When the user asks where a place is, for its address, or to see a map of a location, output the map URL on its own line — the client turns that standalone line into an inline map. For places IN KOREA use 카카오맵: `https://map.kakao.com/link/map/,,` when you have coordinates (e.g. from place_search), otherwise `https://map.kakao.com/link/search/`. Use Google only for places OUTSIDE Korea: `https://www.google.com/maps/search/` (URL-encode, add city/country when ambiguous). Do NOT call browser_open for it and do NOT wrap it in `![](...)`. If the user asks for a map without naming a place ("지도 열어줘"), use the place the conversation is already about instead of asking which one. The map URL line must be bare — no bullet, no label in front. Do not use image search for a map. Still answer in text as well — the map is an addition, not a replacement. For driving routes in Korea use the route_search 길찾기 link instead (it renders as a route map); Google route links do not render.' : ''; // VERIFY CONCRETE FACTS는 ANTI-HALLUCINATION 안에 무조건 붙어 있었지만, 하는 말이 통째로 // "web_search를 먼저 불러라"다 — 그 도구가 이번 턴 스키마에 없으면 실행 불가능한 지시이고, diff --git a/web-ui/js/app/markdown.js b/web-ui/js/app/markdown.js index 73db3b7..a8d6f7f 100644 --- a/web-ui/js/app/markdown.js +++ b/web-ui/js/app/markdown.js @@ -280,8 +280,9 @@ function renderMarkdown(text, opts) { return pre + '' + post; }); - // Google Maps URLs on their own line → inline iframe - html = html.replace(/((?:^|\n)[ \t]*)(https?:\/\/(?:www\.google\.com\/maps|maps\.google\.com|goo\.gl\/maps)[^\s<>")\n]*)([ \t]*)(?=\n|$)/gim, function(m, pre, url, post) { + // Google Maps URLs on their own line → inline iframe. 카카오처럼 짧은 이름표("구글 지도: URL")와 목록 기호도 + // 떼고 띄운다(10-25 '- 구글 지도: https://www.google.com/maps/search/Montana'가 링크로만 나옴). + html = html.replace(/((?:^|\n)[ \t]*)(?:[-*•][ \t]+)?(?:[^\n<>:]{1,20}:[ \t]*)?(https?:\/\/(?:www\.google\.com\/maps|maps\.google\.com|goo\.gl\/maps)[^\s<>")\n]*)([ \t]*)(?=\n|$)/gim, function(m, pre, url, post) { var kakaoUrl = googleMapsToKakaoUrl(url); if (kakaoUrl) { return pre + '' + post;