prehistoric-alligator-43413
10/30/2025, 4:11 PMchat_ctx = ChatContext()
chat_ctx = chat_ctx.append(role="system", text=AGENT_INSTRUCTIONS)
chat_ctx = chat_ctx.append(role="user", text="Hello")tall-airline-16756
10/30/2025, 4:11 PMtall-airline-16756
10/30/2025, 4:11 PMChatContext class in LiveKit doesn’t have a direct append method built into its core. Instead, you’ll want to use the add_message() method to add messages to the context. Here’s a quick example:
chat_ctx.add_message(role="system", text=AGENT_INSTRUCTIONS)
That said, some examples or utilities might offer an append method just to make things a bit easier, but it’s not officially part of the core class. If you run into any trouble, I recommend sticking with add_message(). Please feel free to reach out if you have any more questions—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent.py | delay-handling/README.mdocprehistoric-alligator-43413
10/30/2025, 4:32 PMtall-airline-16756
10/30/2025, 4:33 PMChatContext.add_message() method doesn’t take a text argument. Instead, you’ll want to use the content argument to add your message. Here’s a little example to help you out:
chat_ctx.add_message(role="system", content=AGENT_INSTRUCTIONS)
The content argument is pretty flexible — it can be a string or even a list with text, images, or audio. If anything’s unclear or you want to dive deeper, just let me know. I’m here to help!
Sources: examples/drive-thru/test_agent.py