icy-nightfall-64225
06/25/2025, 9:25 AMtall-airline-16756
06/25/2025, 9:25 AMtall-airline-16756
06/25/2025, 9:25 AMchat_ctx
parameter when initializing an agent. This ensures that the conversation history is retained across sessions.
Here’s how you can implement this:
1. When initializing an agent, pass the chat context from the previous session: class HelpfulAssistant(Agent):
def __init__(self, chat_ctx: ChatContext):
super().__init__(
instructions="You are a helpful voice AI assistant.",
chat_ctx=chat_ctx # This preserves the conversation history
)
2. When performing a handoff between agents, pass the chat context: @function_tool()
async def on_consent_given(self):
"""Use this tool to indicate that consent has been given and the call may proceed."""
# Pass the chat context during handoff
return HelpfulAssistant(chat_ctx=self.session.chat_ctx)
By default, each new agent starts with a fresh conversation history. To include the prior conversation, set the chat_ctx
parameter in the Agent
constructor. Additionally, the complete conversation history for the session is always available in session.history
, which you can access if needed.
Sources: Workflows | LiveKit Docs