With Python livekit agent SDK, is it possible to a...
# ask-ai
b
With Python livekit agent SDK, is it possible to access conversation_item_added event from the Agent class?
✅ 1
t
Thanks for reaching out, toshi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I see you want to know whether the Python LiveKit Agent SDK lets an Agent handle the
conversation_item_added
event. Yes — you can access
conversation_item_added
from within an
Agent
by registering a listener on the agent’s session (the agent has a
self.session
reference). Handlers registered there will be called whenever a new item (message or function call) is added to the conversation history, and the event includes an
item
field with the message content, role, and type. Example pattern you can use inside a custom Agent subclass:
Copy code
class MyAgent(Agent):
    async def on_enter(self):
        @self.session.on("conversation_item_added")
        def on_conversation_item_added(event):
            # event.item contains the new message/function call and metadata
            print(f"New item added: {event.item}")
If you’d like, tell me: • the exact Agent subclass or lifecycle hook you’re using (e.g.,
on_enter
,
on_message
) and • whether you need the handler to perform async work (so I can show the proper async handler pattern). Sources: Text and transcriptions | LiveKit Documentation | Realtime model metrics | LiveKit Documentation, with interactive elements