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:
@@ -1172,6 +1172,17 @@ def prepare_intent(cfg, text: str, dialogue_memory, chat_available: bool,
|
||||
return list(routed)
|
||||
|
||||
|
||||
def prepare_done_by_user(cfg, text: str, dialogue_memory) -> Optional[bool]:
|
||||
"""The done-by-user guard's first judgement for ``text`` ahead of its reply (v2: on a partial
|
||||
transcript while the user still speaks), passed back through ``prepared_done``. Only asked when
|
||||
the guard could run (an earlier plain answer in the dialogue memory); otherwise None."""
|
||||
from .done_guard import _is_answer, said_done
|
||||
|
||||
if not any(_is_answer(m) for m in _recent_messages(cfg, dialogue_memory)):
|
||||
return None
|
||||
return said_done(cfg, redact(text))
|
||||
|
||||
|
||||
def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
text: str, dialogue_memory: "DialogueMemory",
|
||||
language: Optional[str] = None,
|
||||
@@ -1182,7 +1193,8 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
intent_judge: bool = False,
|
||||
prepared_tools: Optional[list] = None,
|
||||
person_notes: Optional[list] = None,
|
||||
left_out: Optional[list] = None) -> Optional[str]:
|
||||
left_out: Optional[list] = None,
|
||||
prepared_done: Optional[Callable[[], Optional[bool]]] = None) -> Optional[str]:
|
||||
"""
|
||||
Main entry point for reply generation.
|
||||
|
||||
@@ -1221,6 +1233,9 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
not see (the done-by-user guard's second try, reply.spec.md
|
||||
"Earlier answers after the user did it (v2)"); the guard does not run
|
||||
again.
|
||||
prepared_done: v2 only. Gives the guard's first judgement (does the
|
||||
user say they did it) that ``prepare_done_by_user`` made while the
|
||||
user was still speaking; None from it: the guard asks for itself.
|
||||
|
||||
Returns:
|
||||
Generated reply text or None
|
||||
@@ -3167,7 +3182,8 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
if history is not None and left_out is None and not tools_started:
|
||||
from .done_guard import earlier_answers, superseded
|
||||
_earlier = earlier_answers(recent_messages, history)
|
||||
if _earlier and superseded(cfg, redacted, reply):
|
||||
if _earlier and superseded(cfg, redacted, reply,
|
||||
said=prepared_done() if prepared_done is not None else None):
|
||||
debug_log(f"done-by-user guard: answering again without {len(_earlier)} earlier line(s)",
|
||||
"planning")
|
||||
return run_reply_engine(db, cfg, tts, text, dialogue_memory, language=language,
|
||||
|
||||
Reference in New Issue
Block a user