feat(voice_worker): the v2 brain answers in Korean unless asked for another language

The brain passes default_language (worker --reply-language, default Korean) to
the reply engine; unlike the output_language lock it gives way when the user
explicitly asks for a language. Tools get the ko code (--tool-language).

Eval evals/test_reply_language_default.py (Qwen3.6 on Strata): 6/6, English
questions answered in Korean, an explicit English request in English, and the
control without the default answers English in English.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 10:34:12 +09:00
parent cefe9b9253
commit 7623d6d002
9 changed files with 170 additions and 25 deletions

View File

@@ -981,7 +981,8 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
text: str, dialogue_memory: "DialogueMemory",
language: Optional[str] = None,
history: Optional[Any] = None,
legacy_memory: bool = True) -> Optional[str]:
legacy_memory: bool = True,
default_language: Optional[str] = None) -> Optional[str]:
"""
Main entry point for reply generation.
@@ -1004,6 +1005,9 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
enrichment) belongs to a single user. False skips all of it, for
the v2 brain where several people share one assistant and only
the scoped ``history`` may reach the prompt.
default_language: v2 only. The language to reply in unless the user
explicitly asks for another one (e.g. "Korean"). An
``output_language`` lock still wins. None: the user's language.
Returns:
Generated reply text or None
@@ -1713,7 +1717,7 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
# _resolve_output_language). Building the persona from the raw env var while
# the directive used the config value made the two contradict each other.
_output_language = _resolve_output_language()
_persona_prompt = build_system_prompt(_assistant_name, _output_language)
_persona_prompt = build_system_prompt(_assistant_name, _output_language, default_language)
# File-based operator instructions: every *.md in AGENTS_DIR (default
# /app/agents, bind-mounted from ./agents). Read once per turn so edits in
# the folder apply on the next reply without a restart; fail-open to "".
@@ -1738,6 +1742,7 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
_lang_directive = reply_language_directive(
_output_language,
getattr(cfg, "tts_engine", "piper"),
default_language,
)
if _lang_directive:
guidance.insert(1, _lang_directive)