miniature-nail-35141
10/24/2025, 8:39 AMget_job_context at on_ext functiontall-airline-16756
10/24/2025, 8:39 AMtall-airline-16756
10/24/2025, 8:40 AMon_ext function? Are you talking about:
• A custom extension function you’ve created?
• The on_enter method in Agent classes?
• An external integration callback?
• Or maybe a specific event handler?
Once I have a clearer picture, I’ll be able to guide you better and make sure we address your needs perfectly.
Sources: examples/voice_agents/session_close_callback.pyminiature-nail-35141
10/24/2025, 10:48 AMtall-airline-16756
10/24/2025, 10:50 AMagent.update_chat_ctx() method. This is a great way to dynamically adjust the agent's conversation history while your program is running.
Basic Usage:
async def entrypoint(ctx: JobContext):
await ctx.connect()
# Create and start agent session
session = AgentSession()
await session.start(agent=your_agent, room=ctx.room)
# Update chat context within the job
new_chat_ctx = agent.chat_ctx.copy()
new_chat_ctx.add_message(role="user", content=["New message"])
await agent.update_chat_ctx(new_chat_ctx)
Key Points:
• It's important to always copy the context first using agent.chat_ctx.copy() before making any changes.
• Be sure to handle exceptions like RealtimeError to keep everything running smoothly.
• Remember, the exclude_invalid_function_calls parameter (which defaults to True) helps exclude any invalid function calls.
If you have any questions or need a hand with the implementation, please don’t hesitate to ask—I’m here to help!
Sources: Agents v0.x migration guide - Python | LiveKit Docs | livekit-agents/livekit/agents/voice/generation.py | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki | agent/main.py