big-army-80496
09/29/2025, 11:41 AM@session.on("agent_speech_committed") on Agents Python 1.x? I am migrating from Agent Python 0.x
user_turn_completed seems relevant but this is for the user, not the agenttall-airline-16756
09/29/2025, 11:41 AMtall-airline-16756
09/29/2025, 11:41 AM@session.on("agent_speech_committed") is actually the conversation_item_added event. This event fires whenever a message—whether from the user or the agent—is added to the chat history.
If you'd like to specifically handle messages from the agent, here’s a friendly approach you can try:
from livekit.agents import ConversationItemAddedEvent
@session.on("conversation_item_added")
def on_conversation_item_added(event: ConversationItemAddedEvent):
# Check if the message is from the agent
if event.item.role == "assistant":
print(f"Agent speech committed: {event.item.text_content}")
Just so you know, the item property on the event gives you access to the committed ChatMessage, including its content, role, and metadata. This is the best way to work with agent messages in Agents Python 1.x.
Sources: Text and transcriptions | LiveKit Docs | Docs::Agents