From the live conversation on 0.1.40 (2026-11-18): - The bot browser told pages a program drives it (navigator.webdriver), and YouTube stopped every video about 45 s in with "문제가 발생했습니다" (ump.spsrejectfailure, reproduced twice on the game PC). Chrome now starts with --disable-blink-features=AutomationControlled, as the M0 video check already did; the live Chrome test checks webdriver is false. - "네." to "계산기를 실행해도 될까요?" got webSearch and botBrowser from the router, so the consent call was refused and the calculator never started. Waiting tools: pcControl stays on offer while a request asked in the previous reply waits, botBrowser while it holds the asker's page. - "소리 반으로 줄여 줘" for the bot's video worked on the person's own Edge window. botBrowser gets a volume action (media elements and YouTube's player), the page shows its volume, its description names its actions first (the part the planner sees), pcControl's says the bot's browser is not among its windows, and a turn whose plan has no step while a tool holds something for the asker gets the one-step nudge for it. Evals (qwen3.6 on the game PC): volume 0/3 before, 8/8 after; "네." consent 10/10; pcControl 10/10; botBrowser 16/18 (the NewJeans play case fails 0/6 before this change too). Unit: Python 2542 passed, 13 failed (the same 13 as before); app 348 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
102 lines
5.2 KiB
Python
102 lines
5.2 KiB
Python
"""Tools still waiting on the asker stay on offer (reply.spec.md, "Waiting tools").
|
|
|
|
Live 2026-11-18 (0.1.40): "계산기 열어서 12 더하기 3 해 줘" -> pcControl asked "실행해도 될까요?" ->
|
|
the person said "네." and the router picked webSearch and botBrowser, so the model's pcControl call
|
|
was refused and the reply said no tool could start the calculator. Then, with a YouTube video
|
|
playing in the bot browser, "소리 반으로 줄여 줘" and "유튜브 문제 발생했다고 뜨는데?" got pcControl
|
|
and screenView only, and the model worked on the person's own Edge window instead.
|
|
"""
|
|
|
|
from unittest.mock import Mock, patch
|
|
|
|
import pytest
|
|
|
|
from src.jarvis.memory.conversation import DialogueMemory
|
|
from src.jarvis.reply import turn_state
|
|
from src.jarvis.reply.engine import run_reply_engine
|
|
from src.jarvis.tools.builtin import bot_browser
|
|
from tests.test_engine_tool_carryover_guard import _mock_cfg, _tool_names_from_chat_call
|
|
|
|
|
|
class FakePc:
|
|
def __init__(self, turn, state):
|
|
self.turn = turn
|
|
self.state = state
|
|
|
|
def act(self, action, **fields):
|
|
return {"ok": True, "item": {}}
|
|
|
|
|
|
def _reply(text, router_pick, pc=None, user="100"):
|
|
mock_chat = Mock(return_value={"message": {"content": "네."}})
|
|
turn_state.reset()
|
|
turn_state.set_user(user)
|
|
turn_state.set_pc(pc)
|
|
try:
|
|
with patch("src.jarvis.reply.engine.select_tools", return_value=list(router_pick)), \
|
|
patch("src.jarvis.reply.engine.chat_with_messages", mock_chat), \
|
|
patch("src.jarvis.reply.engine.extract_text_from_response", return_value="네."), \
|
|
patch("src.jarvis.reply.engine.plan_query", return_value=[]), \
|
|
patch("src.jarvis.reply.engine.extract_search_params_for_memory", return_value={}), \
|
|
patch("src.jarvis.memory.graph.GraphMemoryStore"), \
|
|
patch("src.jarvis.memory.graph_ops.build_warm_profile", return_value={"user": "", "directives": ""}), \
|
|
patch("src.jarvis.memory.graph_ops.format_warm_profile_block", return_value=""):
|
|
run_reply_engine(db=Mock(), cfg=_mock_cfg(), tts=None, text=text, dialogue_memory=DialogueMemory())
|
|
finally:
|
|
turn_state.reset()
|
|
return _tool_names_from_chat_call(mock_chat.call_args_list[-1])
|
|
|
|
|
|
def _pending(turn):
|
|
return {"pending": {"계산기": {"turn": turn, "kinds": ["run"], "what": "run in 계산기"}}}
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_a_pc_request_asked_in_the_previous_reply_keeps_pc_control_on_offer():
|
|
names = _reply("네.", ["webSearch"], pc=FakePc(turn=2, state=_pending(1)))
|
|
assert "pcControl" in names and "webSearch" in names, sorted(names)
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_a_lapsed_or_absent_pc_request_adds_nothing():
|
|
assert "pcControl" not in _reply("네.", ["webSearch"], pc=FakePc(turn=3, state=_pending(1)))
|
|
assert "pcControl" not in _reply("네.", ["webSearch"], pc=FakePc(turn=2, state={}))
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_the_page_the_bot_browser_holds_for_the_asker_keeps_bot_browser_on_offer(monkeypatch):
|
|
monkeypatch.setenv("JARVIS_BROWSER_CDP", "http://127.0.0.1:1")
|
|
monkeypatch.setattr(bot_browser, "_sessions", {"100": object()})
|
|
assert "botBrowser" in _reply("소리 반으로 줄여 줘", ["pcControl"], pc=FakePc(1, {}))
|
|
# Another person's page is not the asker's.
|
|
assert "botBrowser" not in _reply("소리 반으로 줄여 줘", ["pcControl"], pc=FakePc(1, {}), user="200")
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_an_answer_without_the_held_tool_after_a_plan_without_steps_is_asked_to_call_it(monkeypatch):
|
|
# Eval 2026-11-19: "소리 반으로 줄여 줘" with the asker's video playing, the planner planned no
|
|
# step and the model said the volume was halved without calling botBrowser (0/6).
|
|
monkeypatch.setenv("JARVIS_BROWSER_CDP", "http://127.0.0.1:1")
|
|
monkeypatch.setattr(bot_browser, "_sessions", {"100": object()})
|
|
mock_chat = Mock(side_effect=[{"message": {"content": "소리를 절반으로 줄였습니다."}},
|
|
{"message": {"content": "소리를 줄이지 못했습니다."}}])
|
|
turn_state.reset()
|
|
turn_state.set_user("100")
|
|
try:
|
|
with patch("src.jarvis.reply.engine.select_tools", return_value=["botBrowser"]), \
|
|
patch("src.jarvis.reply.engine.chat_with_messages", mock_chat), \
|
|
patch("src.jarvis.reply.engine.extract_text_from_response",
|
|
side_effect=lambda r: r["message"]["content"]), \
|
|
patch("src.jarvis.reply.engine.plan_query", return_value=["Reply to the user."]), \
|
|
patch("src.jarvis.memory.graph.GraphMemoryStore"), \
|
|
patch("src.jarvis.memory.graph_ops.build_warm_profile", return_value={"user": "", "directives": ""}), \
|
|
patch("src.jarvis.memory.graph_ops.format_warm_profile_block", return_value=""):
|
|
reply = run_reply_engine(db=Mock(), cfg=_mock_cfg(), tts=None, text="소리 반으로 줄여 줘",
|
|
dialogue_memory=DialogueMemory(), intent_judge=True)
|
|
finally:
|
|
turn_state.reset()
|
|
assert mock_chat.call_count == 2
|
|
sent = [m.get("content") or "" for m in mock_chat.call_args_list[-1].kwargs["messages"]]
|
|
assert any("call botBrowser" in c for c in sent), sent[-3:]
|
|
assert "줄였습니다" not in (reply or "")
|