Best practice for injecting dynamic, non-conversational context in Gemini prompts?

Hi Gemini team,

I’m building a conversational app using the Gemini API and wanted to ask about the recommended way to inject dynamic contextual information that is not part of the conversation itself.

Examples of this context:

  • User profile information (e.g. name, preferences)

  • App or session state

  • Other dynamic data that can change over time and should be treated as current facts, not chat history

This context:

  • Needs to be provided on every prompt

  • Can change between turns

  • Should help the model reason correctly during the conversation

  • Should not be treated as conversational dialogue

I’m currently integrating Gemini via Flutter / Firebase AI, but this question is API-level and applies regardless of client SDK.

At the moment, the API supports systemInstruction and a list of Content, but there doesn’t seem to be a documented, first-class way to provide dynamic, non-conversational state.
Using systemInstruction doesn’t feel ideal since this data changes frequently, and injecting it as regular Content means it’s treated conversationally unless carefully labeled.

Questions:

  1. Is there an official or recommended pattern for injecting dynamic, non-conversational context (e.g. “current state”) into Gemini prompts?

  2. Is using labeled sections inside Content the intended approach today?

  3. Are there any best practices for keeping this context authoritative without polluting conversation history?

Any guidance would be appreciated — this seems like a common requirement for stateful or agent-style applications.

Thanks!

2 Likes

Hi! That’s very well said request I have last few months.
As far as I understand the model was taught to process messages of two roles (model/user).
Do you use live model or the regular one?

So what I do about it: I set in systemInstruction some rules of how to treat messages with different labels. Since they have thinking budget now, you could read if the model take into account your rules and tweak the prompt so it understand what you really want of it.

I’m glad to exchange more observation and definetly +1 to request for “best practices” from Google team.

1 Like

check these links:
1.

blog.jcz.dev/the-making-of-gemini-plays-pokemon

Pretty interesting and insightful

Hope it helps