fix: stopped sentences recorded only as far as heard, search words as plain query, paused video said so
- Playback sends how long the clip playing when a request was stopped had played (tts_played last_ms); the worker cuts the last sentence of that recording to it. - botBrowser open takes the search words as plain `query`: the tool puts them, encoded, into the address's empty search parameter or types them into the site's search box. The description tells the model to search this way and never put words into an address itself (live: 아이유 hand-encoded into 아이우). Eval (qwen3:8b, 3 runs): right words reach YouTube 1/3 -> 3/3. - When a page's main video does not play (also after the tool pressed play, or it failed to load), a note after the page says it is not playing and not to say it plays. Eval: a paused video reported as playing 1/3 -> 0/3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -139,6 +139,31 @@ def test_the_state_of_sound_and_video_on_the_page_is_reported_and_absent_without
|
||||
assert "Media:" not in BotBrowserTool().run({"action": "read"}, ctx()).reply_text
|
||||
|
||||
|
||||
def test_search_words_given_as_query_are_encoded_by_the_tool_not_the_model(fake):
|
||||
t = BotBrowserTool()
|
||||
# An address ending in an empty search parameter: the words go into it, encoded by the tool.
|
||||
t.run({"action": "open", "url": "https://www.youtube.com/results?search_query=", "query": "아이유 신곡"}, ctx())
|
||||
assert fake.calls[-1] == ("open", "https://www.youtube.com/results?search_query="
|
||||
"%EC%95%84%EC%9D%B4%EC%9C%A0+%EC%8B%A0%EA%B3%A1")
|
||||
assert urllib.parse.unquote_plus(fake.calls[-1][1]).endswith("아이유 신곡")
|
||||
# Just the site: it opens, and the words are typed into its search box and sent.
|
||||
fake.calls.clear()
|
||||
t.run({"action": "open", "url": "youtube.com", "query": "아이유 신곡"}, ctx())
|
||||
assert fake.calls == [("open", "https://youtube.com"), ("type", "아이유 신곡", None, True)]
|
||||
|
||||
|
||||
def test_a_page_whose_main_video_is_not_playing_says_so_outside_the_page_text(fake):
|
||||
fake.page = dict(fake.page, media=[{"playing": False, "time": 0.0, "duration": 225.0, "muted": False, "main": True}])
|
||||
r = BotBrowserTool().run({"action": "open", "url": "https://www.youtube.com/watch?v=x"}, ctx())
|
||||
after = r.reply_text[r.reply_text.index(bot_browser.FENCE_END):]
|
||||
assert "not playing" in after
|
||||
fake.page["media"][0]["playing"] = True
|
||||
assert "not playing" not in BotBrowserTool().run({"action": "read"}, ctx()).reply_text
|
||||
# Sound that is not the page's main player says nothing more than its Media line.
|
||||
fake.page["media"] = [{"playing": False, "time": 0.0, "duration": 5.0, "muted": False, "main": False}]
|
||||
assert "not playing" not in BotBrowserTool().run({"action": "read"}, ctx()).reply_text
|
||||
|
||||
|
||||
def test_actions_pass_their_arguments(fake):
|
||||
t = BotBrowserTool()
|
||||
t.run({"action": "click", "target": "[2]"}, ctx())
|
||||
@@ -275,6 +300,9 @@ PAGES = {
|
||||
"/results": "<html><head><title>Results</title></head><body><a href='/watch'>The song</a></body></html>",
|
||||
"/watch": "<html><head><title>Watch</title></head><body>"
|
||||
"<video src='/tone.wav' style='width:90vw;height:300px'></video></body></html>",
|
||||
# A video page whose player cannot play (its file is missing).
|
||||
"/broken": "<html><head><title>Broken</title></head><body>"
|
||||
"<video src='/missing.mp4' style='width:90vw;height:300px'></video></body></html>",
|
||||
}
|
||||
|
||||
|
||||
@@ -390,6 +418,11 @@ def test_a_video_page_whose_player_stays_paused_gets_play_pressed_when_clicked_t
|
||||
# Sound that is not the page's main player (an audio element, no big video) is left as it is.
|
||||
page = s.open(site + "/button")
|
||||
assert [m["playing"] for m in page["media"]] == [False]
|
||||
# A player that cannot start, even after play was pressed: the answer says it is not playing.
|
||||
s.deadline = time.monotonic() + 15 # the tool gives each action its own deadline
|
||||
page = s.open(site + "/broken")
|
||||
assert [(m["playing"], m["main"]) for m in page["media"]] == [(False, True)]
|
||||
assert "not playing" in bot_browser._render(page)
|
||||
|
||||
|
||||
def test_links_that_would_open_a_new_tab_open_in_the_same_tab(chrome):
|
||||
|
||||
Reference in New Issue
Block a user