feat(voice_worker): a short voice prompt and one judgement before each v2 answer

- compact_prompt: the v2 persona in a tenth of v1's words, answers as short as
  possible, the full tool guidance only on turns with a data tool. A greeting's
  reply prompt went from about 4,500 to 1,400 tokens on Strata.
- intent_judge: the tool router judges whether the turn needs tools; the
  planner runs only when it does. prepare_intent runs the pick ahead on a
  partial transcript (worker message prepare), and the reply reuses it.
- Without stream_browser the screen-share tools are not offered.
- The time context carries the 12-hour form (10:37 was read as pm).
- A <tool_call> block written as the reply is parsed as a call, not spoken.

Evals (Qwen3.6 on Strata, EVAL_COMPACT_PROMPT=1 EVAL_INTENT_JUDGE=1):
221 passed, 4 failed (known failures); new evals/test_voice_reply_length.py
(v2 answers 234 chars against v1's 416) and test_reply_language_default.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 12:25:15 +09:00
parent 7623d6d002
commit 46e4e75d05
13 changed files with 721 additions and 44 deletions

View File

@@ -157,6 +157,57 @@ _SYSTEM_PROMPT_TEMPLATE: str = (
)
# The v2 voice persona (voice_worker.spec.md, "History and brain"): the same butler in a tenth of
# the words. v1's persona spends most of its length on the single-user long-term memory (profile,
# diary, graph) and on the on-screen browser, neither of which the v2 brain has; Strata reads every
# prompt from the start, so each dropped token is latency saved on every reply. The user asked for
# answers as short as possible (2026-11-12): the aside is optional and only when nearly free.
_VOICE_PERSONA_TEMPLATE: str = (
"You are {name}, the voice assistant in a group voice chat, with the manner of a composed, "
"polite butler and a dry sense of humour. "
"Keep every reply as short as it can be while still answering well: exactly one short "
"sentence that gives the answer first, with no second sentence even for a remark or advice "
"(join them into the one sentence or drop one). No preamble, no repeating the question, no "
"follow-up offers, no lists. Meet small talk in kind, warmly and briefly. When asked for a "
"joke, a story or just something to say, give a short fresh one in that sentence; never "
"refuse it or call it beyond you. "
"A dry touch is welcome only when it costs almost no words; never for serious topics (errors, "
"money, health, feelings, anything urgent). "
"Never be mean, condescending or sycophantic ('great question'), never call the user 'sir' or "
"'madam', and never answer with a bare greeting: engage with what was actually said. "
"Your reply is spoken aloud by text-to-speech: plain words only, no markdown, emoji or code. "
"{tool_rules} "
"The [Context: ...] line at the top holds the real current time and location: answer time and "
"date questions from it, phrased naturally in the user's language; never say you lack a clock. "
"When 'Information shared in previous conversations' is present it is your memory of earlier "
"conversations: what was said there is not a live fact and needs no tool, so answer questions "
"about it from that section directly, and never say you cannot check or remember it."
)
def build_voice_persona(
assistant_name: str = "Jarvis", output_language: Optional[str] = None,
default_language: Optional[str] = None,
) -> str:
"""The short v2 voice persona; language handling as in ``build_system_prompt``."""
name = (assistant_name or "Jarvis").strip() or "Jarvis"
prompt = _VOICE_PERSONA_TEMPLATE.format(name=name, tool_rules=TOOL_HONESTY_RULES)
lang = (output_language or "").strip()
if lang:
prompt = prompt.replace("in the user's language", f"in {lang}")
elif (default_language or "").strip():
prompt = prompt.replace("in the user's language", "in the reply language")
return prompt
# Compact prompts, turns where no data tool was routed: what the tool guidance says about acting
# instead of refusing, in one line (the full guidance is only for turns with data tools).
COMPACT_ACTION_RULE: str = (
"If the user asks for an action or for live information that your tools here do not cover, "
"call toolSearchTool with a short description of it before saying you cannot."
)
def tool_honesty_reminder(tool_names) -> str:
"""End-of-prompt restatement of the tool honesty rules for this turn.