i am using following repo -&gt; <https://github.co...
# agents
s
l
in chat mode, it dosent hit on_user_turn_completed method,it directly goes to llm for reponse
has anyone experienced the same issue?
The on_user_turn_completed is for voice. For the text messages you can use custom_text_input_handler, https://docs.livekit.io/agents/build/text/#custom-handling
I can't find an example that shows this, but I modified our listen_and_respond agent to show the principle:
Copy code
"""
---
title: Listen and Respond
category: basics
tags: [listen, respond, openai, deepgram]
difficulty: beginner
description: Shows how to create an agent that can listen to the user and respond.
demonstrates:
  - This is the most basic agent that can listen to the user and respond. This is a good starting point for any agent.
---
"""

import logging
import os
from pathlib import Path
from dotenv import load_dotenv
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice import Agent, AgentSession
from livekit.plugins import silero
from livekit.agents import AgentSession, RoomInputOptions
from livekit.agents.voice.room_io import TextInputEvent

load_dotenv(dotenv_path=Path(__file__).parent.parent / '.env')

logger = logging.getLogger("listen-and-respond")
logger.setLevel(logging.INFO)

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)

class ListenAndRespondAgent(Agent):
    def __init__(self) -> None:
        super().__init__(
            instructions="""
                You are a helpful agent. When the user speaks, you listen and respond.
            """,
            stt="assemblyai/universal-streaming",
            llm="openai/gpt-4.1-mini",
            tts="cartesia/sonic-2:6f84f4b8-58a2-430c-8c79-688dad597532",
            vad=silero.VAD.load()
        )

    async def on_enter(self):
        self.session.generate_reply()
    async def on_user_turn_completed(self, turn_ctx, new_message):
        logger.info(f"User turn completed: {new_message.content}")

async def entrypoint(ctx: JobContext):
    session = AgentSession()

    await session.start(
        agent=ListenAndRespondAgent(),
        room=ctx.room,
        room_input_options=RoomInputOptions(text_input_cb=custom_text_input_handler)
    )

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))