Core Concepts
Three layers. Clean separation. Infinite flexibility.The Hierarchy
Components: Versioned Artifacts
Components are files that agents use during execution. Think of them as the “ingredients” that agents consume:- Prompts (
.md) - AI instructions and templates - Configs (
.json,.yaml) - Settings and parameters - Queries (
.sql) - Database queries - Scripts (
.js,.ts) - Reusable functions - Schemas (
.json) - Data validation rules - Templates (
.html,.md) - Output templates
Why Components Are Special
Each component gets its own version history.Example: Prompt Component
Agents: Workers That Execute
Agents are executable units that perform tasks. They use operations (execution primitives) and components (versioned artifacts) to get work done.Agent Anatomy
Operations: How Agents Execute
Operations are the execution primitives. Think of them as the “verb” of what an agent does:think
AI reasoning - LLMs, embeddings, classification
code
JavaScript/TypeScript - Business logic, transformations
storage
Database operations - KV, D1, R2, Vectorize
http
HTTP requests - External APIs, webhooks
tools
MCP/skills access - External capabilities via protocols
Email operations - Sending, templates
sms
SMS operations - Twilio, etc.
html
HTML rendering - Dynamic pages
PDF generation - Reports, invoices
page
Full-stack pages - Complete web pages with forms
Custom vs Pre-built Agents
Custom Agents - You define them using operations:scraper- Web scraping with fallback strategiesvalidator- Quality scoring and validationrag- RAG pipeline with R2 storagehitl- Human-in-the-loop approvalfetcher- HTTP with retry logictransformer- Data transformationscheduler- Delayed/scheduled execution
Ensembles: Orchestration Workflows
Ensembles are YAML files that coordinate agents into workflows. They define what runs, in what order, and how data flows.Ensemble Anatomy
Flow Control
Sequential (default):State Management
Share data across agents using state:The Versioning Multiverse
Here’s where it gets powerful: components AND agents can both be versioned independently.Mix Versions Freely
A/B Testing Made Trivial
Test 2 agent versions × 3 prompt versions × 2 configs = 12 variants:Time Travel
Reproduce bugs from last week by deploying the exact versions that were running:Edge Architecture
Your ensembles run on Cloudflare Workers at 200+ global locations.Why Edge Matters
Traditional Orchestrators:- Centralized compute (single region)
- Slow cold starts (2-5 seconds)
- Scale requires infrastructure management
- Geographic latency
- Distributed compute (200+ regions)
- Fast cold starts (<50ms)
- Infinite scale (automatic)
- Near-zero latency globally
Built-in Caching
Three cache layers:- KV Cache - HTTP responses, agent outputs
- AI Gateway Cache - LLM responses (persistent across deployments)
- Durable Objects - Strongly consistent state for HITL and async workflows
What You Can’t Do (By Design)
Ensembles can’t use operations directly:Mental Model
Think of it like a restaurant:- Components = Recipes (versioned, can be updated independently)
- Agents = Chefs (execute using recipes and tools)
- Ensembles = Menu/Order (orchestrate which chefs make which dishes)
- Operations = Cooking techniques (grill, bake, sauté)
- Conductor = Kitchen manager (coordinates everything)

