If I do warm handoff using the code below, how do ...
# ask-ai
n
If I do warm handoff using the code below, how do I get the invited user's conversation item? It seems like only the initial user's conversation item is getting added and new user's conversation does not get added.
Copy code
await ctx.api.sip.create_sip_participant(
    api.CreateSIPParticipantRequest(
        room_name=ctx.room.name,
        sip_trunk_id=dispatch_metadata.outbound_trunk_id,
        sip_call_to=dispatch_metadata.dial_info,
        participant_identity=dispatch_metadata.dial_info,
        wait_until_answered=True,
    )
)
t
Thanks for reaching out, Hwuiwon. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When you want to grab the invited user's conversation item during a warm handoff, here are a few friendly ways to do it: • Check out the session history: You can use
session.history
to pull up the full conversation history, including all the invited user's messages. This way, you have everything you need for processing or summarizing the chat. • Keep an ear out for real-time events: The
conversation_item_added
event is great for catching new conversation items as they come in. Perfect if you want to handle things in real time or keep a log. • Share context during handoff: When you pass the session along, make sure to include the current session’s
chat_ctx
so the new agent has all the conversation context handy. If you'd like, I’m happy to share more details or examples on how to set these up. Just let me know! Sources: Workflows | LiveKit Docs | Events and error handling | LiveKit Docs | examples/warm-transfer/warm_transfer.py | Session recording and transcripts | LiveKit Docs
n
Yeah so in that
conversation_item_added
, only first user's input gets captured.
t
Hey there! To help figure out why only the first user's input is getting captured during the warm handoff, could you share a bit more about how you’ve set things up? Specifically: • Are you creating a new
AgentSession
each time, or are you reusing the one already in place during the handoff? • Is the
chat_ctx
(that’s the conversation context) being shared as is, or are you rebuilding it when a new user joins? • Have you added any custom tweaks in your handoff logic that might impact the session state or event listeners? Knowing these details will really help us get to the bottom of this and find the best fix for you. Sources: Events and error handling | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_session.py | plugins/openai/src/realtime/realtime_model.ts
n
I'm reusing the session. what do you mean about chat_ctx? Always include the code in your response
t
Hey there! The
chat_ctx
in LiveKit is super important because it keeps track of the conversation state and history during a session. It holds all the chat items like user messages, agent replies, and function calls, so everything flows smoothly. If you want to reuse a session, you can pass the
chat_ctx
from the previous session to the new agent to keep the conversation context intact. Here’s a quick example:
Copy code
new_agent = TechnicalSupportAgent(chat_ctx=previous_agent.session.chat_ctx)
This way, the new agent can see the full conversation history, making transitions feel seamless—perfect for warm handoffs. Feel free to ask if you want me to explain more or share examples tailored to your setup. I’m here to help! Sources: Agents 0.x migration guide | LiveKit Docs | tests/test_agent_session.py | Workflows | LiveKit Docs | main.py | Testing and evaluation | LiveKit Docs
n
But i'm not making the new agent
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
n
When new user connects, it would only add the existing user message and not new user message
Copy code
2025-08-28 09:25:42.795 | DEBUG    | runtime.conversation_item:_on_conversation_item_added:36 - Conversation item added: id='item_fc3cecc6f3a6' type='message' role='user' content=['Hello? Can you hear me?'] interrupted=False transcript_confidence=0.0 hash=None created_at=1756387542.794729
2025-08-28 09:25:58.371 | DEBUG    | runtime.conversation_item:_on_conversation_item_added:36 - Conversation item added: id='item_7ede9a57a433' type='message' role='user' content=['Hey. What can you do for me?'] interrupted=False transcript_confidence=0.0 hash=None created_at=1756387558.370979
@alert-easter-19258 hello