robert 10cce3340d
ci / test (push) Successful in 38s
ci / hassfest (push) Successful in 7s
Route web follow-ups, lookups and weather elsewhere to the web agent
The decision model judges one sentence, so "Und wer wurde Zweiter?" after a
web answer or "Such mal im Internet ..." went to the primary agent, which
has no web tools and said it cannot search. Follow-ups now stay with the
web agent for five minutes, explicit lookups and the weather in a named
place go to it, and general weather questions get the home's forecast.
The benchmark can run items in one conversation.
2026-11-25 17:55:33 +01:00
2026-11-21 03:41:00 +01:00
2026-11-21 03:41:00 +01:00
2026-11-21 03:41:00 +01:00

Voice Router

Voice Router

A Home Assistant conversation agent that answers simple voice commands itself, in about a tenth of a second, and hands everything else to your LLM agent. One pipeline understands several languages (currently English and German) and detects the language per sentence, so one wake word is enough.

sentence ─┬─ Home Assistant's own exact matching (every language) ──────────── ~10 ms
          └─ embedding search ∥ decision model (kind, room, language)
               ├─ clear match  → execute directly, answer in the user's words  ~100-150 ms
               ├─ grey zone    → decision model picks among the candidates     +20-30 ms
               ├─ comparison   → "which room is warmest?" from room sensors    ~100 ms
               └─ otherwise    → your LLM agent, with the likely devices'
                                 states already looked up                      LLM time

How it works

  • Catalog from your installation. Every entity exposed to Assist becomes a set of commands (on, off, state questions, scenes, media, vacuum, whole rooms), phrased in every language from your names, aliases and areas. Nothing is configured by hand; the catalog is rebuilt when entities, devices or areas change.
  • Embeddings (any OpenAI-compatible /v1/embeddings endpoint, e.g. llama.cpp with EmbeddingGemma) find the device; sentence vectors are cached on disk, so restarts are instant.
  • A decision model (llama.cpp /v1/systemone, e.g. LiquidAI d1-2B) answers typed questions in one forward pass: what kind of command, which room, which language, and in the grey zone which candidate fits. It runs in parallel with the embedding search.
  • Safety first. Only reversible actions are executed directly (lights, switches, fans, scenes, media, vacuum). Locks, covers, alarms and anything with a number go to Home Assistant's own intents or to the LLM. A candidate is executed only if it clearly leads every other target and fits the recognised kind of command.
  • LLM handoff without losing the prompt cache. The router adds the most relevant devices' states as an already answered GetLiveContext call after your sentence, so the agent rarely needs a tool round trip and its cached system prompt stays untouched.
  • Optional second agent (a larger local model or a cloud model): the decision model rates whether a question needs careful reasoning or a longer explanation; such questions go to the second agent, and it also takes over when the primary agent fails.
  • Natural bridging sentences. While an agent has not started to answer, the router says short sentences that fit what it is doing, in the user's language and words: a beat after the question when it will take a while (searching, thinking), otherwise after 0.8 s; "let me look that up" when it searches, the source when reading a page takes longer, "found something" when it is still reading the results; growing gaps, at most three sentences, never the same twice in a row, and none once the answer has started. Thinking and tool calls do not count as an answer. Without an answer after 20 s it says so and stops. The sentences go only to the speech output, not into the conversation history.
  • Web search (optional). Questions about current facts (news, results, prices, opening hours, who holds an office) go to a web agent that has only two tools, provided by the router as their own LLM API: web_search (a SearXNG instance) and read_page (the passages of a result that fit the question, ranked with the embedding model; the top two pages are fetched in the background right after the search). The router searches with the question's keywords while the first bridging sentence plays, so the agent usually starts with results in hand. Page text is untrusted, so this agent gets no home control. Only public http(s) addresses are fetched.
  • Context chosen by judgement. With every question the router adds, as an already answered tool call after the user's message (the system prompt stays identical, so the prompt cache holds): a calendar line (24-hour time, weekday, this week's Monday to Sunday), the likely devices with their states, and per kind of question what a person would look at first: outside readings and the forecast for advice ("Do I need a jacket?"), running timers, the list's items, what is playing. Plus a short answer style for that kind ("yes or no first, then the reason").
  • Exact dates. The LLM API "Voice Router tools" provides GetDateTime for date and time arithmetic (days until, weekday of a date, time after a duration, age). Give it to the answering agents; Home Assistant then also leaves its per-second time line out of their system prompt.
  • Thinking when it pays off (optional). One agent per thinking level (an LLM with a thinking budget): light for calculation questions (date questions use the date tool instead), medium for questions the decision model rates as hard, deep only when asked for ("denk genau nach", "think it through"). Everything else is answered without thinking.
  • Natural names. Spoken device names drop model numbers ("Denon AVC-X4700H" -> "Denon") and, in German answers, common English device and room words become German ("Kitchen Lamp" -> "Küchenlampe"); German articles and prepositions follow the noun.
  • Early speech. Home Assistant starts speaking a streamed answer after 60 characters; the router opens the stream at the answer's first clause instead, so a long first sentence does not delay the first words.
  • Resilient. If the embedding or decision model is busy (for example while another model has the GPU), the router does not wait: Home Assistant's own matching and the LLM agent take over.

For several languages in one pipeline, use a text-to-speech service that speaks each sentence in its own language and synthesizes streamed text sentence by sentence (for example Wyoming Pocket TTS 1.5 or newer with --languages en,de); otherwise answers in the second language are read by the first language's voice.

Requirements

  • Home Assistant 2026.11 or newer.
  • An OpenAI-compatible embedding endpoint (multilingual model recommended).
  • A decision model served by llama.cpp (llama-server -hf LiquidAI/d1-2B-GGUF:Q4_K_M --no-mmproj; about 1.7 GB of GPU memory, or around 0.5 s per question on a CPU).
  • A conversation agent for everything else (for example an OpenAI-compatible LLM agent).

Installation

HACS: add this repository as a custom repository (category Integration), install Voice Router and restart Home Assistant.

Manually: copy custom_components/voice_router into your config/custom_components folder and restart Home Assistant.

Then add the integration under Settings → Devices & services. With Create an Assist pipeline enabled, a pipeline named Voice Router is created that copies speech-to-text and text-to-speech from your preferred pipeline; your preferred pipeline is not changed. Select it on a voice satellite to try it.

Configuration in YAML (optional)

For configuration kept in git, the same settings can be provisioned from YAML; the entry is created or updated on start:

voice_router:
  embedding_url: http://llm.local:8080/v1/embeddings
  embedding_model: embeddinggemma
  decision_url: http://llm.local:8081/v1/systemone
  api_key: !secret voice_router_api_key
  primary_agent: conversation.my_llm_agent
  languages: [en, de]
  create_pipeline: true

Tuning

Option Default Meaning
Direct action threshold 0.85 Similarity a command needs to be executed without the decision model
Decision model confidence 0.6 Confidence the decision model needs in the grey zone (0.85 when it is unsure about the kind of command)
llm_head_start (YAML) false Start the primary agent while the router is still deciding, for sentences HA's own matching does not handle. Its answer and tool calls are held back until the decision; it is kept when the decision would have sent the sentence to that agent anyway (no device states to prefetch, not a hard question) and cancelled otherwise. Saves the decision time (about 0.1-0.2 s) on general questions, at the cost of a briefly started LLM request for router commands.
follow_up_judge (YAML) false Let the decision model decide whether the agent's reply waits for an answer, instead of Home Assistant's rule (keep listening when the reply ends with "?"). Catches requests without a question mark ("Tell me what you have in the fridge.") and drops questions that need no answer. Runs when the answer is complete, while the satellite is still speaking (about 0.1 s); if the model does not answer within 0.6 s, Home Assistant's rule applies.
search_url (YAML) – SearXNG instance (JSON output enabled) for the web agent's tools; registers the LLM API "Voice Router web search".
web_agent (YAML) – Conversation agent for web questions; give it only the "Voice Router web search" API.
think_agents (YAML) – {light, medium, deep}: conversation agents with growing thinking budgets (e.g. the same model through different aliases).

Diagnostics (Download diagnostics on the integration) show the catalog size and the last routing decisions with their timings.

Development

pip install numpy pytest pytest-asyncio ruff
ruff check custom_components tests && pytest

The routing core in custom_components/voice_router/core does not import Home Assistant and is tested against an invented home (tests/fixture_other_home.json).

License

MIT

S
Description
Home Assistant conversation agent: simple voice commands answered locally in ~0.1 s, everything else handed to your LLM agent. One multilingual pipeline.
Readme MIT
419 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 100%