Using AI Agents parameters outside of the model's scope
Building an AI Agent in RavenDB is very much like defining a class, you define all the things that it can do, the initial prompt to the AI model, and you specify which parameters the agent requires. Like a class, you can create an instance of an AI agent by starting a new conversation with it. Each conversation is a separate instance of the agent, with different parameters, an initial user prompt, and its own history.
Here is a simple example of a non-trivial agent. For the purpose of this post, I want to focus on the parameters that we pass to the model.
var agent = new AiAgentConfiguration(
"shopping assistant",
config.ConnectionStringName,
"You are an AI agent of an online shop...")
{
Parameters =
[
new AiAgentParameter("lang",
"The language the model should respond with."),
new AiAgentParameter("currency", "Preferred currency for the user"),
new AiAgentParameter("customerId", null, sendToModel: false),
],
Queries = [ /* redacted... */ ],
Actions = [ /* redacted... */ ],
};As you can see in the configuration, we define the lang and currency parameters as standard agent parameters. These are defined with a description for the model and are passed to the model when we create a new conversation.
But what about the customerId parameter? It is marked as sendToModel: false. What is the point of that? To understand this, you need to know a bit more about how RavenDB deals with the model, conversations, and memory.
Each conversation with the model is recorded using a conversation document, and part of this includes the parameters you pass to the conversation when you create it. In this case, we don’t need to pass the customerId parameter to the model; it doesn’t hold any meaning for the model and would just waste tokens.
The key is that you can query based on those parameters. For example, if you want to get all the conversations for a particular customer (to show them their conversation history), you can use the following query:
from "@conversations"
where Parameters.customerId = $customerIdThis is also very useful when you have data that you genuinely don’t want to expose to the model but still want to attach to the conversation. You can set up a query that the model may call to get the most recent orders for a customer, and RavenDB will do that (using customerId) without letting the model actually see that value.

Comments
Comment preview
Join the conversation...