From 35538107d4376b7c1c7fd4cdd73d4d7671104268 Mon Sep 17 00:00:00 2001 From: martin-purplefish Date: Tue, 8 Oct 2024 14:09:48 -0400 Subject: [PATCH] handle llm stream returning false (#865) --- .changeset/yellow-eggs-shout.md | 5 +++++ livekit-agents/livekit/agents/pipeline/pipeline_agent.py | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/yellow-eggs-shout.md diff --git a/.changeset/yellow-eggs-shout.md b/.changeset/yellow-eggs-shout.md new file mode 100644 index 000000000..58df4025f --- /dev/null +++ b/.changeset/yellow-eggs-shout.md @@ -0,0 +1,5 @@ +--- +"livekit-agents": patch +--- + +Fixed bug where agent would freeze if before_llm_cb returned false diff --git a/livekit-agents/livekit/agents/pipeline/pipeline_agent.py b/livekit-agents/livekit/agents/pipeline/pipeline_agent.py index 4053d26e6..27ca5d0b9 100644 --- a/livekit-agents/livekit/agents/pipeline/pipeline_agent.py +++ b/livekit-agents/livekit/agents/pipeline/pipeline_agent.py @@ -552,6 +552,7 @@ async def _synthesize_answer_task( llm_stream = self._opts.before_llm_cb(self, copied_ctx) if llm_stream is False: + handle.interrupt() return if asyncio.iscoroutine(llm_stream):