how to get the call summary using *`get_job_contex...
# ask-ai
m
how to get the call summary using
get_job_context
at on_ext function
t
Thanks for reaching out, Rajadurai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! Could you help me understand a bit more about what you mean by the
on_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.py
m
How to update chatcontext using job context
t
To update the chat context using the job context in LiveKit, you can use the
agent.update_chat_ctx()
method. This is a great way to dynamically adjust the agent's conversation history while your program is running. Basic Usage:
Copy code
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