Skip to content

The agent that grows with you

feat(voice): auxiliary.voice_chat routes spoken voice turns to their own model

Teknium6cc1efd8f90f
diff --git a/agent/conversation_loop.py b/agent/conversation_loop.py
index d88600832e5..5e48e3c9e55 100644
--- a/agent/conversation_loop.py
+++ b/agent/conversation_loop.py
@@ -1596,6 +1596,10 @@ def _run_conversation_turn(
)
except PreflightCompressionTimedOut as _preflight_timeout_exc:
return _preflight_timeout_result(agent, _preflight_timeout_exc, conversation_history)
+ # Voice turns may run on auxiliary.voice_chat: bound after the prompt/row/compaction were settled
+ # against the main model, undone in finalize_turn (and run_conversation's finally on early exits).
+ from agent.voice_turn_route import begin_voice_turn_route
+ _ctx.active_system_prompt = begin_voice_turn_route(agent, _ctx.messages, _ctx.active_system_prompt)
# Per-turn agent state (the gateway caches agents across turns, so none of this may
# leak into the next message): interim-commentary dedup spans the whole turn but not
@@ -1716,27 +1720,31 @@ def run_conversation(
addresses, after every history rewrite including post-turn micro-compaction.
"""
from agent.turn_context import export_current_turn_boundary
+ from agent.voice_turn_route import end_voice_turn_route
from tools.vision_tools_history_budget import native_turn_images
# Images attached natively to this user turn stay visible to vision_analyze for the turn, so
# it does not embed the same pixels a second time into the same request (#76411).
with native_turn_images(user_message):
- result = _run_conversation_turn(
- agent,
- user_message,
- system_message=system_message,
- conversation_history=conversation_history,
- task_id=task_id,
- stream_callback=stream_callback,
- persist_user_message=persist_user_message,
- persist_user_timestamp=persist_user_timestamp,
- persist_user_display_kind=persist_user_display_kind,
- persist_user_display_metadata=persist_user_display_metadata,
- persist_user_platform_id=persist_user_platform_id,
- moa_config=moa_config,
- turn_author=turn_author,
- title_user_message=title_user_message,
- )
+ try:
+ result = _run_conversation_turn(
+ agent,
+ user_message,
+ system_message=system_message,
+ conversation_history=conversation_history,
+ task_id=task_id,
+ stream_callback=stream_callback,
+ persist_user_message=persist_user_message,
+ persist_user_timestamp=persist_user_timestamp,
+ persist_user_display_kind=persist_user_display_kind,
+ persist_user_display_metadata=persist_user_display_metadata,
+ persist_user_platform_id=persist_user_platform_id,
+ moa_config=moa_config,
+ turn_author=turn_author,
+ title_user_message=title_user_message,
+ )
+ finally:
+ end_voice_turn_route(agent)
result = export_current_turn_boundary(agent, result, user_message)
_close_durable_failed_turn(agent, result)
return result
diff --git a/agent/route_binding.py b/agent/route_binding.py
index b77b251fbee..417114f8126 100644
--- a/agent/route_binding.py
+++ b/agent/route_binding.py
@@ -50,7 +50,7 @@ def bind_route_entry(agent: Any, entry: Dict[str, Any], provider: str, model: st
try:
from hermes_cli.model_normalize import normalize_model_for_provider
model = normalize_model_for_provider(model, provider)
- except Exception as norm_err:
+ except Exception as norm_err: # health: allow BLE001 -- moved verbatim from try_activate_fallback; a bad catalog entry keeps the raw id
logger.warning("Could not normalize fallback model %r for provider %r: %s", model, provider, norm_err)
base_url = str(client.base_url)
from hermes_cli.providers import is_actual_route
diff --git a/agent/turn_finalizer.py b/agent/turn_finalizer.py
index efd5e532795..076742ce7a1 100644
--- a/agent/turn_finalizer.py
+++ b/agent/turn_finalizer.py
@@ -751,6 +751,11 @@ def finalize_turn(
agent.clear_interrupt()
agent._stream_callback = None # don't leak into future calls
+ # A voice turn's model route ends with the turn: memory sync and the background review
+ # below (and the next turn) run on the session's main model.
+ from agent.voice_turn_route import end_voice_turn_route
+ end_voice_turn_route(agent)
+
# Skill trigger is checked NOW — based on how many tool iterations THIS turn used.
_should_review_skills = (
agent._skill_nudge_interval > 0
diff --git a/agent/turn_usage.py b/agent/turn_usage.py
index 7deaa9f1df4..7c4fb537e54 100644
--- a/agent/turn_usage.py
+++ b/agent/turn_usage.py
@@ -271,6 +271,7 @@ def record_response_usage(
if cost_result.status == "included" else None,
model=agent.model,
api_call_count=1,
+ task=getattr(agent, "_turn_route_task", "") or "",
)
except Exception as e: # silent loss here undercounts analytics
logger.debug(
diff --git a/agent/voice_turn_route.py b/agent/voice_turn_route.py
new file mode 100644
index 00000000000..3374c02f494
--- /dev/null
+++ b/agent/voice_turn_route.py
@@ -0,0 +1,149 @@
+"""Per-turn model route for voice chat: ``auxiliary.voice_chat``.
+
+A voice turn (CLI voice input, a Desktop/TUI voice conversation, a messaging voice note) can run
+on a faster model than the session's main one. The route binds at the end of turn setup, after the
+system prompt and session row were built for the main model and after preflight compression
+judged the history against the main model's window, and is undone before post-turn work (memory
+sync, background review) so nothing outside the turn sees it. A turn whose request would not fit
+under the voice model's compression threshold at turn start runs on the main model instead, so
+switching to voice never compacts the conversation to suit a smaller model.
+
+Surfaces mark the next turn with ``agent._voice_turn_pending = True``; it is consumed here. GPT-Live
+delegations are not voice turns in this sense: the live model already owns the voice layer and
+delegates real work to the session's model.
+"""
+
+from __future__ import annotations
+
+import copy
+import logging
+from typing import Any, Dict, List, Optional
+
+logger = logging.getLogger(__name__)
+
+TASK = "voice_chat"
+
+# Agent fields the route swap touches outside the ``_primary_runtime``-shaped snapshot.
+_EXTRA_FIELDS = (
+ "_fallback_activated", "_fallback_index", "_provider_fallback_active", "_provider_fallback_route",
+ "_rate_limit_backoff_count", "_credential_pool", "_credential_pool_entry_id", "_config_context_length",
+)
+
+
+def _route_target(agent: Any, cfg: Dict[str, Any]) -> Optional[Dict[str, Any]]:
+ """The entry to bind, or None when the slot follows the main model (``auto`` + no model)."""
+ provider = str(cfg.get("provider") or "").strip().lower()
+ model = str(cfg.get("model") or "").strip()
+ base_url = str(cfg.get("base_url") or "").strip()
+ if provider in ("", "auto", "main"):
+ if base_url:
+ provider = "custom"
+ elif model:
+ provider = str(getattr(agent, "provider", "") or "").strip().lower()
+ else:
+ return None
+ if not model:
+ # Provider pinned without a model: that provider's fast auxiliary model.
+ from agent.auxiliary_client import _get_aux_model_for_provider
+ model = _get_aux_model_for_provider(provider, prefer_fast=True) or ""
+ if not (provider and model):
+ return None
+ if not base_url and provider == str(agent.provider or "").lower() and model == agent.model:
+ return None
+ # ``provider: openai`` means the user's OpenAI endpoint, as on every other auxiliary task.
+ from hermes_cli.runtime_provider_custom import expand_direct_api_alias
+ provider, base_url = expand_direct_api_alias(provider, base_url or None)
+ return {**cfg, "provider": provider, "model": model, "base_url": base_url or ""}
+
+
+def _fits(agent: Any, messages: List[Dict[str, Any]], system_prompt: str) -> bool:
+ from agent.model_metadata import estimate_request_tokens_rough
+ limit = getattr(getattr(agent, "context_compressor", None), "threshold_tokens", 0) or 0
+ if not limit:
+ return True
+ tokens = estimate_request_tokens_rough(
+ messages, system_prompt=system_prompt or "", tools=getattr(agent, "tools", None) or None)
+ return tokens < limit
+
+
+def _capture(agent: Any) -> Dict[str, Any]:
+ from agent.agent_runtime_helpers import _build_primary_runtime_snapshot
+ return {
+ "snapshot": _build_primary_runtime_snapshot(agent, agent.api_mode),
+ **{name: getattr(agent, name, None) for name in _EXTRA_FIELDS},
+ }
+
+
+def _reinstall(agent: Any, state: Dict[str, Any]) -> None:
+ from agent.route_binding import reinstall_runtime_snapshot
+ reinstall_runtime_snapshot(agent, state["snapshot"])
+ for name in _EXTRA_FIELDS:
+ setattr(agent, name, state[name])
+
+
+def _warn_once(agent: Any, target: Dict[str, Any], reason: str) -> None:
+ logger.warning("auxiliary.%s route %s/%s not used: %s; the voice turn runs on %s/%s",
+ TASK, target["provider"], target["model"], reason, agent.provider, agent.model)
+ if getattr(agent, "_warned_voice_route", False):
+ return
+ agent._warned_voice_route = True
+ emit = getattr(agent, "_emit_warning", None)
+ if callable(emit):
+ emit(f"⚠ Voice chat model {target['model']} via {target['provider']} unavailable ({reason}); "
+ f"using {agent.model}.")
+
+
+def begin_voice_turn_route(agent: Any, messages: List[Dict[str, Any]], system_prompt: Any) -> Any:
+ """Bind the voice route for a marked turn; returns the system prompt the turn should send."""
+ if not getattr(agent, "_voice_turn_pending", False):
+ return system_prompt
+ agent._voice_turn_pending = False
+ from agent.auxiliary_task_config import _get_auxiliary_task_config
+ from hermes_constants import parse_reasoning_effort
+ cfg = _get_auxiliary_task_config(TASK)
+ effort = parse_reasoning_effort(cfg.get("reasoning_effort"))
+ target = _route_target(agent, cfg)
+ if target is None and effort is None:
+ return system_prompt
+ state: Dict[str, Any] = {"reasoning_config": copy.deepcopy(getattr(agent, "reasoning_config", None))}
+ agent._voice_route_state = state
+ if target is not None:
+ state.update(_capture(agent))
+ reason = ""
+ try:
+ from agent.route_binding import bind_route_entry
+ if bind_route_entry(agent, target, target["provider"], target["model"]) is None:
+ reason = "provider not configured"
+ except Exception as exc: # health: allow BLE001 -- any bind failure falls back to the main model with a notice
+ reason = str(exc).splitlines()[0] if str(exc) else type(exc).__name__
+ if not reason and not _fits(agent, messages, system_prompt):
+ reason = "the conversation is larger than its context window"
+ if reason:
+ _reinstall(agent, state)
+ _warn_once(agent, target, reason)
+ agent._voice_route_state = {"reasoning_config": state["reasoning_config"]}
+ return agent._cached_system_prompt or system_prompt
+ from agent.chat_completion_helpers import rewrite_prompt_model_identity
+ rewrite_prompt_model_identity(agent, agent.model, agent.provider)
+ agent._turn_route_task = TASK
+ logger.info("Voice turn routed to %s (%s)", agent.model, agent.provider)
+ if effort is not None:
+ agent.reasoning_config = effort
+ return agent._cached_system_prompt or system_prompt
+
+
+def end_voice_turn_route(agent: Any) -> None:
+ """Undo ``begin_voice_turn_route`` (idempotent; every turn exit calls it)."""
+ state = getattr(agent, "_voice_route_state", None)
+ if not state:
+ return
+ agent._voice_route_state = None
+ agent._turn_route_task = ""
+ try:
+ if "snapshot" in state:
+ _reinstall(agent, state)
+ except Exception:
+ logger.warning("Voice turn route restore failed; the next turn re-resolves the main runtime",
+ exc_info=True)
+ agent._fallback_activated = True # restore_primary_runtime takes it from here
+ agent.reasoning_config = state["reasoning_config"]
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.test.tsx
index d7697550561..7dbf0bbd6b9 100644
--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.test.tsx
+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.test.tsx
@@ -149,7 +149,7 @@ describe('useComposerVoice voice submission', () => {
hook.rerender({ busy: false })
await act(async () => retainedSubmit('change direction'))
- expect(mocks.onSubmit).toHaveBeenCalledWith('change direction')
+ expect(mocks.onSubmit).toHaveBeenCalledWith('change direction', { voiceTurn: true })
expect(mocks.clearDraft).toHaveBeenCalledTimes(1)
expect(mocks.resetBrowseState).toHaveBeenCalledWith('session-1')
expect(mocks.triggerHaptic).toHaveBeenCalledWith('submit')
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
index c1e96773ba1..ce44bd63e2c 100644
--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
@@ -178,7 +178,7 @@ export function useComposerVoice({
triggerHaptic('submit')
resetBrowseState(sessionId)
clearDraft()
- await onSubmit(text)
+ await onSubmit(text, { voiceTurn: true })
}
/** A GPT-Live delegation → Hermes turn. The bubble and the persisted row are
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
index 3a579344e58..a80ef647843 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
@@ -900,6 +900,7 @@ export function useSubmitPrompt(deps: SubmitPromptDeps) {
// will be spoken by the voice model. Wins over HUD for this turn.
...(options?.surface && { surface: options.surface }),
...(options?.surface && options.voiceContext && { voice_context: options.voiceContext }),
+ ...(options?.voiceTurn && { voice_turn: true }),
// A queue drain is a "run after" message, never a live-turn
// correction. The flag tells the gateway's busy path to hold it for
// the next turn untouched — without it, losing the settle race
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.ts
index a6b97ee7970..ffff70f40f8 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.ts
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.ts
@@ -731,6 +731,9 @@ export interface SubmitTextOptions {
/** With `surface: 'voice-live'`: the recent spoken exchange, appended to the
* model-bound note by the gateway (never persisted, never rendered). */
voiceContext?: string
+ /** A spoken turn from the chained voice conversation: the gateway runs it on
+ * `auxiliary.voice_chat` (the session model when that slot is on auto). */
+ voiceTurn?: boolean
fromQueue?: boolean
/** Called once with the EXACT session identity the backend accepted the
* prompt into — the live runtime id after any stale-runtime recovery, plus
diff --git a/apps/desktop/src/app/settings/aux-task-rows.tsx b/apps/desktop/src/app/settings/aux-task-rows.tsx
index b2c1a0f4a8c..195f8342863 100644
--- a/apps/desktop/src/app/settings/aux-task-rows.tsx
+++ b/apps/desktop/src/app/settings/aux-task-rows.tsx
@@ -28,6 +28,7 @@ const AUX_TASKS: readonly AuxTaskMeta[] = [
{ key: 'mcp' },
{ key: 'title_generation' },
{ key: 'review' },
+ { key: 'voice_chat' },
// Same three canonical slots the backend serves but the list below used to
// omit (#97297): triage_specifier, kanban_decomposer, profile_describer.
{ key: 'triage_specifier' },
diff --git a/apps/desktop/src/i18n/ar_settings.ts b/apps/desktop/src/i18n/ar_settings.ts
index abebc3dbc9d..bf9a44184dc 100644
--- a/apps/desktop/src/i18n/ar_settings.ts
+++ b/apps/desktop/src/i18n/ar_settings.ts
@@ -776,6 +776,7 @@ export const arSettings = {
label: 'المراجعة',
hint: 'وكيل المراجعة الفرعي /review'
},
+ voice_chat: { label: 'دردشة صوتية', hint: 'ردود الوضع الصوتي' },
triage_specifier: {
label: 'محدد الفرز',
hint: 'توضيح مواصفات كانبان'
diff --git a/apps/desktop/src/i18n/de_aux_tasks.ts b/apps/desktop/src/i18n/de_aux_tasks.ts
index ae3a737359c..884c2d05cdb 100644
--- a/apps/desktop/src/i18n/de_aux_tasks.ts
+++ b/apps/desktop/src/i18n/de_aux_tasks.ts
@@ -29,6 +29,7 @@ export const deAuxTasks: AuxTaskCopyMap = {
label: 'Review',
hint: '/review Bewertungs-Subagent'
},
+ voice_chat: { label: 'Sprachchat', hint: 'Gesprochene Antworten im Sprachmodus' },
triage_specifier: {
label: 'Triage-Spezifizierer',
hint: 'Kanban-Spezifikation ausarbeiten'
diff --git a/apps/desktop/src/i18n/en_aux_tasks.ts b/apps/desktop/src/i18n/en_aux_tasks.ts
index 8ac79fb8652..8afa073e81b 100644
--- a/apps/desktop/src/i18n/en_aux_tasks.ts
+++ b/apps/desktop/src/i18n/en_aux_tasks.ts
@@ -8,6 +8,7 @@ export const enAuxTasks: AuxTaskCopyMap = {
mcp: { label: 'MCP', hint: 'MCP tool routing' },
title_generation: { label: 'Title gen', hint: 'Session titles' },
review: { label: 'Review', hint: '/review reviewer subagent' },
+ voice_chat: { label: 'Voice chat', hint: 'Spoken voice-mode replies' },
triage_specifier: { label: 'Triage specifier', hint: 'Kanban spec fleshing' },
kanban_decomposer: { label: 'Kanban decomposer', hint: 'Task decomposition' },
profile_describer: { label: 'Profile describer', hint: 'Auto profile descriptions' },
diff --git a/apps/desktop/src/i18n/es_aux_tasks.ts b/apps/desktop/src/i18n/es_aux_tasks.ts
index ecbff609add..16f2ae9e3d3 100644
--- a/apps/desktop/src/i18n/es_aux_tasks.ts
+++ b/apps/desktop/src/i18n/es_aux_tasks.ts
@@ -29,6 +29,7 @@ export const esAuxTasks: AuxTaskCopyMap = {
label: 'Revisión',
hint: 'subagente revisor de /review'
},
+ voice_chat: { label: 'Chat de voz', hint: 'Respuestas habladas del modo voz' },
triage_specifier: {
label: 'Especificador de triaje',
hint: 'Detalle de especificaciones de Kanban'
diff --git a/apps/desktop/src/i18n/fr_aux_tasks.ts b/apps/desktop/src/i18n/fr_aux_tasks.ts
index f81be16503e..4fe2823268f 100644
--- a/apps/desktop/src/i18n/fr_aux_tasks.ts
+++ b/apps/desktop/src/i18n/fr_aux_tasks.ts
@@ -29,6 +29,7 @@ export const frAuxTasks: AuxTaskCopyMap = {
label: 'Révision',
hint: 'Sous-agent de révision /review'
},
+ voice_chat: { label: 'Chat vocal', hint: 'Réponses parlées du mode vocal' },
triage_specifier: {
label: 'Précision du triage',
hint: 'Détail des spécifications Kanban'
diff --git a/apps/desktop/src/i18n/ja_aux_tasks.ts b/apps/desktop/src/i18n/ja_aux_tasks.ts
index f3a80de3717..b058b32bb69 100644
--- a/apps/desktop/src/i18n/ja_aux_tasks.ts
+++ b/apps/desktop/src/i18n/ja_aux_tasks.ts
@@ -8,6 +8,7 @@ export const jaAuxTasks: AuxTaskCopyMap = {
mcp: { label: 'MCP', hint: 'MCP ツールルーティング' },
title_generation: { label: 'タイトル生成', hint: 'セッションタイトル' },
review: { label: 'レビュー', hint: '/review レビューサブエージェント' },
+ voice_chat: { label: '音声チャット', hint: '音声モードの応答' },
triage_specifier: { label: 'トリアージ指定', hint: 'カンバン仕様の具体化' },
kanban_decomposer: { label: 'カンバン分解', hint: 'タスク分解' },
profile_describer: { label: 'プロファイル記述', hint: 'プロファイル概要の自動生成' },
diff --git a/apps/desktop/src/i18n/ru_aux_tasks.ts b/apps/desktop/src/i18n/ru_aux_tasks.ts
index 4dc81cd5279..c623caf36b6 100644
--- a/apps/desktop/src/i18n/ru_aux_tasks.ts
+++ b/apps/desktop/src/i18n/ru_aux_tasks.ts
@@ -7,5 +7,6 @@ export const ruAuxTasks: AuxTaskCopyMap = {
approval: { label: 'Одобрение', hint: 'Умное авто-одобрение' },
mcp: { label: 'MCP', hint: 'Маршрутизация MCP-инструментов' },
title_generation: { label: 'Ген. заголовка', hint: 'Заголовки сеансов' },
+ voice_chat: { label: 'Голосовой чат', hint: 'Ответы в голосовом режиме' },
curator: { label: 'Куратор', hint: 'Просмотр использования навыков' }
}
diff --git a/apps/desktop/src/i18n/zh-hant_settings.ts b/apps/desktop/src/i18n/zh-hant_settings.ts
index 4add1e17394..e0d1462eeca 100644
--- a/apps/desktop/src/i18n/zh-hant_settings.ts
+++ b/apps/desktop/src/i18n/zh-hant_settings.ts
@@ -1068,6 +1068,7 @@ export const zhHantSettings = {
mcp: { label: 'MCP', hint: 'MCP 工具路由' },
title_generation: { label: '標題生成', hint: '工作階段標題' },
review: { label: '評審', hint: '/review 評審子代理' },
+ voice_chat: { label: '語音聊天', hint: '語音模式回覆' },
triage_specifier: { label: '分類指定', hint: '看板任務規格補全' },
kanban_decomposer: { label: '看板分解', hint: '任務拆解' },
profile_describer: { label: '設定檔描述', hint: '自動生成設定檔描述' },
diff --git a/apps/desktop/src/i18n/zh_aux_tasks.ts b/apps/desktop/src/i18n/zh_aux_tasks.ts
index 66b4df7cba6..d5deccf4024 100644
--- a/apps/desktop/src/i18n/zh_aux_tasks.ts
+++ b/apps/desktop/src/i18n/zh_aux_tasks.ts
@@ -8,6 +8,7 @@ export const zhAuxTasks: AuxTaskCopyMap = {
mcp: { label: 'MCP', hint: 'MCP 工具路由' },
title_generation: { label: '标题生成', hint: '会话标题' },
review: { label: '评审', hint: '/review 评审子智能体' },
+ voice_chat: { label: '语音聊天', hint: '语音模式回复' },
triage_specifier: { label: '分类指定', hint: '看板任务规格补全' },
kanban_decomposer: { label: '看板分解', hint: '任务拆解' },
profile_describer: { label: '配置描述', hint: '自动生成配置描述' },
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index 3fa391f215c..88a5df587c8 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -2687,6 +2687,7 @@ export interface PromptSubmitParams {
queued?: boolean | null
surface?: string | null
voice_context?: string | null
+ voice_turn?: boolean | null
title_preview?: string | null
truncate_before_user_ordinal?: number | null
truncate_before_row_id?: number | null
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index a7313b15098..5ac325215ad 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -26564,6 +26564,18 @@
"default": null,
"title": "Voice Context"
},
+ "voice_turn": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Voice Turn"
+ },
"title_preview": {
"anyOf": [
{
diff --git a/gateway/run_turn.py b/gateway/run_turn.py
index ad82ba2cf69..c8e6f037f2a 100644
--- a/gateway/run_turn.py
+++ b/gateway/run_turn.py
@@ -4311,8 +4311,8 @@ class GatewayTurnMixin:
persist_user_timestamp=persist_user_timestamp,
persist_user_display_kind=persist_user_display_kind,
reply_expected=reply_expected,
- persist_user_display_metadata=persist_user_display_metadata,
- scheduled_heartbeat=scheduled_heartbeat,
+ persist_user_display_metadata=persist_user_display_metadata, scheduled_heartbeat=scheduled_heartbeat,
+ voice_turn=str(getattr(message_type, "value", message_type) or "").lower() == "voice",
)
_status_thread_metadata = self._run_agent_bind_turn_wiring(
turn_ctx, turn_runner, source, event_message_id, disp._native_slack_task_cards,
diff --git a/gateway/run_turn_runner.py b/gateway/run_turn_runner.py
index d98df4a0ebb..f8e8d09e257 100644
--- a/gateway/run_turn_runner.py
+++ b/gateway/run_turn_runner.py
@@ -1249,8 +1249,7 @@ class TurnRunner:
def _wire_turn_agent_callbacks(self, agent, turn_route, reasoning_config,
stream_delta_cb, interim_assistant_cb, want_interim_messages):
- """Per-message state — callbacks and reasoning config change every turn, so they aren't
- baked into the cached agent."""
+ """Per-message state (callbacks, reasoning, voice route) — never baked into the cached agent."""
ctx = self._ctx
runner = self._runner
agent._notification_config = ctx.user_config
@@ -1272,6 +1271,7 @@ class TurnRunner:
agent.notice_clear_callback = None # sends can't be retracted
agent.event_callback = ctx._event_callback_sync
agent.reasoning_config, agent.service_tier = reasoning_config, runner._service_tier
+ agent._voice_turn_pending = ctx.voice_turn # auxiliary.voice_chat route
self._merge_turn_request_overrides(agent, turn_route)
# Must-deliver notes for THIS turn ride the current user message (api_content sidecar), never
# the system prompt. Assigned unconditionally so a reused agent never replays a stale note.
diff --git a/gateway/turn_context.py b/gateway/turn_context.py
index 7124eb5dfd2..e215a4182f8 100644
--- a/gateway/turn_context.py
+++ b/gateway/turn_context.py
@@ -64,6 +64,7 @@ class TurnContext:
persist_user_display_metadata: Optional[dict] = None
user_config: Any = None
mute_notification_reply: bool = False
+ voice_turn: bool = False # a voice-note turn: runs on auxiliary.voice_chat
enabled_toolsets: Any = None
disabled_toolsets: Any = None
log_mode_enabled: bool = False
diff --git a/hermes_cli/cli_chat_turn_mixin.py b/hermes_cli/cli_chat_turn_mixin.py
index 9509450e8c7..da3f9b6f992 100644
--- a/hermes_cli/cli_chat_turn_mixin.py
+++ b/hermes_cli/cli_chat_turn_mixin.py
@@ -331,6 +331,7 @@ class CLIChatTurnMixin:
reset_current_session_key = None # type: ignore[assignment]
_approval_session_token = None
agent_message = turn.voice_prefix + message if turn.voice_prefix else message
+ self.agent._voice_turn_pending = bool(turn.voice_prefix) # auxiliary.voice_chat route
# One-shot /model and /reload-skills notes; _prepend_note_to_message also handles
# multimodal content-part lists (string concat raised TypeError with an image).
for _note_attr in ("_pending_model_switch_note", "_pending_skills_reload_note"):
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.py
index 41297dc5ff5..67cecea3455 100644
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@ -774,9 +774,7 @@ DEFAULT_CONFIG = {
"title_generation": {
"enabled": True,
"model_upgrade_enabled": True, # False = keep the instant derived title, never call a model
- # Note: session_search no longer uses an auxiliary LLM (PR #27590 — single-shape tool returns DB
- # content directly). The old ``auxiliary.session_search.*`` block was removed here. Existing
- # values in user config.yaml files are harmless leftovers and ignored.
+ # session_search no longer uses an aux LLM (#27590); leftover auxiliary.session_search is ignored.
"provider": "auto",
"model": "",
"prefer_fast_model": False,
@@ -789,6 +787,7 @@ DEFAULT_CONFIG = {
},
"memory_query_rewrite": _aux(8, reasoning_effort=False),
"tts_audio_tags": _aux(30),
+ "voice_chat": _aux(120), # spoken voice-mode turns (agent/voice_turn_route.py); auto = session model
# Kanban: triage_specifier expands a Triage one-liner into a spec (cheap model OK);
# kanban_decomposer emits a JSON graph of child tasks (more tokens).
"triage_specifier": _aux(120),
diff --git a/hermes_cli/main_provider_setup.py b/hermes_cli/main_provider_setup.py
index ac866614227..9d73edd047a 100644
--- a/hermes_cli/main_provider_setup.py
+++ b/hermes_cli/main_provider_setup.py
@@ -59,6 +59,7 @@ _AUX_TASKS: list[tuple[str, str, str]] = [
("review", "Review", "/review reviewer subagent"),
("memory_query_rewrite", "Memory query rewrite", "memory retrieval queries"),
("tts_audio_tags", "TTS audio tags", "Gemini TTS tag insertion"),
+ ("voice_chat", "Voice chat", "spoken voice-mode replies"),
("skills_hub", "Skills hub", "skills search/install"),
("triage_specifier", "Triage specifier", "kanban spec fleshing"),
("kanban_decomposer", "Kanban decomposer", "task decomposition"),
diff --git a/hermes_cli/web_server_config.py b/hermes_cli/web_server_config.py
index b4db3ecc50e..773a9c47967 100644
--- a/hermes_cli/web_server_config.py
+++ b/hermes_cli/web_server_config.py
@@ -549,7 +549,7 @@ def _normalize_config_for_web(config: Dict[str, Any]) -> Dict[str, Any]:
# Canonical auxiliary task slots. Keep in sync with DEFAULT_CONFIG["auxiliary"]
# in hermes_cli/config.py — listed here for deterministic ordering in the UI.
_AUX_TASK_SLOTS: Tuple[str, ...] = (
- "vision", "compression", "skills_hub", "approval", "mcp", "title_generation", "review",
+ "vision", "compression", "skills_hub", "approval", "mcp", "title_generation", "review", "voice_chat",
"triage_specifier", "kanban_decomposer", "profile_describer", "curator",
)
diff --git a/hermes_state.py b/hermes_state.py
index d7867ade9ad..62b46da4725 100644
--- a/hermes_state.py
+++ b/hermes_state.py
@@ -1589,7 +1589,7 @@ class SessionDB(
_TOKEN_DELTA_COST_FIELDS = ("estimated_cost_usd", "actual_cost_usd")
_TOKEN_DELTA_ROUTE_FIELDS = (
"model", "cost_status", "cost_source", "pricing_version", "billing_provider", "billing_base_url",
- "billing_mode", "source",
+ "billing_mode", "source", "task",
)
MAX_TITLE_LENGTH = 100
diff --git a/hermes_state_usage.py b/hermes_state_usage.py
index 0b2e2fe991b..18909ec26e9 100644
--- a/hermes_state_usage.py
+++ b/hermes_state_usage.py
@@ -276,12 +276,14 @@ class SessionUsageMixin:
actual_cost_usd: Optional[float]=None, cost_status: Optional[str]=None, cost_source: Optional[str]=None,
pricing_version: Optional[str]=None, billing_provider: Optional[str]=None, billing_base_url: Optional[str]=None,
billing_mode: Optional[str]=None, api_call_count: int=0, absolute: bool=False,
- source: Optional[str]=None,
+ source: Optional[str]=None, task: str = "",
) -> None:
"""Update token counters and backfill model if unset. *absolute*=False increments
(per-API-call deltas, CLI path); *absolute*=True sets directly (gateway path,
where the cached agent holds cumulative totals). ``source`` is the session's real surface
- for the row-existence guard; callers that don't know it leave the placeholder."""
+ for the row-existence guard; callers that don't know it leave the placeholder. ``task`` names a
+ per-turn route (``voice_chat``): its calls count in the session totals and land in
+ ``session_model_usage`` under that task, but never become the session's recorded route."""
usage = {k: v for k, v in locals().items() if k in _MODEL_USAGE_FIELDS}
# Ensure the row exists: under concurrent load create_session() may have failed on
# locking, and the UPDATE would silently affect 0 rows. When this guard is the first
@@ -320,7 +322,7 @@ class SessionUsageMixin:
# and fallback succeeds, the first accounted usage is the authoritative route;
# after that keep the row as is (one row cannot represent mixed usage).
first_accounted_route = (
- int(existing.get("api_call_count") or 0) == 0 and has_accounted_usage and bool(model)
+ not task and int(existing.get("api_call_count") or 0) == 0 and has_accounted_usage and bool(model)
and bool(billing_provider)
and (existing.get("model") != model or existing.get("billing_provider") != billing_provider)
)
@@ -331,7 +333,7 @@ class SessionUsageMixin:
WHERE id = ?""", (model, billing_provider, billing_base_url, billing_mode, session_id))
conn.execute(sql, params)
if record_model_usage:
- self._record_model_usage(conn, session_id, **usage)
+ self._record_model_usage(conn, session_id, task=task, **usage)
self._execute_write(_do)
def _record_model_usage(
diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.json
index e2edf54a1ca..1d6147fcd1c 100644
--- a/locales/_keys.desktop.json
+++ b/locales/_keys.desktop.json
@@ -3481,6 +3481,8 @@
"settings.model.tasks.triage_specifier.label",
"settings.model.tasks.vision.hint",
"settings.model.tasks.vision.label",
+ "settings.model.tasks.voice_chat.hint",
+ "settings.model.tasks.voice_chat.label",
"settings.nav.about",
"settings.nav.apiKeys",
"settings.nav.archivedChats",
diff --git a/tests/agent/test_voice_turn_route.py b/tests/agent/test_voice_turn_route.py
new file mode 100644
index 00000000000..a29221e9e2e
--- /dev/null
+++ b/tests/agent/test_voice_turn_route.py
@@ -0,0 +1,68 @@
+"""``auxiliary.voice_chat``: a voice turn runs on the voice model, the next turn on the main one.
+
+Two real loopback providers; the agent talks HTTP to both, so the assertion is on what each
+server actually received rather than on agent attributes.
+"""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from run_agent import AIAgent
+from tests.fakes.fake_llm_provider import FakeLLMServer, Text, write_hermes_home
+
+
+def _agent(home: Path, main_url: str):
+ return AIAgent(
+ model="fake-model", provider="custom", base_url=main_url, api_key="sk-fake-e2e",
+ quiet_mode=True, skip_context_files=True, skip_memory=True, enabled_toolsets=["memory"],
+ )
+
+
[email protected]("voice_window_ok", [True, False])
+def test_voice_turn_routes_then_restores(tmp_path, monkeypatch, voice_window_ok):
+ with FakeLLMServer([Text("main one"), Text("main two")]) as main, \
+ FakeLLMServer([Text("voice reply")]) as voice:
+ context = "128000" if voice_window_ok else "1000"
+ home = write_hermes_home(tmp_path / ".hermes", main.base_url, extra_config=(
+ "auxiliary:\n voice_chat:\n provider: custom\n"
+ f" base_url: {voice.base_url}\n model: voice-model\n api_key: sk-fake-voice\n"
+ "custom_providers:\n - name: voice\n"
+ f" base_url: {voice.base_url}\n models:\n voice-model:\n context_length: {context}\n"
+ ))
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ agent = _agent(home, main.base_url)
+
+ first = agent.run_conversation("typed question")
+ agent._voice_turn_pending = True
+ spoken = agent.run_conversation("spoken question", conversation_history=first["messages"])
+ agent.run_conversation("typed again", conversation_history=spoken["messages"])
+
+ main_models = [r["model"] for r in main.main_requests()]
+ voice_models = [r["model"] for r in voice.main_requests()]
+ if voice_window_ok:
+ assert voice_models == ["voice-model"]
+ assert main_models == ["fake-model", "fake-model"]
+ assert spoken["model"] == "voice-model"
+ else: # too large for the voice model's window: the main model answers, nothing compacts
+ assert voice_models == []
+ assert main_models == ["fake-model"] * 3
+ assert agent.model == "fake-model"
+ assert agent.base_url.rstrip("/") == main.base_url.rstrip("/")
+ assert agent._fallback_activated is False
+
+
+def test_voice_usage_never_becomes_the_session_route(tmp_path):
+ from hermes_state import SessionDB
+
+ db = SessionDB(tmp_path / "state.db")
+ db.create_session("s1", source="cli", model="main-model")
+ db.update_token_counts("s1", input_tokens=10, output_tokens=5, model="voice-model",
+ billing_provider="voicep", api_call_count=1, task="voice_chat")
+ row = db.get_session("s1")
+ assert row["model"] == "main-model"
+ assert row["input_tokens"] == 10
+ assert db.auxiliary_usage_by_task("s1")["voice_chat"]["input_tokens"] == 10
+ assert db.get_recent_session_model_route("s1") is None
diff --git a/tests/gateway/test_display_null_turn_wiring.py b/tests/gateway/test_display_null_turn_wiring.py
index 33cbaefed90..d140a12ec0c 100644
--- a/tests/gateway/test_display_null_turn_wiring.py
+++ b/tests/gateway/test_display_null_turn_wiring.py
@@ -23,6 +23,7 @@ def _wire(user_config):
native_tool_start_callback=None,
voice_ack_callback=None,
_voice_ack_guild=[None],
+ voice_turn=False,
_native_slack_task_cards=False,
native_tool_complete_callback=None,
_step_callback_sync=None,
diff --git a/tui_gateway/contracts/prompt_voice.py b/tui_gateway/contracts/prompt_voice.py
index d257e0a25ed..83e4da975d9 100644
--- a/tui_gateway/contracts/prompt_voice.py
+++ b/tui_gateway/contracts/prompt_voice.py
@@ -35,6 +35,7 @@ class PromptSubmitParams(SessionParams):
queued: bool | None = None # client queue drain — the busy path must hold it, never redirect/steer
surface: str | None = None # a ClientSurface value; unknown values clear the surface
voice_context: str | None = None # recent spoken transcript, model input only (voice-live)
+ voice_turn: bool | None = None # a spoken voice-conversation turn: runs on auxiliary.voice_chat
# Desktop-generated large-paste preview (first ~1000 chars); TITLE input only, never the model turn.
title_preview: str | None = None
truncate_before_user_ordinal: int | None = None
diff --git a/tui_gateway/methods_prompt.py b/tui_gateway/methods_prompt.py
index b4d8686fb09..103184b70bd 100644
--- a/tui_gateway/methods_prompt.py
+++ b/tui_gateway/methods_prompt.py
@@ -729,6 +729,7 @@ def _(rid, params: dict) -> dict:
voice_context = params.get("voice_context")
session["voice_live_context"] = (
voice_context[:6000] if session["client_surface"] == "voice-live" and isinstance(voice_context, str) else "")
+ session["voice_turn"] = params.get("voice_turn") is True
has_truncation = any(params.get(k) is not None for k in _TRUNCATION_PARAMS)
if has_truncation and isinstance(text, str):
# A rewind replays what the transcript shows: re-expand a skill invocation or
diff --git a/tui_gateway/prompt_turn.py b/tui_gateway/prompt_turn.py
index d4a954ed3cc..fcffd89e5b7 100644
--- a/tui_gateway/prompt_turn.py
+++ b/tui_gateway/prompt_turn.py
@@ -728,6 +728,7 @@ def _prepare_turn_input(sid: str, session: dict, st: _TurnRun, text: Any, images
if take_speech_interrupted():
run_message = _prepend_note(run_message, SPEECH_INTERRUPTED_NOTE)
run_message = _prepend_note(run_message, _pending_reaction_notes(session))
+ agent._voice_turn_pending = bool(session.pop("voice_turn", False)) # auxiliary.voice_chat route
return prompt, _prepend_note(run_message, _hud_surface_note(session)), cols, streamer
diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.ts
index 03c21fb83fc..97108ba1b40 100644
--- a/ui-tui/src/app/createGatewayEventHandler.ts
+++ b/ui-tui/src/app/createGatewayEventHandler.ts
@@ -37,6 +37,7 @@ import { getOverlayState, patchOverlayState, SENSITIVE_PROMPTS } from './overlay
import { flashGoodVibes, flashPet } from './petFlashStore.js'
import { forgetServerRequest } from './serverRequestStore.js'
import { reportStartupLatency } from './startupLatency.js'
+import { markNextSubmitVoice } from './submissionCore.js'
import { turnController } from './turnController.js'
import { getTurnState } from './turnStore.js'
import { getUiState, patchUiState } from './uiStore.js'
@@ -1089,6 +1090,7 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev:
// is committed before submit reads it; invalid config also falls
// back to this established direct-submit behavior.
setInput('')
+ markNextSubmitVoice(text)
setTimeout(() => submitRef.current(text), 0)
})
diff --git a/ui-tui/src/app/submissionCore.ts b/ui-tui/src/app/submissionCore.ts
index 16406e0143e..e7f94ec6162 100644
--- a/ui-tui/src/app/submissionCore.ts
+++ b/ui-tui/src/app/submissionCore.ts
@@ -38,6 +38,22 @@ export function markSubmitting(): void {
patchUiState({ busy: true, status: 'running…' })
}
+// A voice-mode transcript about to be submitted: the matching prompt.submit carries
+// `voice_turn` so the gateway runs it on `auxiliary.voice_chat`. Matched by text, so a
+// transcript the user edited or that went to the queue still lands as typed text.
+let pendingVoiceTranscript: null | string = null
+
+export function markNextSubmitVoice(text: string): void {
+ pendingVoiceTranscript = text
+}
+
+function takeVoiceTurn(submitText: string): boolean {
+ const voice = pendingVoiceTranscript !== null && pendingVoiceTranscript === submitText.trim()
+ pendingVoiceTranscript = null
+
+ return voice
+}
+
// Submit a ready prompt (already resolved to be neither a slash command nor a
// shell escape, with a live session). Pulled out of useSubmission so the
// synchronous-busy invariant above is unit-testable without React test infra.
@@ -80,7 +96,11 @@ export function submitPrompt(
turnController.interrupted = false
deps.gw
- .request<PromptSubmitResponse>('prompt.submit', { session_id: liveSid, text: submitText })
+ .request<PromptSubmitResponse>('prompt.submit', {
+ session_id: liveSid,
+ text: submitText,
+ ...(takeVoiceTurn(submitText) && { voice_turn: true })
+ })
.then(r => {
// The gateway consumed a typed voice stop phrase server-side (voice
// chat ended, no turn started) — release the busy latch; the
diff --git a/web/src/lib/aux-tasks.ts b/web/src/lib/aux-tasks.ts
index 52a6fdc61b5..e2df12d78ca 100644
--- a/web/src/lib/aux-tasks.ts
+++ b/web/src/lib/aux-tasks.ts
@@ -20,6 +20,7 @@ export const BUILTIN_AUX_TASKS: readonly AuxTaskMeta[] = [
{ key: "mcp", label: "MCP", hint: "MCP tool routing" },
{ key: "title_generation", label: "Title Gen", hint: "Session titles" },
{ key: "review", label: "Review", hint: "/review subagent" },
+ { key: "voice_chat", label: "Voice Chat", hint: "Spoken voice-mode replies" },
{ key: "triage_specifier", label: "Triage Specifier", hint: "Kanban spec fleshing" },
{ key: "kanban_decomposer", label: "Kanban Decomposer", hint: "Task decomposition" },
{ key: "profile_describer", label: "Profile Describer", hint: "Auto profile descriptions" },
diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.md
index 894e740cf5c..c11b8cbe577 100644
--- a/website/docs/user-guide/configuration.md
+++ b/website/docs/user-guide/configuration.md
@@ -1409,6 +1409,7 @@ $ hermes model
[ ] vision currently: auto / main model
[ ] title_generation currently: openrouter / google/gemini-3-flash-preview
[ ] tts_audio_tags currently: auto / main model
+[ ] voice_chat currently: auto / main model
[ ] compression currently: auto / main model
[ ] approval currently: auto / main model
[ ] triage_specifier currently: auto / main model
@@ -1421,6 +1422,8 @@ Select a task, pick a provider (OAuth flows open a browser; API-key providers pr
The **Delegation** entry is special: it routes the model used by `delegate_task` subagents and persists to the top-level `delegation.*` section (`delegation.provider` / `delegation.model`) rather than `auxiliary.*`, because subagents are full child agents, not side-LLM calls. Its `auto` means "inherit the parent agent's provider, model, and credentials."
+The **Voice chat** entry picks the model that answers spoken voice-mode turns (tools included); typed turns stay on the main model. See [Voice chat model](features/voice-mode.md#voice-chat-model).
+
If you do not want Hermes to auto-generate titles after the first exchange, set
`auxiliary.title_generation.enabled: false`. Manual titles still work through
`/title` and `hermes sessions rename`.
diff --git a/website/docs/user-guide/features/voice-mode.md b/website/docs/user-guide/features/voice-mode.md
index 2ced53b5184..6efef22009e 100644
--- a/website/docs/user-guide/features/voice-mode.md
+++ b/website/docs/user-guide/features/voice-mode.md
@@ -241,6 +241,22 @@ How it works: pressing the voice button opens a WebRTC session from the desktop
Not supported in this mode: the Nous-managed audio proxy (direct key only), the CLI/TUI (`/voice` keeps the chained loop), and the `tts` tool (it keeps using `tts.provider`).
+### Voice chat model
+
+Spoken turns can run on a different (usually faster) model than the one you type to. Set the `voice_chat` auxiliary slot, in Settings → Models → Auxiliary models on Desktop, in `hermes model` → Auxiliary models, or in config.yaml:
+
+```yaml
+auxiliary:
+ voice_chat:
+ provider: openrouter # "auto" = the session's model (default)
+ model: google/gemini-3-flash-preview # empty with a provider = that provider's fast model
+ reasoning_effort: low # optional; applies to voice turns only
+```
+
+It applies to every chained voice turn: CLI and TUI voice mode, the Desktop voice conversation, and voice notes on messaging platforms. The voice turn has the full toolset; only the model answering it changes. The next typed message goes back to the session's model, and so do memory and skill reviews after the turn. Usage is recorded under the `voice_chat` task, so the session keeps the model you picked as its own.
+
+The voice model never forces a compaction: when the conversation is already larger than its context window, that turn runs on the session's model and a one-time notice says so. GPT-Live voice chat ignores this slot, because there the voice layer already is the fast model and delegates real work to the session's model.
+
### Barge-in
You can interrupt the agent at ANY point in its turn — the microphone stays live from the moment you finish speaking until the reply has fully played (full duplex):