Skip to content

Kivi follow-up listening: the reply must end in ? (and other fast-tier slips)

Problem

Two symptoms observed on 2026-12-03 while asking the TV satellite (c3-b) to play music:

  1. The conversation does not advance. Kivi answers a music request with a clarifying question, but then does not listen for the answer — the user must say the wake word again. Two reply shapes cause it: an imperative like "Dime qué prefieres" (no ? at all), and a question followed by an option list that ends in . — e.g. "¿Qué música te apetece ahora? Tengo celta, clásica de Bach, … Eskorbuto." The second shape still fails even though it contains a question, because only the last character is checked.
  2. A parse error is spoken aloud: "Error: Unexpected tool argument response: Expecting ',' delimiter: line 1 column 102 (char 101)" — heard as "unexpected argument delimiter".

Neither is a Music Assistant, network, or gateway wiring problem. Both are limitations of the conversation.fast (Kiais fast tier) path through Home Assistant's core llama_cpp agent.

Root Cause

1. Follow-up listening is a punctuation heuristic

Home Assistant decides whether to keep the microphone open for the answer only by the last character of the assistant reply (components/conversation/chat_log.py, ChatLog.continue_conversation):

return (
    last_msg.role == "assistant"
    and last_msg.content is not None
    and last_msg.content.strip().endswith(("?", ";", "?"))
)

The flag travels to the satellite in the ESPHome INTENT_END event (components/esphome/assist_satellite.py sends continue_conversation), and the satellite firmware acts on it (webos-voice-satellite, crates/esphome-api/src/voice.rs, finish_run): continue_conversation → start a follow-up run without wake word, same conversation id; otherwise re-arm to wake-word mode.

So "Dime qué prefieres" (ends in s) → flag 0 → mic closes → the answer is never heard. "¿Qué prefieres?" → flag 1 → follow-up works. Spanish imperative clarifications are grammatically commands, so the model can produce them while still "asking a question".

The Kivi prompt already required ?-terminated clarifying questions (added after two earlier observations of the same failure, see docs/voice-assistant/kiais-integration.md). The fast model simply slipped past the instruction. This is model reliability, not a missing mechanism. The habitual slip is question first, then an option list ending in . — so "don't enumerate options" prompt rules fight the model's natural behavior and lose; the working prompt instead folds the options into the question (see Fix). Full failure-mode catalog and the deterministic fix designed for a future custom agent: docs/voice-assistant/followup-continuation-design.md.

Commercial assistants do not parse punctuation: they signal "keep listening" as structured dialog state (Alexa shouldEndSession: false + Dialog.ElicitSlot/Delegate directives, Google Assistant expectUserResponse/expected_inputs, Siri's dialog model). HA's Assist LLM API has no such structured flag, hence the heuristic. The HA-community workaround is exactly the prompt rule; the alternative ("always continue" after every reply) keeps the mic open more and trades into the false-wake risk gated by EXP-015/G4 for the TV satellites.

2. Spoken JSON parse error = malformed tool-call arguments from the fast model

After a successful media_player__search_media (MA returned playable results), the model's next tool call (media_player__play_media, with a long media_content_id) carried invalid JSON arguments. llama_cpp parses them with json.loads (_decode_tool_arguments, components/llama_cpp/entity.py); on JSONDecodeError it raises the json_parse_error translation — "Unexpected tool argument response: {message}" — which the pipeline speaks.

The Kiais gateway is not the cause: its only response-path transform (kiais-gateway/src/reasoning.rs) normalizes reasoning fields and repairs tool-call names; function.arguments is forwarded byte-identical. The malformed JSON comes from the upstream fast model. It is transient: retrying the request normally produces valid JSON. Same family as the documented ~93% tool-call correctness of the fast tier (docs/voice-assistant/experiments/conversation-agent-eval.md).

How to Diagnose

Recent conversation turns (tool calls, arguments, results, spoken replies) are in HA's in-memory chat logs, not in .storage and not in the pod logs:

  1. Log in with a login-flow token (pass web/hass.grigri.cloud, user agil).
  2. Websocket conversation/chat_log/subscribe_index → the initial_state event carries the last few chat logs with full content. (conversation/trace/list does not exist in this version; trace.saved_traces only holds UI-saved traces.)
  3. Find the turn: the last assistant content is the spoken error; the preceding tool_result shows what the model was acting on. A tool call whose arguments failed to parse never appears as a tool_calls entry.

Privacy: chat logs contain raw household conversation (STT output). Do not persist them to disk beyond the debugging session, never commit them, and shred scratch files afterwards.

For the follow-up symptom, check the reply's last character and the continue_conversation flag in the INTENT_END payload; POST /api/conversation/process returns the flag directly, so text-only checks need no audio and no satellite.

Fix / Workaround

Applied 2026-12-03 (owner-approved live changes), two iterations the same day:

  1. First revision added a negative example ("Nunca uses imperativos como «Dime qué prefieres»") and the consequence. It fixed the imperative shape but not the question-then-options shape: the model still replied "¿Qué música te apetece ahora? Tengo celta, clásica … Eskorbuto." (ends .), so the mic closed again.
  2. Second revision (current) folds the options into the question instead of forbidding them, which works with the model's habit rather than against it:
Si la petición es ambigua, responde con una sola pregunta corta que acabe en «?» y nada más. Si quieres ofrecer opciones, mételas dentro de la pregunta, por ejemplo «¿Qué música te apetece: celta, clásica o rock?» o «¿En qué habitación?». Nunca uses imperativos como «Dime qué prefieres» ni añadas una frase después de la pregunta: si el final no lleva «?», el micrófono se cierra y no se oye la respuesta.

All other subentry fields unchanged (chat_model: fast, llm_hass_api: [assist], max_tokens: 300, temperature: 0.2, top_p: 1.0, recommended: false). Verified text-only after the second revision: "¿Está encendida la luz?" → "¿En qué habitación?" and "Pon música" → "¿Qué música te apetece: celta, clásica o rock?" — both end in ?, continue_conversation: true. The music probe now folds the options into the question as intended.

Headless application path (the prompt is UI-managed .storage, not git):

  • config_entries/subentries/update (websocket) only changes the title — not the data.
  • Use the subentry reconfigure flow: POST /api/config/config_entries/subentries/flow with {"handler": [<entry_id>, "conversation"], "subentry_id": <id>}, then POST the full subentry data (only the prompt changed) to /api/config/config_entries/subentries/flow/<flow_id>. Success is {"type": "abort", "reason": "reconfigure_successful"}. The flow validates the model with a small test completion before saving.
  • HA saves .storage with a delay: an immediate read-back can still show the old prompt. Re-read after a few seconds before concluding the change failed.

Residual limits:

  • The prompt reduces slips but cannot guarantee compliance from a small fast model. When it happens, say the wake word again; the conversation id is kept, so context survives.
  • For the spoken JSON parse error: retry the request. If it starts failing systematically on long opensubsonic--…:// media URIs, escalate as a fast-tier/gateway tool-call serialization issue — not as a MA or HA wiring problem.
  • Do not "fix" this by making the satellite always listen after every reply: that is the false-wake exposure EXP-015/G4 exists to measure.

See also: docs/voice-assistant/followup-continuation-design.md (failure-mode catalog and the deterministic custom-agent design for the future build), docs/voice-assistant/kiais-integration.md (prompt history, deployment, rollback), docs/deployment/home-assistant-voice-multiroom.md (TV satellite commissioning).