perf(voice): ask the done-by-user question while the user still speaks
The done-by-user guard asked its first yes/no question after every follow-up answer was made, adding a short LLM call (~0.4 s) before Jarvis spoke. The question depends only on the user's words, so the voice worker's prepare now asks it on the partial transcript after the tool pick (prepare_done_by_user, follow-up turns only) and the guard uses that judgement (prepared_done), asking only whether the answer refuses when the user said they did it. Without a prepared judgement, or when it failed, the guard asks for itself as before. The reply does not wait for the judgement, only the guard does. Measured on Qwen3.6 through the game PC's Strata, 12 pairs of short follow-up questions in alternating order: brain time median 1.06 s before, 0.69 s after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,9 +62,15 @@ def earlier_answers(recent_messages: Iterable[dict], history: Any) -> list[str]:
|
||||
return answers + [x for x in getattr(history, "answers", None) or [] if x in shown]
|
||||
|
||||
|
||||
def superseded(cfg, text: str, reply: str, timeout_sec: float = 5.0) -> bool:
|
||||
def said_done(cfg, text: str, timeout_sec: float = 5.0) -> Optional[bool]:
|
||||
"""Does the user say they themselves already did something? None: no usable judgement."""
|
||||
return _yes_no(cfg, _DONE_PROMPT, f"<utterance>{text}</utterance>", "user says done", timeout_sec)
|
||||
|
||||
|
||||
def superseded(cfg, text: str, reply: str, timeout_sec: float = 5.0, said: Optional[bool] = None) -> bool:
|
||||
"""True when the user says they did something themselves and ``reply`` still says something
|
||||
cannot be done. No usable judgement is False (the answer is kept)."""
|
||||
if not _yes_no(cfg, _DONE_PROMPT, f"<utterance>{text}</utterance>", "user says done", timeout_sec):
|
||||
cannot be done. ``said``: that first judgement when it was already made (the prepare stage);
|
||||
None asks for it. No usable judgement is False (the answer is kept)."""
|
||||
if not (said if said is not None else said_done(cfg, text, timeout_sec)):
|
||||
return False
|
||||
return bool(_yes_no(cfg, _REFUSES_PROMPT, f"<reply>{reply}</reply>", "reply refuses", timeout_sec))
|
||||
|
||||
Reference in New Issue
Block a user