What’s an Ensemble?
An ensemble is a workflow that:- Orchestrates multiple agents
- Controls flow (sequential, parallel, conditional)
- Manages state across agents
- Maps outputs to final results
Explore the Template Ensemble
Your project includes a working ensemble! Let’s exploreensembles/hello-world.yaml:
- Defines a CLI trigger (
conductor run hello) - Calls the
helloagent (fromagents/examples/hello/) - Returns its output as
greeting
Run It
The template includes a test intests/basic.test.ts:
Template Syntax
Ensembles use${} for variable interpolation:
Access Input
Access Agent Outputs
Check Agent Status
Default Values with Fallbacks
Ternary Conditions
Array Access
Boolean Negation
Important: Agent Signatures for Ensembles
Critical: For agents to work in ensembles, they MUST use theAgentExecutionContext signature!
Why This Matters
When you reference an agent in an ensemble, Conductor calls it with this structure:Correct Agent Signature ✅
All agents used in ensembles must follow this pattern:What Happens If You Don’t?
Wrong signature (direct parameters):undefined values because ensemble passes { input: {...}, env, ctx } but agent expects direct parameters!
Quick Fix for Existing Agents
If your agent isn’t working in an ensemble:-
Import
AgentExecutionContext: -
Change signature to accept
{ input, env, ctx }: -
Destructure your parameters from
input:
See Agent Signatures in “Your First Agent” for detailed explanation.
Create Your First Ensemble
Let’s build a simple two-step workflow.Step 1: Create the Ensemble
Createensembles/greeting-workflow.yaml:
Step 2: Test It
Createtests/greeting-workflow.test.ts:
pnpm test
Auto-Discovery (v1.12+)
Zero-Config Ensemble Loading: Ensembles in theensembles/ directory are automatically discovered at build time.
How It Works
Just create a YAML file inensembles/ - no imports or registration needed!
Step 1: Create ensembles/my-workflow.yaml
Using Auto-Discovery API
The recommended way to use ensembles is withcreateAutoDiscoveryAPI():
POST /api/v1/execute/ensemble/{name}- Execute an ensemble by namePOST /api/v1/execute/agent/{name}- Execute an agent directly (if enabled)GET /api/v1/ensembles- List all ensemblesGET /api/v1/agents- List all agents- Automatic webhook and cron trigger handling
Execute Request Format
Execute an ensemble via the API:
Note: All /api/v1/* routes require authentication by default. See Security & Authentication for details.
Execute an agent directly (if allowDirectAgentExecution is enabled):
Discovery Rules
Auto-Discovered:- ✅ All
*.yamlfiles inensembles/ - ✅ Nested directories:
ensembles/workflows/user-onboarding.yaml - ✅ Cron triggers from ensemble configs
- ❌ README.md files
- ❌ Files outside
ensembles/directory
Verification
List all discovered ensembles:Testing with Auto-Discovery
In tests, you can still use manual registration for fine-grained control:Flow Control
Sequential Execution (Default)
Agents run one after another:Parallel Execution
Agents run simultaneously:- Agents with NO dependencies on each other → Run in parallel
- Agent depends on previous output → Wait for completion
Conditional Execution
Run agents only when conditions are met:Loops
Process arrays of items:Retry Logic
Automatically retry failed operations:Real-World Example: Content Moderation
Let’s build a complete content moderation pipeline:- Quick filter catches ~80% of bad content (free)
- AI only runs on remaining 20% (costs money)
- Result: 80% cost reduction!
Execute from Other Ensembles
You can call one ensemble from another using the HTTP operation:Best Practices
1. Start Simple, Add Complexity
2. Use Descriptive Names
- ✅
validate-input,fetch-user-data,send-notification - ❌
step1,step2,step3
3. Document Your Ensembles
4. Handle Errors
5. Optimize Costs
Sequential for dependencies:6. Test Everything
Troubleshooting
Agent not found
Agent not found
Problem:
Agent 'my-agent' not foundFix: Ensure agent is registered or exists in agents/ directory:Template syntax error
Template syntax error
Problem:
Cannot read property 'output' of undefinedFix: Check variable references:Parallel agents not running in parallel
Parallel agents not running in parallel
Problem: Agents run sequentially even though they shouldn’tReason: One agent depends on another’s outputFix: Remove dependencies:
Ensemble execution times out
Ensemble execution times out
Problem: Execution exceeds time limitFixes:
- Use caching for slow operations
- Run independent checks in parallel
- Skip expensive operations when possible
- Increase timeout (paid plan)
TypeScript Ensembles
Prefer TypeScript over YAML? You can create ensembles programmatically with full type safety, IDE autocomplete, and compile-time validation.Basic TypeScript Ensemble
TypeScript vs YAML Comparison
- TypeScript
- YAML
Benefits of TypeScript Ensembles
| Feature | YAML | TypeScript |
|---|---|---|
| Type safety | Runtime only | Compile-time |
| IDE autocomplete | Limited | Full support |
| Refactoring | Manual | Automated |
| Conditional logic | Expression strings | Native code |
| Reusable components | Copy/paste | Import/export |
When to Use Each
Use YAML when:- Quick prototyping
- Simple linear workflows
- Non-developers editing workflows
- Maximum readability
- Complex conditional logic
- Reusable step patterns
- Type safety is important
- IDE support needed
- Dynamic workflow generation
Validating TypeScript Ensembles
TypeScript ensembles are validated the same way as YAML:For complete TypeScript API documentation, see the TypeScript API Reference.
Next Steps
TypeScript API
Complete TypeScript reference
Flow Control
Master advanced flow patterns
State Management
Share data across agents
Playbooks
Real-world patterns
Performance Tips
Caching Layers
- KV Cache (operation level):
- AI Gateway (automatic for AI providers):
- Ensemble Results (application level):

