fix(chat): the delete consent check knows the pending message and reads the whole reply
The consent classifier is now told which message and channel are pending, so a yes for another
message ("yes, delete message 22" while 21 is pending) is a no and cancels the request. A reply
longer than 600 characters is no longer cut and judged by its start (which could drop a later
"don't"); it counts as no without a model call.
Eval evals/test_chat_delete_consent.py gains the different-message and long-reply cases:
17/17 on qwen2.5:7b, three runs. The previous prompt said YES 3/3 to
"응, 일정 채널에 있는 거 지워" while a message in 잡담 was pending.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""chatChannels tool (src/jarvis/tools/builtin/chat_channels.spec.md) with a fake chat backend."""
|
||||
|
||||
import re
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
@@ -175,6 +176,35 @@ def test_the_consent_check_failing_means_no(chat):
|
||||
assert chat.acts == []
|
||||
|
||||
|
||||
def test_the_check_knows_which_message_is_pending_and_another_one_cancels(chat):
|
||||
"""A yes for a different message is not a yes for the pending one."""
|
||||
def judge(base_url, model, system_prompt, user_content, **kw):
|
||||
# A careful classifier: agrees only when no other message number is named.
|
||||
pending = re.findall(r"message (\d+)", system_prompt)
|
||||
named = re.findall(r"\d+", user_content)
|
||||
return "YES" if pending and all(n == pending[0] for n in named) else "NO"
|
||||
with patch("jarvis.tools.builtin.chat_channels.call_llm_direct", side_effect=judge):
|
||||
call(ASK, chat, said="21번 지워 줘")
|
||||
chat.turn = 2
|
||||
assert not call({**ASK, "confirm": True}, chat, said="yes, delete message 22").success
|
||||
chat.turn = 3
|
||||
assert not call({**ASK, "confirm": True}, chat, said="응 지워").success # cancelled
|
||||
call(ASK, chat, said="21번 지워 줘")
|
||||
chat.turn = 4
|
||||
assert call({**ASK, "confirm": True}, chat, said="응 21번 지워").success
|
||||
assert chat.acts == [("delete", "2", {"message_id": "21"})]
|
||||
|
||||
|
||||
def test_a_reply_too_long_to_judge_whole_is_not_a_yes(chat):
|
||||
"""A later "don't" must never be cut off: an over-long reply is no, not a judged prefix."""
|
||||
said = "응 지워. " + "그런데 말이야 " * 120 + "아니 취소해. 삭제하지 마"
|
||||
with consent({"응 지워": "YES"}):
|
||||
call(ASK, chat, said="21번 지워 줘")
|
||||
chat.turn = 2
|
||||
assert not call({**ASK, "confirm": True}, chat, said=said).success
|
||||
assert chat.acts == [] and not chat.pending_deletes
|
||||
|
||||
|
||||
def test_confirm_without_a_request_is_refused(chat):
|
||||
chat.turn = 5
|
||||
with consent({"응": "YES"}):
|
||||
|
||||
Reference in New Issue
Block a user