끊어 보낸 메시지 힌트 오발동 수정: '문장/메시지/대화/질문' 같은 말과 합치기·끊김 말이 함께 있어야 발동('2개를 병렬로 연결하면 되나?'가 걸려 실제 질문을 무시했음)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d635253080
commit
17eb76bf2c
2 files changed
+12
-3
No files matched your search
@@ -74,20 +74,24 @@ function placeCorrectionHint(msg: string, history: ReadonlyArray<{ role: string;
|
||||
* 사용자가 "두 문장 합해야 하네.." / "위에 두 대화 문장이 원래 한 문장이라고"라고 해도 모델(Haiku)은 합칠 원문을
|
||||
* 다시 붙여 달라고 하거나, 메타 발화 자체("두 문장 합해야 하네")를 합쳐 버렸다. 직전 사용자 발화를 그대로 짚어 준다.
|
||||
*/
|
||||
const SPLIT_META_RE = /(?:두|2|세|3)\s*(?:문장|메시지|개|줄|대화)|한\s*문장|원래\s*한|합(?:쳐|해|치|친|하)|이어\s*(?:서|붙|진|지)|붙여서|끊겼|끊어졌|잘렸|잘린|중간에\s*(?:보내|전송|넘어)/;
|
||||
// 메시지·문장을 가리키는 말 + 합치기/끊김 말이 둘 다 있어야 메타 발화로 본다. 동사만 보던 때는
|
||||
// '무거운 거 돌릴 때 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 || msg.length > 60 || !SPLIT_META_RE.test(msg)) return null;
|
||||
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 && !(t.length <= 60 && SPLIT_META_RE.test(t)))
|
||||
.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.`;
|
||||
|
||||
@@ -69,5 +69,10 @@ describe('splitMessageHint — 끊어 보낸 메시지 이어붙이기 (2026-10-
|
||||
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