Description
I was very excited with the playground setup. It's exactly the kind of thing we need to scale our apps faster but never have the time to build - audit/investigation tools. Unfortunately I cannot use it in my case because my agents are not "static". This is a feature request to accommodate users such as myself.
Current Behavior
Currently, definePlaygroundAPI
requires a static array of agents to be passed at initialization:
export function definePlaygroundAPI(
component: AgentComponent,
options: {
agents: Agent<ToolSet>[];
userNameLookup?: <DataModel extends GenericDataModel>(
ctx: GenericQueryCtx<DataModel>,
userId: string
) => string | Promise<string>;
}
)
Problem
This design assumes all agents are known and configured at build time. However, in many production scenarios, agents need to be:
- Configured dynamically based on user permissions/roles
- Loaded from database configurations
- Created with user-specific tools or instructions
Proposed Solution
Modify the API to support both static and dynamic agent configurations:
export function definePlaygroundAPI(
component: AgentComponent,
options: {
userNameLookup?: <DataModel extends GenericDataModel>(
ctx: GenericQueryCtx<DataModel>,
userId: string
) => string | Promise<string>;
} & ({
agents: Agent<ToolSet>[];
} | {
agentsLookup: (
ctx: GenericQueryCtx<GenericDataModel>,
userId: string
) => Agent<ToolSet>[] | Promise<Agent<ToolSet>[]>;
})
)
Use Cases
SaaS Platforms with Customer-Specific Agent Configurations
In multi-tenant SaaS applications, each customer organization needs agents tailored to their specific:
- Custom Tools: Each customer may have different integrations enabled
- Custom Prompts: Industry-specific language, compliance requirements, or brand voice
- Custom Configurations: Different context windows, temperature settings, or model selections
Backwards Compatibility
This change maintains backwards compatibility as the existing agents
array option would continue to work exactly as before.