Outputs
How Daydreams agents send information and responses.
What is an Output?
An output is how your agent sends information to the outside world. If actions are what your agent can "do", outputs are how your agent "speaks" or "responds".
Real Examples
Here are outputs that make agents useful:
Discord Message
Console Print
Email Notification
The Problem: Agents Need to Communicate
Without outputs, your agent can think but can't communicate:
The Solution: Outputs Enable Communication
With outputs, your agent can respond properly:
How Outputs Work in Your Agent
1. You Define How the Agent Can Respond
2. The LLM Decides When to Respond
When the agent thinks, it sees:
3. The LLM Uses Outputs to Respond
The LLM responds with structured output calls:
4. Daydreams Sends the Output
Daydreams automatically:
- Validates the output format
- Runs your handler function
- Actually sends the Discord message
- Logs the result
Creating Your First Output
Here's a simple output that saves messages to a file:
Use it in your agent:
Working with Context Memory
Outputs can read and update your agent's memory:
Outputs vs Actions: When to Use Which?
Understanding the difference is crucial:
Use Outputs When:
- Communicating results to users or external systems
- You don't need a response back for the LLM to continue
- Final step in a conversation or workflow
Use Actions When:
- Getting data the LLM needs for next steps
- You need the result for further reasoning
- Middle step in a complex workflow
Common Pattern: Actions → Outputs
Advanced: Multiple Outputs
Your agent can send multiple outputs in one response:
External Service Integration
Outputs are perfect for integrating with external services:
Best Practices
1. Use Clear Types and Descriptions
2. Validate Input with Schemas
3. Handle Errors Gracefully
4. Use Async/Await for External Services
5. Provide Good Examples
Key Takeaways
- Outputs enable communication - Without them, agents can think but not respond
- LLM chooses when to use them - Based on types and descriptions you provide
- Different from actions - Outputs communicate results, actions get data
- Content and attributes validated - Zod schemas ensure correct format
- Memory can be updated - Track what was sent for future reference
- Error handling is crucial - External services can fail, handle gracefully
Outputs complete the conversation loop - they're how your intelligent agent becomes a helpful communicator that users can actually interact with.