diff --git a/vocode/streaming/agent/base_agent.py b/vocode/streaming/agent/base_agent.py index a402c0c22..f0e65bcb6 100644 --- a/vocode/streaming/agent/base_agent.py +++ b/vocode/streaming/agent/base_agent.py @@ -424,15 +424,6 @@ async def get_tracer_name_start(self) -> str: self.tracer_name_start: str = tracer_name_start return tracer_name_start - def terminate(self): - if ( - hasattr(self.agent_config, "vector_db_config") - and self.agent_config.vector_db_config - ): - self.logger.debug("Terminating vector db") - self.vector_db.tear_down() - return super().terminate() - async def respond( self, human_input, diff --git a/vocode/streaming/streaming_conversation.py b/vocode/streaming/streaming_conversation.py index 71ebdc3f5..da3083f1f 100644 --- a/vocode/streaming/streaming_conversation.py +++ b/vocode/streaming/streaming_conversation.py @@ -626,6 +626,15 @@ async def terminate(self): self.logger.debug("Tearing down synthesizer") await self.synthesizer.tear_down() self.logger.debug("Terminating agent") + if ( + hasattr(self.agent.agent_config, "vector_db_config") + and self.agent.agent_config.vector_db_config + ): + # Shutting down the vector db should be done in the agent's terminate method, + # but it is done here because `vector_db.tear_down()` is async and + # `agent.terminate()` is not async. + self.logger.debug("Terminating vector db") + await self.agent.vector_db.tear_down() self.agent.terminate() self.logger.debug("Terminating output device") self.output_device.terminate()