We're using ChatContext.copy() to include conversa...
# ask-ai
s
We're using ChatContext.copy() to include conversation history in a separate LLM evaluation call, but we need to verify that both the conversation history AND our prompts are being passed correctly to the LLM. Our code: python Apply to total_agent.... # Copy conversation history from current session eval_chat_ctx = turn_ctx.copy( _exclude_function_call_=True, _exclude_empty_message_=True, _exclude_instructions_=False ) # Add new user message and evaluation prompts eval_chat_ctx.add_message(role="user", content=new_message.text_content) eval_chat_ctx.add_message(role="system", content=self.system_prompt) eval_chat_ctx.add_message(role="user", content=custom_user_prompt) # Make LLM call llm = openai.LLM(model="gpt-4o") llm_stream = llm.chat(_chat_ctx_=eval_chat_ctx) Questions: 1. Does ChatContext.copy() actually include the conversation history in the copied context? 2. How can we verify/log what messages are actually in a ChatContext object? (We tried eval_chat_ctx.messages but got AttributeError) 3. Is there a way to inspect the complete context being sent to the LLM for debugging purposes, including both the copied conversation history AND our added prompts? 4. When we add new messages after copying, does it append to the copied history or replace it? 5. How can we verify that our system prompt and user prompt are actually being included in the final LLM call? We need to confirm that our evaluation LLM is receiving both the full conversation context AND our evaluation prompts correctly."
t
Thanks for reaching out, Jason. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Here are answers to your questions: 1. Does ChatContext.copy() include the conversation history? Yes, it does! By default, it includes the conversation history unless you decide to use filters like
exclude_function_call
,
exclude_empty_message
, or
exclude_instructions
. 2. How can we verify/log what messages are in a ChatContext object? Great question! You can use the
toJSON()
method to get a neat JSON view of the context, or simply check out the
items
property to see the list of chat items directly. 3. How to inspect the complete context being sent to the LLM? If your LLM library supports it, turning on verbose or debug output is a handy way to log the raw prompt being sent. Another option is to serialize the
ChatContext
with
toJSON()
and take a look at the full structure. 4. When adding new messages to a copied ChatContext, does it append to the copied history? Yes! Any new messages you add will be appended to the copied history, and the original context stays just as it was. 5. How to verify that system and user prompts are included in the final LLM call? You can check the serialized context or enable verbose/debug output to make sure the system and user messages are part of the final LLM request. Feel free to reach out if you want me to explain anything further or help with anything else! Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | complex-agents/medical_office_triage/README.md | Workflows | LiveKit Docs | agents/src/llm/chat_context.test.ts | examples/src/basic_eou.ts