Skip to content

Commit 2fe9e6d

Browse files
author
Jarvis (OpenClaw)
committed
feat: enable continue_conversation for Voice PE follow-up dialog
When the assistant's response ends with a question mark or contains common follow-up patterns (EN/DE), set continue_conversation=True on the ConversationResult. This tells Voice PE and other HA voice satellites to automatically re-listen after the response finishes playing, enabling natural back-and-forth dialog without requiring the wake word between turns. Fixes #7
1 parent 95bfe5e commit 2fe9e6d

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

custom_components/openclaw/conversation.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from datetime import datetime, timezone
1010
import logging
11+
import re
1112
from typing import Any
1213

1314
from homeassistant.components import conversation
@@ -200,6 +201,7 @@ async def async_process(
200201
return conversation.ConversationResult(
201202
response=intent_response,
202203
conversation_id=conversation_id,
204+
continue_conversation=self._should_continue(full_response),
203205
)
204206

205207
def _resolve_conversation_id(self, user_input: conversation.ConversationInput) -> str:
@@ -314,6 +316,53 @@ def _extract_text_recursive(self, value: Any, depth: int = 0) -> str | None:
314316

315317
return None
316318

319+
@staticmethod
320+
def _should_continue(response: str) -> bool:
321+
"""Determine if the conversation should continue after this response.
322+
323+
Returns True when the assistant's reply ends with a question or
324+
an explicit prompt for follow-up, so that Voice PE and other
325+
satellites automatically re-listen without requiring a wake word.
326+
327+
The heuristic checks for:
328+
- Trailing question marks (including after closing quotes/parens)
329+
- Common conversational follow-up patterns in English and German
330+
"""
331+
if not response:
332+
return False
333+
334+
text = response.strip()
335+
336+
# Check if the response ends with a question mark
337+
# (allow trailing punctuation like quotes, parens, or emoji)
338+
if re.search(r"\?\s*[\"'""»)\]]*\s*$", text):
339+
return True
340+
341+
# Common follow-up patterns (EN + DE)
342+
lower = text.lower()
343+
follow_up_patterns = (
344+
"what do you think",
345+
"would you like",
346+
"do you want",
347+
"shall i",
348+
"should i",
349+
"can i help",
350+
"anything else",
351+
"let me know",
352+
"was meinst du",
353+
"möchtest du",
354+
"willst du",
355+
"soll ich",
356+
"kann ich",
357+
"noch etwas",
358+
"sonst noch",
359+
)
360+
for pattern in follow_up_patterns:
361+
if pattern in lower:
362+
return True
363+
364+
return False
365+
317366
def _error_result(
318367
self,
319368
user_input: conversation.ConversationInput,

0 commit comments

Comments
 (0)