Skip to content

[Playground] Support Dynamic Agent Lookup for Non-Static Agent Configurations #72

Open
@apostolisCodpal

Description

@apostolisCodpal

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:

  1. Custom Tools: Each customer may have different integrations enabled
  2. Custom Prompts: Industry-specific language, compliance requirements, or brand voice
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions