지도 요청 후속 턴: MAPS 규칙을 직전 사용자 발화로도 켜고, 장소 없는 "지도 열어줘"는 대화 중인 장소로 + 구글 지도 줄의 목록기호·이름표 허용 — '몬태나주 어디?' → '지도 열어줘'에 어디냐고 되묻고, '몬타나'만 답한 턴은 '지도' 키워드가 없어 규칙이 빠진 채 search_images로 무관한 스톡사진(대마초 사진 포함)을 붙였으며, '- 구글 지도: URL'은 목록 줄이라 지도로 안 뜸

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Opus 5.5 committed 2026-10-25 10:06:16 +09:00
1 parent fb7bdafb9a
commit b6622ceb78
3 files changed
+10 -4

No files matched your search

+1
View File
@@ -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,
+6 -2
View File
@@ -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/<URL-encoded name>,<lat>,<lon>` when you have coordinates (e.g. from place_search), otherwise `https://map.kakao.com/link/search/<URL-encoded query>`. Use Google only for places OUTSIDE Korea: `https://www.google.com/maps/search/<query>` (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/<URL-encoded name>,<lat>,<lon>` when you have coordinates (e.g. from place_search), otherwise `https://map.kakao.com/link/search/<URL-encoded query>`. Use Google only for places OUTSIDE Korea: `https://www.google.com/maps/search/<query>` (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를 먼저 불러라"다 — 그 도구가 이번 턴 스키마에 없으면 실행 불가능한 지시이고,
+3 -2
View File
@@ -280,8 +280,9 @@ function renderMarkdown(text, opts) {
return pre + '<div class="map-embed-wrap"><iframe class="map-embed' + routeCls + '" src="' + safeEmbed + '" allowfullscreen loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe><div class="map-embed-link"><a href="' + safeEmbed + '" target="_blank" rel="noopener">카카오맵에서 열기 ↗</a></div></div>' + 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 + '<div class="map-embed-wrap"><iframe class="map-embed" src="' + kakaoUrl + '" allowfullscreen loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe><div class="map-embed-link"><a href="' + kakaoUrl + '" target="_blank" rel="noopener">카카오맵에서 열기 ↗</a></div></div>' + post;