Skip to main content

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

  1. Use events for communication: Define clear event types
  2. Manage state with Context: Store intermediate results
  3. Stream for long operations: Better UX for lengthy workflows
  4. Handle errors gracefully: Implement error events and handling
  5. Compose workflows: Build complex workflows from simpler ones
  6. Type your events: Use Zod schemas for type safety

See Also