diff --git a/packages/services/voice-agent/src/agent.py b/packages/services/voice-agent/src/agent.py index 07892d3..9e1e66b 100644 --- a/packages/services/voice-agent/src/agent.py +++ b/packages/services/voice-agent/src/agent.py @@ -93,10 +93,14 @@ class IT0VoiceAgent(Agent): ) async def on_enter(self): - """Called when the agent becomes active — greet the user.""" - self.session.generate_reply( - instructions="用一句简短的话打招呼,告诉用户你是IT0运维助手,可以帮助什么。" - ) + """Called when the agent becomes active — greet the user. + + Uses session.say() with a static message instead of generate_reply() + to avoid triggering the Agent SDK / LLM pipeline for a simple greeting. + This prevents a race condition when the user speaks before the + greeting LLM task completes. + """ + self.session.say("你好,我是IT0运维助手,有什么可以帮你的?") # --------------------------------------------------------------------------- diff --git a/packages/services/voice-agent/src/plugins/agent_llm.py b/packages/services/voice-agent/src/plugins/agent_llm.py index d7dc523..399979d 100644 --- a/packages/services/voice-agent/src/plugins/agent_llm.py +++ b/packages/services/voice-agent/src/plugins/agent_llm.py @@ -331,6 +331,11 @@ class AgentServiceLLMStream(llm.LLMStream): elif evt_type == "error": err_msg = evt_data.get("message", "Unknown error") logger.error("Agent error: %s", err_msg) + # Clear session so next task starts fresh + # (don't try to resume a dead/aborted session) + if "aborted" in err_msg.lower() or "exited" in err_msg.lower(): + logger.info("Clearing agent session after abort/exit") + self._llm_instance._agent_session_id = None self._event_ch.send_nowait( llm.ChatChunk( id=request_id,