Skip to main content

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
Think of agents as musicians and ensembles as the sheet music that coordinates them.

Explore the Template Ensemble

Your project includes a working ensemble! Let’s explore ensembles/hello-world.yaml:
This ensemble:
  1. Defines a CLI trigger (conductor run hello)
  2. Calls the hello agent (from agents/examples/hello/)
  3. Returns its output as greeting

Run It

The template includes a test in tests/basic.test.ts:
Run the tests:

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 the AgentExecutionContext 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):
Result: Agent receives 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:
  1. Import AgentExecutionContext:
  2. Change signature to accept { input, env, ctx }:
  3. Destructure your parameters from input:
That’s it! Your agent now works everywhere: ensembles, direct calls, and tests.
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

Create ensembles/greeting-workflow.yaml:

Step 2: Test It

Create tests/greeting-workflow.test.ts:
Run: pnpm test

Auto-Discovery (v1.12+)

Zero-Config Ensemble Loading: Ensembles in the ensembles/ directory are automatically discovered at build time.

How It Works

Just create a YAML file in ensembles/ - no imports or registration needed! Step 1: Create ensembles/my-workflow.yaml
Step 2: Rebuild
Step 3: Execute via API
That’s it! No imports, no registration, just create the YAML file.

Using Auto-Discovery API

The recommended way to use ensembles is with createAutoDiscoveryAPI():
This provides:
  • POST /api/v1/execute/ensemble/{name} - Execute an ensemble by name
  • POST /api/v1/execute/agent/{name} - Execute an agent directly (if enabled)
  • GET /api/v1/ensembles - List all ensembles
  • GET /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 *.yaml files in ensembles/
  • ✅ Nested directories: ensembles/workflows/user-onboarding.yaml
  • ✅ Cron triggers from ensemble configs
Not Discovered:
  • ❌ 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:
This is fine! Manual execution is supported alongside auto-discovery. See the Auto-Discovery guide for complete details.

Flow Control

Sequential Execution (Default)

Agents run one after another:
⏱️ Total time: fetch + process + store

Parallel Execution

Agents run simultaneously:
⏱️ Total time: max(spam, hate, explicit) + aggregate How Conductor determines parallelism:
  • 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:
Cost optimization: Skip expensive operations when possible!

Loops

Process arrays of items:

Retry Logic

Automatically retry failed operations:

Real-World Example: Content Moderation

Let’s build a complete content moderation pipeline:
Cost optimization achieved:
  • 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:
Parallel for independence:

6. Test Everything

Troubleshooting

Problem: Agent 'my-agent' not foundFix: Ensure agent is registered or exists in agents/ directory:
Problem: Cannot read property 'output' of undefinedFix: Check variable references:
Problem: Agents run sequentially even though they shouldn’tReason: One agent depends on another’s outputFix: Remove dependencies:
Problem: Execution exceeds time limitFixes:
  1. Use caching for slow operations
  2. Run independent checks in parallel
  3. Skip expensive operations when possible
  4. 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

Benefits of TypeScript Ensembles

When to Use Each

Use YAML when:
  • Quick prototyping
  • Simple linear workflows
  • Non-developers editing workflows
  • Maximum readability
Use TypeScript when:
  • 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

  1. KV Cache (operation level):
  1. AI Gateway (automatic for AI providers):
  1. Ensemble Results (application level):

Cost vs Speed

Fast + Expensive (parallel):
Slow + Cheap (sequential with filtering):
Choose based on your priorities!