fix(brain): botBrowser keeps a tab per person, one deadline, and never repeats an action

- each asker has a tab and connection of their own (at most 5, least recently used closes first)
- links, forms and window.open that would open a new tab load in the same tab
- one 15 s deadline covers connecting, the action and the page; events do not extend it
- a broken connection retries only open and read; click, type and back may have run and are not repeated
- <<< and >>> in page content are replaced so it cannot close the fence
- the description says how to search on a site (open, then type with submit=true); eval case 0/3 -> 3/3 on qwen3:8b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-13 22:33:00 +09:00
parent 077db5031c
commit 56212c06dc
5 changed files with 249 additions and 54 deletions

View File

@@ -63,8 +63,8 @@ def _run(monkeypatch, mock_config, eval_db, eval_dialogue_memory, query):
session = FakeSession()
monkeypatch.setenv("JARVIS_BROWSER_CDP", "http://127.0.0.1:9")
monkeypatch.setattr(bot_browser, "session_factory", lambda url: session)
monkeypatch.setattr(bot_browser, "_session", None)
monkeypatch.setattr(bot_browser, "session_factory", lambda url, deadline: session)
monkeypatch.setattr(bot_browser, "_sessions", {})
mock_config.ollama_base_url = JUDGE_BASE_URL
mock_config.ollama_chat_model = JUDGE_MODEL
mock_config.stream_browser = False
@@ -87,7 +87,7 @@ class TestBotBrowserTool:
def test_searching_on_a_site_uses_the_browser(self, monkeypatch, mock_config, eval_db, eval_dialogue_memory):
s, _ = _run(monkeypatch, mock_config, eval_db, eval_dialogue_memory, "유튜브 열어서 로파이 음악 검색해 줘")
opened = any(c[0] == "open" and "youtube" in c[1].lower() for c in s.calls)
typed = any(c[0] == "type" and "로파이" in c[1] for c in s.calls)
typed = any(c[0] == "type" and "로파이" in c[1] and c[3] for c in s.calls) # typed and sent
searched_by_url = any(c[0] == "open" and "youtube" in c[1].lower() and "search" in c[1].lower() for c in s.calls)
assert opened and (typed or searched_by_url), s.calls