Advanced
Extensions vs Services
Understanding the difference between extensions and services in Daydreams.
What Are Extensions and Services?
Think of building an agent like assembling a computer:
- Services are like individual components (hard drive, graphics card, RAM)
- Extensions are like complete packages (gaming bundle, productivity suite)
Real Examples
Services: Individual Components
Extensions: Complete Packages
The Problem: Managing Complexity
Without this separation, you'd have to set up everything manually:
The Solution: Organized Architecture
With extensions and services, it's clean and simple:
How They Work Together
Services Handle the "How"
Services manage the technical details of connecting to external systems:
Extensions Handle the "What"
Extensions bundle all the features users actually want:
When to Use Each
Create a Service When:
- Managing an external connection (database, API client)
- Sharing utilities across multiple features
- Handling lifecycle management (startup, shutdown)
Create an Extension When:
- Bundling a complete feature set
- Adding support for a new platform (Discord, Twitter, etc.)
- Packaging related actions/contexts/inputs/outputs
Practical Example: Building a Trading Extension
Let's see how they work together in practice:
1. First, Create Services for External APIs
2. Then, Create Extension Using Those Services
3. Use the Extension in Your Agent
Architecture Summary
Key Differences
Aspect | Service | Extension |
---|---|---|
Purpose | Manages infrastructure | Provides features |
Contains | Connection logic, utilities | Actions, contexts, inputs, outputs |
Lifecycle | register() → boot() | install() when added |
Reusability | Used by multiple extensions | Used by agents |
Analogy | Computer component | Software package |
Best Practices
Service Design
Extension Design
Next Steps
- Extensions Guide - Learn to build your own extensions
- Built-in Extensions - See real extension examples
- Service Patterns - Advanced service techniques
Key Takeaways
- Services manage "how" - Connection setup, lifecycle, dependencies
- Extensions manage "what" - Features users actually want
- Clean separation - Infrastructure vs functionality
- Easy composition - Add extensions like LEGO blocks
- Automatic management - Framework handles the wiring
This architecture lets you build complex agents by combining simple, focused pieces.