wonderful-wolf-51568
11/29/2025, 1:36 PMtall-airline-16756
11/29/2025, 1:37 PMtall-airline-16756
11/29/2025, 1:37 PMawait agent.update_chat_ctx(chat_ctx).
Example (Python):
from livekit.agents import ChatContext, ChatMessage
# create the new message
new_message = ChatMessage(role="user", content="This is a manually added message.")
# copy current context, add the message
chat_ctx = agent.chat_ctx.copy()
chat_ctx.add_message(new_message)
# push the update so the agent sees it immediately
await agent.update_chat_ctx(chat_ctx)
Notes:
• Do not modify agent.chat_ctx.messages directly; those changes are not guaranteed to be processed.
• You can also seed chat_ctx when starting the session, but runtime changes require update_chat_ctx(). Sources: Agents v0.x migration guide - Python | LiveKit docs | External data and RAG | LiveKit Docswonderful-wolf-51568
11/29/2025, 1:42 PMtall-airline-16756
11/29/2025, 1:42 PM_chat_ctx directly. It's an internal/private attribute and modifying it can cause inconsistent state or undefined behavior.
Use agent.update_chat_ctx() (or the agent's provided update_chat_ctx call) to push changes so the agent processes them immediately. Example reminder:
chat_ctx = agent.chat_ctx.copy()
chat_ctx.add_message(ChatMessage(role="user", content="..."))
await agent.update_chat_ctx(chat_ctx)
If you'd like, I can show how to add multiple messages at once or how to seed the context at session start.
Sources: Agents v0.x migration guide - Python | LiveKit docs