I'm debugging conversation history in LiveKit Agents and found something strange with session.history.items. I'm building an interview agent that makes separate LLM evaluation calls on each user turn (not using the built-in chat flow), and the user messages aren't appearing in session.history.
My setup:
python
Apply to total_agent....
# I create separate ChatContext objects and call llm.chat() for evaluation
async def on_user_turn_completed(self, _turn_ctx_, _new_message_):
eval_chat_ctx = ChatContext()
eval_chat_ctx.add_message(role="system", content=self.system_prompt)
# Try to get conversation history
for item in self.session.history.items:
print(f"Item: role={item.role}, content={item.text_content}")
Debug output shows:
text
Apply to total_agent....
=== DEBUG: RAW SESSION.HISTORY ITEMS ===
Item 0: role=assistant, text_content='Can you describe your overall experience...'
Item 1: role=assistant, text_content='How did attending this concert meet or differ...'
Item 2: role=assistant, text_content='Based on this experience, how likely are you...'
=== END RAW SESSION.HISTORY ===
But LiveKit logs show user transcripts ARE being received:
text
Apply to total_agent....
DEBUG livekit.agents - received user transcript {"user_transcript": "Sure.", "language": "en"}
DEBUG livekit.agents - received user transcript {"user_transcript": "Let's see. I really like the concert overall...", "language": "en"}
Question: Does session.history only maintain conversation history when using the standard agent chat flow? Since I'm making custom LLM calls instead of using the built-in conversation management, are user messages not being added to session.history? How should I access the complete conversation history including user responses in this setup?