Skip to main content

Overview

Auto-discovery is Conductor’s zero-config approach to loading agents and ensembles. Instead of manually importing and registering each agent, Conductor automatically discovers them from your project directory at build time.

Before Auto-Discovery

After Auto-Discovery

That’s it! All agents and ensembles are automatically discovered and registered.

How It Works

Auto-discovery uses Vite plugins that scan your project directory at build time and generate virtual modules containing all your agents and ensembles.

Quick Start

Installation

Auto-discovery is built into Conductor templates. If you’re starting a new project:
The template includes auto-discovery by default.

Manual Setup

If you have an existing project, add these plugins to vite.config.ts:

Using Auto-Discovery

Create your entry point (src/index.ts):

File Structure

Auto-discovery expects this structure:

What Gets Discovered

Pattern: agents/**/*.yamlIncluded: agents/examples/** (by default, set includeExamples: false to exclude)Excluded: agents/generate-docs/** (by default)Handler Detection: If agents/{name}/index.ts exists, it’s auto-loaded as the handlerExample:
Pattern: ensembles/**/*.yamlNo exclusionsExample:

API Reference

createAutoDiscoveryAPI(config)

Creates a Conductor API with auto-discovery.
AutoDiscoveryAPIConfig
Configuration options
boolean
default:true
Enable auto-discovery of agents and ensembles
AgentDefinition[]
Virtual agents module from virtual:conductor-agents
EnsembleDefinition[]
Virtual ensembles module from virtual:conductor-ensembles
AuthConfig
Authentication configuration
boolean
default:true
Enable request logging
CORSConfig
CORS configuration
Returns: ExportedHandler<Env>

getAgentLoader()

Get the initialized AgentLoader instance.
Returns: AgentLoader | null

getEnsembleLoader()

Get the initialized EnsembleLoader instance.
Returns: EnsembleLoader | null

Advanced Usage

Including/Excluding Examples

By default, agents in agents/examples/ are included in discovery. To exclude example agents:

Custom Exclusions

Exclude specific directories from agent discovery:

Custom File Extensions

Support .yml instead of .yaml:

Manual Loader Access

Use the loaders directly for advanced use cases:

Troubleshooting

Agents Not Found

Problem: Auto-discovery doesn’t find your agents Solution:
  1. Check file structure matches agents/**/*.yaml
  2. Ensure agents aren’t in excluded directories
  3. Check Vite plugin is registered in vite.config.ts
  4. Rebuild: pnpm run build

TypeScript Errors

Problem: Cannot find module 'virtual:conductor-agents' Solution: Add type declarations:

Build Errors

Problem: Build fails with “Directory not found” Solution: Create empty directories if needed:
The Vite plugins handle missing directories gracefully but some bundlers may require them to exist.

Migration Guide

From Manual Registration


Discovery Registries (ctx API)

In addition to auto-discovering agents and ensembles at build time, Conductor provides runtime access to discovery registries through the ctx API. This allows agents to introspect what’s available in the project.

ctx.agentRegistry

Access the agent registry to list and inspect available agents:

ctx.agentRegistry.list()

List all available agents in the project:

ctx.agentRegistry.get(name)

Get a specific agent definition:

ctx.ensembleRegistry

Access the ensemble registry to list and inspect available ensembles:

ctx.ensembleRegistry.list()

List all available ensembles in the project:

ctx.ensembleRegistry.get(name)

Get a specific ensemble definition:

ctx.config

Access the project’s Conductor configuration:

Complete Example: Dynamic Routing Agent

Complete Example: Documentation Generator

Use Cases

Discovery registries enable powerful introspection patterns:
  1. Dynamic Routing: Route requests to agents based on runtime conditions
  2. Documentation Generation: Auto-generate API docs from agent definitions
  3. Validation: Check if required agents exist before execution
  4. Monitoring: List all available capabilities for observability
  5. Development Tools: Build CLI tools that inspect project structure

Benefits

Zero Config

No manual imports or registration required

Fast Development

Add new agents by creating files—no code changes

Type Safe

Full TypeScript support with virtual module types

Production Ready

Build-time discovery ensures zero runtime overhead

Next Steps

Your First Agent

Create your first auto-discovered agent

Your First Ensemble

Create your first auto-discovered ensemble

Deployment

Deploy your auto-discovery project to production