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
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:Manual Setup
If you have an existing project, add these plugins tovite.config.ts:
Using Auto-Discovery
Create your entry point (src/index.ts):
File Structure
Auto-discovery expects this structure:What Gets Discovered
Agents
Agents
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:Ensembles
Ensembles
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-agentsEnsembleDefinition[]
Virtual ensembles module from
virtual:conductor-ensemblesAuthConfig
Authentication configuration
boolean
default:true
Enable request logging
CORSConfig
CORS configuration
ExportedHandler<Env>
getAgentLoader()
Get the initialized AgentLoader instance.
AgentLoader | null
getEnsembleLoader()
Get the initialized EnsembleLoader instance.
EnsembleLoader | null
Advanced Usage
Including/Excluding Examples
By default, agents inagents/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:- Check file structure matches
agents/**/*.yaml - Ensure agents aren’t in excluded directories
- Check Vite plugin is registered in
vite.config.ts - 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: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 thectx 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:- Dynamic Routing: Route requests to agents based on runtime conditions
- Documentation Generation: Auto-generate API docs from agent definitions
- Validation: Check if required agents exist before execution
- Monitoring: List all available capabilities for observability
- 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

