Overview
Workflows provide a powerful, event-driven framework for building agentic applications. They replace the deprecated agent implementations with a more flexible and composable approach.Installation
Basic Workflow
Events
Workflows are event-driven:StartEvent
Initiates the workflow:StopEvent
Terminates the workflow:Custom Events
Define custom events for workflow steps:Context
Manage workflow state with Context:Streaming
Stream events from workflows:Agent Workflow
Build agents with workflows:Multi-Step Workflows
Chain multiple steps:Best Practices
- Use events for communication: Define clear event types
- Manage state with Context: Store intermediate results
- Stream for long operations: Better UX for lengthy workflows
- Handle errors gracefully: Implement error events and handling
- Compose workflows: Build complex workflows from simpler ones
- Type your events: Use Zod schemas for type safety