fix(v2): YouTube no longer stops 45 s in, consent and the bot's video keep their tools
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>
This commit is contained in:
@@ -1467,6 +1467,22 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
and not _starts_with_text_tools(cfg) else None
|
||||
)
|
||||
|
||||
# Waiting tools (v2): a tool still holding something for the asker stays on offer, since the
|
||||
# message that answers it names no tool. pcControl with a request asked in their previous
|
||||
# reply ("네." to "계산기를 실행해도 될까요?"), botBrowser with the page it opened for them
|
||||
# ("소리 줄여 줘" while their video plays). Live 2026-11-18 the router left both out: the
|
||||
# consent was refused, and the volume went to the person's own browser window. Added after the
|
||||
# gates above, so a turn the router gave no tool (thanks, small talk) still skips the planner.
|
||||
from .turn_state import get_user as _get_user
|
||||
from ..tools.builtin import bot_browser as _bot_browser, pc_control as _pc_control
|
||||
_held_tools = [n for n, held in (("pcControl", lambda: _pc_control.awaits_answer(_get_pc())),
|
||||
("botBrowser", lambda: _bot_browser.has_page(str(_get_user() or ""))))
|
||||
if n in _full_catalog_names and held()]
|
||||
_waiting = [n for n in _held_tools if n not in routed_tools]
|
||||
if _waiting:
|
||||
routed_tools = routed_tools + _waiting
|
||||
debug_log(f"waiting tools kept on offer: {_waiting}", "planning")
|
||||
|
||||
# In screen-share mode, always offer setBroadcast. "Turn the broadcast
|
||||
# on/off" is language-agnostic intent the embedding/keyword router won't
|
||||
# reliably surface for a non-English utterance (e.g. "방송 꺼줘"), so the
|
||||
@@ -1537,6 +1553,14 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
f"planner produced {len(action_plan)} step(s)", "planning"
|
||||
)
|
||||
|
||||
# Waiting tools, continued: the router saw a need for a tool, the planner planned none, and a
|
||||
# tool holds something for the asker. An answer without calling it is a guess ("소리를 절반으로
|
||||
# 줄였습니다" with nothing done: eval 0/6), so the turn gets the one-step nudge for that tool.
|
||||
if (_one_step_tool is None and intent_judge and _turn_needs_tools and _held_tools
|
||||
and not named_tool_steps(action_plan, [n for n in routed_tools if n not in ("stop", "toolSearchTool")])):
|
||||
_one_step_tool = _held_tools[0]
|
||||
debug_log(f"waiting tool {_one_step_tool}: no planned step, nudge if skipped", "planning")
|
||||
|
||||
# Gating decisions derived from the plan.
|
||||
# - Empty plan → fail-open: behave like before (memory + router).
|
||||
# - Plan with `searchMemory` directive → run memory enrichment.
|
||||
|
||||
@@ -137,7 +137,8 @@ Design principles enforced by the engine:
|
||||
Compensates for small routers that misroute follow-ups where the user is supplying the missing info (field trace 2026-05-03: turn 1 invoked `getWeather` with no location configured, the tool returned `success=False`, the assistant relayed the request, turn 2 was "I'm in London", router picked `webSearch`, planner web-searched "weather in london tomorrow", Wikipedia fallback returned "Edge of Tomorrow" and the assistant parroted the film summary as the weather answer). A successful chain followed by a genuine new short ask ("log my breakfast") correctly does NOT carry over the prior tool — its `tool_failed=False` flag short-circuits the walker.
|
||||
The walker stops at the first genuine user message, walks both calling protocols (native: `assistant.tool_calls[*].function.name` matched to `role=tool` results by `tool_call_id`; text-tool fallback: `role=user` messages tagged with `tool_name`), and only collects names whose matching tool result message has `tool_failed=True`. The augmentation is an engine-side per-turn overlay: the router cache stores only the raw router output, so identical-query replays in future turns are unaffected. When carry-over fires, `_selection_source` becomes `<strategy>+carryover` (or `<strategy>+plan+carryover`) so the printed `🔧 Tools` log line stays honest.
|
||||
The flag distinguishes only success vs failure, not failure mode (argument issue vs network vs anything else); the user is most likely to follow up with a correction either way, and the chat model can still pick a different tool from the widened list. Edge cases: an MCP tool unloaded between turns is filtered out by the `_full_catalog_names` membership check (so a stale name never leaks into the schema). A tool turn evicted from `DialogueMemory._tool_turns` by the storage cap (`_tool_turns_max_storage`, default 16) loses its carry-over protection — acceptable because active sessions rarely accumulate 16 tool turns before reaching the recent-window boundary, and the chat model can still call `toolSearchTool` to re-widen mid-loop. Orphan assistant `tool_calls` (no matching `role=tool` result in the recent window — possible after truncation or scrub) are ignored and logged via `debug_log` so upstream data loss is diagnosable rather than silent.
|
||||
- The per-turn allow-list exposed to the chat model is: `<plan or router picks>` + `<previous-turn carry-over (if any)>` + `stop` (the sentinel) + `toolSearchTool`.
|
||||
- **Waiting tools** (v2): a tool still holding something for the asker is unioned into the allow-list after the carry-over, since the message that answers it names no tool: `pcControl` while a request asked in the asker's previous reply waits for this message (`pc_control.awaits_answer`, the consent turn: "네." to "계산기를 실행해도 될까요?"), and `botBrowser` while the bot browser holds the page it opened for the asker (`bot_browser.has_page`, "소리 줄여 줘" while their video plays). Only tools in the catalogue; an engine-side per-turn overlay like the carry-over (the router cache is untouched); logged as `waiting tools kept on offer`. They are added after the intent judge's gates, so a turn the router gave no tool (thanks, small talk) still skips the planner. When the router did give the turn a tool, the planner planned no tool step and a tool holds something for the asker, the turn gets the one-step nudge for that tool (an answer without calling it is asked once to call it first): the planner cannot see what the tool holds, and the model said "소리를 절반으로 줄였습니다" with nothing done (eval `evals/test_bot_browser_tool.py`, volume case: 0/6 before the nudge, 8/8 after; before the volume action and the waiting tools 0/3, reading the person's own windows and saying it cannot). Live 2026-11-18 (0.1.40): the router left both out, so the consent call was refused ("no tool can start the calculator") and the volume request went to the person's own browser window.
|
||||
- The per-turn allow-list exposed to the chat model is: `<plan or router picks>` + `<previous-turn carry-over (if any)>` + `<waiting tools (if any)>` + `stop` (the sentinel) + `toolSearchTool`.
|
||||
- `toolSearchTool` wraps the same routing logic (`select_tools`) but is invokable mid-loop. It takes a refined natural-language description of what the model is trying to accomplish and returns the expanded set of candidate tools. When invoked, the returned tools are merged into the allow-list for subsequent turns (still plus `stop` and `toolSearchTool` itself). This gives the agent a single-shot escape hatch when the initial routing was too narrow without widening the allow-list to "everything" by default.
|
||||
- `toolSearchTool` is a builtin; see `src/jarvis/tools/builtin/tool_search.spec.md`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user