How can I apply filters to a Data Agent in the Conversational Analytics API?

I’m building with Google Cloud Conversational Analytics (Gemini Data Analytics) and I need a way to restrict or scope the data my Data Agent returns.

What I’m using

from google.cloud import geminidataanalytics

data_agent_client = geminidataanalytics.DataAgentServiceClient()
data_chat_client  = geminidataanalytics.DataChatServiceClient()

I can start a conversation like this:

messages = [
    geminidataanalytics.Message(
        user_message=geminidataanalytics.UserMessage(text=question)
    )
]

conversation_reference = geminidataanalytics.ConversationReference(
    conversation=data_chat_client.conversation_path(
        billing_project, location, conversation_id
    ),
    data_agent_context=geminidataanalytics.DataAgentContext(
        data_agent=data_chat_client.data_agent_path(
            billing_project, location, data_agent_id
        ),
        credentials=looker_credentials
    ),
)

request = geminidataanalytics.ChatRequest(
    parent=f"projects/{billing_project}/locations/{location}",
    messages=messages,
    conversation_reference=conversation_reference,
)

stream = data_chat_client.chat(request=request)
for response in stream:
    print(response)

What I need help with

I’d like to apply filters in a controlled way, either:

  1. When creating/updating the Data Agent so that every query it runs is automatically scoped (for example: always filter by region = 'EMEA'), or

  2. Dynamically per conversation so a user’s chat session can include temporary filters (like a date range) without depending on the LLM to infer them.

My question

Is there an officially supported way—agent-level or per-conversation—to attach filters like these when using the Python client?
Any code snippets, API fields, or best practices would be hugely appreciated!

Thanks in advance for any pointers or sample code

Hi @Vamsi_Panchada There isn’t an automatic way for the API to always apply filters, but you can handle it two ways: add a default filter when creating or updating the Data Agent so every query is scoped (like region = ‘EMEA’), or pass a filter in the DataAgentContext of your ConversationReference so it only applies to that conversation. Permanent rules go in the agent config, temporary ones go in the context.

Hi @a_aleinikov - i guess there is a no argument in datacontext to apply the filter and if we want to do it through some instructions there is a possibility that it can be bypassed through prompt injection