MastraM
Mastra•5d ago
Ata Sanchez

Dynamic agents with runtimeContext compatible with AI Studio testing??

Hello team, I'm using networkRoute to create a route compatible with the AI SDK in the following way:

networkRoute({
    path: '/quote-agent/chat',
    agent: 'quoteAgent',
}),


The problem is that in my DB, I store an "agentId" which is an internal identifier in my system, and with this, I want to inject the context information for that agent via requestContext (by performing queries to my DB). At least, this is the way I found to create "dynamic agents on demand" for my clients.
The issue is that when I use Studio to test my agent, I have no way to modify the payload I send in the POST request, so that in the middleware, I can get this information and use it to make modifications to the agent. Currently, what I've been doing is having a dynamic segment in the URL for networkRoute:

networkRoute({
    path: '/quote-agent/:my-agent-id/chat',
    agent: 'quoteAgent',
}),


But it doesn't feel right; it even feels hacky, and from Studio, I can't use that endpoint and test my agent properly.
So the question is: What would be the best approach to achieve this functionality while still being able to use Studio to test my agent?
Was this page helpful?