- 로그 screen: "보이는 글 txt로 저장" (logs_save_text), a 대화 view that saves the days' conversation with every trace in full (history_export), and a 목소리 view with the voice.record switch and the days' recordings as a zip with an index (voice_export). - Voice worker: with JARVIS_RECORDINGS_DIR (voice.record, off by default) each final and each spoken answer is kept as a WAV with an index line; day folders older than 7 days removed. - response.interrupt (default on): off, latest/important finish the running answer first. - Bot browser: Chrome lets pages start video and sound; botBrowser reports each page's media state, waits for a player to start after open/click, and presses play on a video page a click led to when its player stayed paused (live: a clicked YouTube video stayed paused). - webSearch reads `query` when `search_query` is missing (live: both searches of an answer failed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
3.2 KiB
Python
86 lines
3.2 KiB
Python
"""Behaviour tests for real-time search routing by live broadcast state.
|
|
|
|
Routing contract (docs/stream_browser_modes.md):
|
|
- master flag cfg.stream_browser (env STREAM_BROWSER) = broadcast capability
|
|
- context.broadcasting = live screen-share state for the turn (set by the bot)
|
|
|
|
master live(ctx) -> backend
|
|
------- --------- -------
|
|
True True on-screen Chrome (browser_search)
|
|
True False Gemini
|
|
True None Chrome (no signal -> fall back to master)
|
|
False True/None Gemini (broadcast disabled, never Chrome)
|
|
"""
|
|
|
|
from types import SimpleNamespace
|
|
|
|
import jarvis.tools.builtin.realtime_search as rs
|
|
from jarvis.tools.base import ToolContext
|
|
from jarvis.tools.builtin.web_search import WebSearchTool
|
|
|
|
|
|
def _ctx(stream_browser, broadcasting):
|
|
cfg = SimpleNamespace(
|
|
web_search_enabled=True,
|
|
stream_browser=stream_browser,
|
|
gemini_auth="oauth",
|
|
gemini_api_key="",
|
|
gemini_model="gemini-2.0-flash",
|
|
)
|
|
return ToolContext(
|
|
db=None,
|
|
cfg=cfg,
|
|
system_prompt="",
|
|
original_prompt="",
|
|
redacted_text="",
|
|
max_retries=0,
|
|
user_print=lambda *a, **k: None,
|
|
language=None,
|
|
broadcasting=broadcasting,
|
|
)
|
|
|
|
|
|
def _route(monkeypatch, stream_browser, broadcasting):
|
|
"""Run webSearch and return which backend handled it ('browser'/'gemini')."""
|
|
monkeypatch.setattr(rs, "browser_search", lambda *a, **k: "BROWSER_RESULT")
|
|
monkeypatch.setattr(rs, "gemini_cli_search", lambda *a, **k: "GEMINI_RESULT")
|
|
monkeypatch.setattr(rs, "gemini_search", lambda *a, **k: "GEMINI_RESULT")
|
|
res = WebSearchTool().run({"search_query": "현재 서울 날씨"}, _ctx(stream_browser, broadcasting))
|
|
if res.reply_text == "BROWSER_RESULT":
|
|
return "browser"
|
|
if res.reply_text == "GEMINI_RESULT":
|
|
return "gemini"
|
|
return "fallthrough"
|
|
|
|
|
|
def test_master_on_live_on_uses_browser(monkeypatch):
|
|
assert _route(monkeypatch, True, True) == "browser"
|
|
|
|
|
|
def test_master_on_live_off_uses_gemini(monkeypatch):
|
|
assert _route(monkeypatch, True, False) == "gemini"
|
|
|
|
|
|
def test_master_on_no_signal_defaults_to_browser(monkeypatch):
|
|
# None = no live signal (evals / text entry / older bot) -> behave as master
|
|
assert _route(monkeypatch, True, None) == "browser"
|
|
|
|
|
|
def test_master_off_never_uses_browser_even_if_live(monkeypatch):
|
|
# STREAM_BROWSER=false disables broadcast entirely: always Gemini.
|
|
assert _route(monkeypatch, False, True) == "gemini"
|
|
|
|
|
|
def test_master_off_no_signal_uses_gemini(monkeypatch):
|
|
assert _route(monkeypatch, False, None) == "gemini"
|
|
|
|
|
|
def test_a_query_given_as_query_instead_of_search_query_still_searches(monkeypatch):
|
|
# Live 2026-11-16: the planner wrote "webSearch query='...'" and the model passed `query`;
|
|
# both searches failed with "Please provide a search query".
|
|
seen = []
|
|
monkeypatch.setattr(rs, "gemini_cli_search", lambda q, *a, **k: seen.append(q) or "GEMINI_RESULT")
|
|
monkeypatch.setattr(rs, "gemini_search", lambda q, *a, **k: seen.append(q) or "GEMINI_RESULT")
|
|
res = WebSearchTool().run({"query": "안강 산책 코스"}, _ctx(False, None))
|
|
assert res.reply_text == "GEMINI_RESULT" and seen[:1] == ["안강 산책 코스"]
|