We are using livekit workflow multi-agent framework.
We noticed that during the agent transfer, if the user is speaking the state is stuck in speaking.
it never changes to listening after user silence or after agent handoff.
Attaching the transfer_to_agent fn definition,
@function_tool
async def transfer_to_agent(self, target_agent_id: str, run_ctx: RunContext):
“”"
Transfer to another agent.
“”"
# Disable interruptions during transfer
run_ctx.disallow_interruptions()
# Create new chat context (optional)
new_chat_ctx = self.chat_ctx.copy() if self.chat_ctx else None
# Create next agent
factory = self.agents_map[target_agent_id]
next_agent = await factory({"source_agent_id": self._agent_id})
# Apply chat context
if new_chat_ctx:
await next_agent.update_chat_ctx(
new_chat_ctx,
exclude_invalid_function_calls=False
)
# Pause current activity scheduling to avoid race conditions
if (
self.agent_session
and hasattr(self.agent_session, "_activity")
and self.agent_session._activity
):
self.agent_session._activity._scheduling_paused = True
return next_agent, None
livekit-agents = {version = "1.3.9” }