# Loading Chat Context for Realtime Model

**URL:** <https://community.livekit.io/t/loading-chat-context-for-realtime-model/545>\
**Category:** Agents\
**Tags:** agent-development\
**Created:** [March 13, 2026, 6:44am UTC](https://community.livekit.io/t/loading-chat-context-for-realtime-model/545 "2026-03-13T06:44:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bikraj\_Shrestha](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/bikraj_shrestha/32/675_2.png) [@Bikraj\_Shrestha](https://community.livekit.io/u/Bikraj_Shrestha)\
**Post date:** [March 13, 2026, 6:44am UTC](https://community.livekit.io/t/loading-chat-context-for-realtime-model/545/1 "2026-03-13T06:44:16Z")

</div>

How do I load saved chat context for realtime models?  
I tried passing the chat context object while creating agent but that does not seem to be working.

---

<div class="post-metadata">

**Author:** ![darryncampbell](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/darryncampbell/32/20_2.png) [@darryncampbell](https://community.livekit.io/u/darryncampbell)\
**Post date:** [March 13, 2026, 9:55am UTC](https://community.livekit.io/t/loading-chat-context-for-realtime-model/545/2 "2026-03-13T09:55:35Z")

</div>

You can load the chat context when initializing the assistant with a realtime model as follows:

```auto
initial_chat_ctx = ChatContext()
initial_chat_ctx.add_message(role="user", content="My favourite colour is blue.")

# Start the session, which initializes the voice pipeline and warms up the models
await session.start(
    agent=Assistant(chat_ctx=initial_chat_ctx),
    ...

```

Then you can ask the agent what your favourite colour is.

---

<div class="post-metadata">

**Author:** ![Bikraj\_Shrestha](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/bikraj_shrestha/32/675_2.png) [@Bikraj\_Shrestha](https://community.livekit.io/u/Bikraj_Shrestha)\
**Post date:** [March 13, 2026, 10:20am UTC](https://community.livekit.io/t/loading-chat-context-for-realtime-model/545/3 "2026-03-13T10:20:34Z")

</div>

I have done exactly that.  
For context I am using gemini-2.5-flash-native-audio-preview-12-2025 model.  
But when I ask the model through text the model is able to answer questions based on older context but when I ask the same thing via audio the model is not able to answer at all.

---

<div class="post-metadata">

**Author:** ![darryncampbell](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/darryncampbell/32/20_2.png) [@darryncampbell](https://community.livekit.io/u/darryncampbell)\
**Post date:** [March 13, 2026, 10:54am UTC](https://community.livekit.io/t/loading-chat-context-for-realtime-model/545/4 "2026-03-13T10:54:11Z")

</div>

That’s interesting, using that model I also see that the context is not picked up. My above code works with OpenAI realtime.

I did look into workarounds, but after doing a bit of digging, I think the most reliable approach for gemini would be to include any required context in your instructions.

---

<div class="post-metadata">

**Author:** ![Bikraj\_Shrestha](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/bikraj_shrestha/32/675_2.png) [@Bikraj\_Shrestha](https://community.livekit.io/u/Bikraj_Shrestha)\
**Post date:** [March 13, 2026, 11:12am UTC](https://community.livekit.io/t/loading-chat-context-for-realtime-model/545/5 "2026-03-13T11:12:16Z")

</div>

I have done the same with fallback to a tool(just in case).  
Were you able to find any Github issue linked to it?

---

<div class="post-metadata">

**Author:** ![darryncampbell](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/darryncampbell/32/20_2.png) [@darryncampbell](https://community.livekit.io/u/darryncampbell)\
**Post date:** [March 16, 2026, 8:58am UTC](https://community.livekit.io/t/loading-chat-context-for-realtime-model/545/6 "2026-03-16T08:58:59Z")

</div>

I don’t see anything, the repository is here: [GitHub · Where software is built](https://github.com/livekit/agents/issues)
