끊어 보낸 메시지 힌트(splitMessageHint) 제거 — 실제 적중 0회, 오발동 2회(진짜 질문을 '합친 질문'으로 바꿔 답 안 함). 근원(한글 조합 Enter·중지 후 서버가 답 저장)은 d635253에서 수정
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17eb76bf2c
commit
9389e86ce6
3 files changed
+2
-68
No files matched your search
@@ -66,33 +66,3 @@ function placeCorrectionHint(msg: string, history: ReadonlyArray<{ role: string;
|
||||
if (!prevQ || !WEATHER_RE.test(prevQ)) return null;
|
||||
return `The user's short message "${msg}" is most likely a correction of the PLACE in their previous weather question ("${prevQ.slice(0, 80)}"): the place is "${m[1]}". Re-run the same kind of weather lookup (weather_kma for Korea) for that place and answer the previous question for it — do NOT switch to web search and do NOT ask which place they mean.`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 나뉘어 보낸 메시지 이어붙이기 힌트 (2026-10-21).
|
||||
*
|
||||
* 실사고(메인채팅): "sg 90 서보 모터로 만들 수 있는 장난감 롭"이 중간에 전송되고 이어서 "로봇 뭐가 잇지?"를 보냄 →
|
||||
* 사용자가 "두 문장 합해야 하네.." / "위에 두 대화 문장이 원래 한 문장이라고"라고 해도 모델(Haiku)은 합칠 원문을
|
||||
* 다시 붙여 달라고 하거나, 메타 발화 자체("두 문장 합해야 하네")를 합쳐 버렸다. 직전 사용자 발화를 그대로 짚어 준다.
|
||||
*/
|
||||
// 메시지·문장을 가리키는 말 + 합치기/끊김 말이 둘 다 있어야 메타 발화로 본다. 동사만 보던 때는
|
||||
// '무거운 거 돌릴 때 2개를 병렬로 연결하면 되나?'가 걸려 실제 질문을 무시했다(10-22).
|
||||
const SPLIT_NOUN_RE = /문장|메시지|메세지|대화|질문|채팅/;
|
||||
const SPLIT_META_RE = /(?:두|2|세|3)\s*(?:문장|메시지|메세지|줄|대화|질문)|한\s*문장|원래\s*한|합(?:쳐|해|치|친|하)|이어\s*(?:서|붙|진|지)|붙여|끊겼|끊어졌|잘렸|잘린|중간에|나눠|나뉘/;
|
||||
const isSplitMeta = (t: string) => t.length <= 60 && SPLIT_NOUN_RE.test(t) && SPLIT_META_RE.test(t);
|
||||
|
||||
export function splitMessageHint(
|
||||
message: string,
|
||||
historyIn: ReadonlyArray<{ role: string; content?: any }>,
|
||||
): string | null {
|
||||
const msg = String(message || '').trim();
|
||||
if (!msg || !isSplitMeta(msg)) return null;
|
||||
const history = historyIn.length && historyIn[historyIn.length - 1].role === 'user' && String(historyIn[historyIn.length - 1].content || '').trim() === msg
|
||||
? historyIn.slice(0, -1) : historyIn;
|
||||
// 앞서 같은 메타 발화를 했으면("두 문장 합해야 하네" → "원래 한 문장이라고") 그것도 빼고 실제 내용 발화만 남긴다
|
||||
const prior = history.filter(h => h.role === 'user')
|
||||
.map(h => String(h.content || '').trim())
|
||||
.filter(t => t && !isSplitMeta(t))
|
||||
.slice(-2);
|
||||
if (prior.length < 2) return null;
|
||||
return `The user is saying their earlier messages were ONE sentence that got sent in pieces (e.g. Enter was pressed mid-sentence). Their last content messages, oldest first: 1) "${prior[0]}" 2) "${prior[1]}". Join these into the single question they meant (fix an obvious cut-off word or typo where they meet), state the joined question in one short line, then answer THAT question directly. This current message is only a remark about the split — do not treat its words as content, and do not ask them to paste the text again.`;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ import { selectToolsForTurn, bootAllowedTools, codeAiBlockedTools } from './tool
|
||||
import { buildChatSystemPrompt, groundingResultReadingRule } from './system-prompt';
|
||||
import { decideRoute } from './model-routing';
|
||||
import { weatherFabricationReplacement } from './tool-failure-backstop';
|
||||
import { weatherFollowUpHint, splitMessageHint } from './followup-hints';
|
||||
import { weatherFollowUpHint } from './followup-hints';
|
||||
import { fixKeyboardLayout } from './hangul-layout';
|
||||
import { suspectSoundAlikePlace } from './voice-place-check';
|
||||
import { replyIsWrongLanguage, TRANSLATE_TO_KOREAN_SYSTEM } from './language-backstop';
|
||||
@@ -975,13 +975,6 @@ async function handleChat(
|
||||
messages.push({ role: 'assistant', content: 'Understood.' });
|
||||
messages.push({ role: 'user', content: `Note: ${_wfHint}` });
|
||||
}
|
||||
// 중간에 끊어 보낸 두 메시지를 "원래 한 문장"이라고 할 때 직전 발화를 짚어 준다 (followup-hints.ts, 2026-10-21)
|
||||
const _splitHint = splitMessageHint(message, history);
|
||||
if (_splitHint) {
|
||||
console.log('[v2] SPLIT-MESSAGE HINT added');
|
||||
messages.push({ role: 'assistant', content: 'Understood.' });
|
||||
messages.push({ role: 'user', content: `Note: ${_splitHint}` });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, describe } from 'node:test';
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { weatherFollowUpHint } from '../src/gateway/chat/followup-hints';
|
||||
|
||||
@@ -47,32 +47,3 @@ test('앞으로 올 비·무관한 말에는 과거 비 힌트가 붙지 않는
|
||||
assert.ok(!h || !/ALREADY fell/.test(h), q);
|
||||
}
|
||||
});
|
||||
|
||||
import { splitMessageHint } from '../src/gateway/chat/followup-hints';
|
||||
|
||||
describe('splitMessageHint — 끊어 보낸 메시지 이어붙이기 (2026-10-21)', () => {
|
||||
const H = [
|
||||
{ role: 'user', content: 'sg 90 서보 모터로 만들 수 있는 장난감 롭' },
|
||||
{ role: 'assistant', content: '...' },
|
||||
{ role: 'user', content: '로봇 뭐가 잇지?' },
|
||||
{ role: 'assistant', content: '...' },
|
||||
];
|
||||
test('실측: "두 문장 합해야 하네.."는 직전 두 발화를 짚는다', () => {
|
||||
const h = splitMessageHint('두 문장 합해야 하네..', H);
|
||||
assert.ok(h && h.includes('장난감 롭') && h.includes('로봇 뭐가 잇지?'));
|
||||
});
|
||||
test('실측 2턴째: 앞선 메타 발화는 내용에서 뺀다', () => {
|
||||
const H2 = [...H, { role: 'user', content: '두 문장 합해야 하네..' }, { role: 'assistant', content: '...' }];
|
||||
const h = splitMessageHint('위에 두 대화 문장이 원래 한 문장이라고', H2);
|
||||
assert.ok(h && h.includes('장난감 롭') && !h.includes('합해야 하네'));
|
||||
});
|
||||
test('관계없는 짧은 말은 무시', () => {
|
||||
assert.equal(splitMessageHint('고마워', H), null);
|
||||
assert.equal(splitMessageHint('내일 날씨는?', H), null);
|
||||
// 10-22 오발동: 내용 질문에 '2개', '연결', '합' 같은 말이 들어간 경우
|
||||
assert.equal(splitMessageHint('무거운거 돌릴때 2개를 병령로 연결하면 되나?', H), null);
|
||||
assert.equal(splitMessageHint('그러니까 서보를 2개 병렬로 연결하면 무거운 거를 돌릴 수 있냐란 거지', H), null);
|
||||
assert.equal(splitMessageHint('전원이 끊겼어', H), null);
|
||||
assert.equal(splitMessageHint('두 값을 합하면 얼마야?', H), null);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user