Presist opener to history

This commit is contained in:
Xin Wang
2026-02-12 15:59:36 +08:00
parent bbfb5570cc
commit a92a56b845
2 changed files with 22 additions and 0 deletions

View File

@@ -212,6 +212,27 @@ class ConversationManager:
else:
await self.set_state(ConversationState.IDLE)
async def add_assistant_turn(self, text: str, was_interrupted: bool = False) -> None:
"""Append an assistant turn directly without mutating conversation state."""
content = text.strip()
if not content:
return
turn = ConversationTurn(
role="assistant",
text=content,
was_interrupted=was_interrupted,
)
self.turns.append(turn)
for callback in self._turn_callbacks:
try:
await callback(turn)
except Exception as e:
logger.error(f"Turn callback error: {e}")
logger.info(f"Assistant (injected): {content[:50]}...")
async def interrupt(self) -> None:
"""Handle interruption (barge-in)."""
if self.state == ConversationState.SPEAKING:

View File

@@ -563,6 +563,7 @@ class DuplexPipeline:
),
priority=20,
)
await self.conversation.add_assistant_turn(greeting_to_speak)
if tts_output_enabled:
await self._speak(greeting_to_speak)