From a92a56b8457c90a6efdf60ddbadf53194d48fd22 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Thu, 12 Feb 2026 15:59:36 +0800 Subject: [PATCH] Presist opener to history --- engine/core/conversation.py | 21 +++++++++++++++++++++ engine/core/duplex_pipeline.py | 1 + 2 files changed, 22 insertions(+) diff --git a/engine/core/conversation.py b/engine/core/conversation.py index a3712e6..08b23c6 100644 --- a/engine/core/conversation.py +++ b/engine/core/conversation.py @@ -211,6 +211,27 @@ class ConversationManager: await self.set_state(ConversationState.INTERRUPTED) 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).""" diff --git a/engine/core/duplex_pipeline.py b/engine/core/duplex_pipeline.py index e877d7a..2f45387 100644 --- a/engine/core/duplex_pipeline.py +++ b/engine/core/duplex_pipeline.py @@ -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)