Why doesn't on_user_turn_completed fire in chat mode?

This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.

In chat mode, on_user_turn_completed doesn’t get called. Messages go directly to the LLM for a response.

Has anyone experienced this issue?

on_user_turn_completed is for voice mode only.

For text messages, use custom_text_input_handler:

from livekit.agents.voice.room_io import TextInputEvent

def custom_text_input_handler(session: AgentSession, event: TextInputEvent) -> None:
    logger.info(f"Custom text input handler: {event.text}")
    # Default behavior: interrupt and generate reply
    session.interrupt()
    session.generate_reply(user_input=event.text)

async def entrypoint(ctx: JobContext):
    session = AgentSession()
    await session.start(
        agent=MyAgent(),
        room=ctx.room,
        room_input_options=RoomInputOptions(text_input_cb=custom_text_input_handler)
    )