Streams
Project-scoped data stores with schema versioning for persisting and querying graph outputs.
Streams are project-scoped data stores that persist the outputs of your graph executions. Each stream has a versioned schema and supports queries with filtering, sorting, and pagination. Use streams to accumulate structured data over time and to inject stored context into downstream graph nodes.
Overview
- Project-scoped: Each stream belongs to a single project. Streams have a 1:1 relationship with graphs -- when a graph has an associated stream, exit node outputs are automatically persisted to it after each execution.
- Schema versioned: Stream schemas support draft and production versions. Define and iterate on a draft schema, then promote it to production when it is ready. This ensures that downstream consumers always read data in a known shape.
- Queryable: Query stream data with filter expressions, sort orders, limit, and offset. Stream nodes use these queries to retrieve the right slice of data at runtime.
- Toggleable: Streams can be enabled or disabled. Disabling a stream stops new data from being written without deleting existing records.
Creating and managing streams
Create and manage streams in the Portal under Storage > Streams, or through the API.
- Create a stream and define its schema. The schema specifies the fields and types that the stream stores. If you associate the stream with a graph, the schema is derived from the output schemas of that graph's exit nodes.
- Version the schema as your data shape evolves. Work on a draft version, then promote it to production. Previous versions remain available for reference.
- Enable or disable the stream to control whether new execution outputs are persisted.
How data flows into streams
When a graph with an associated stream completes execution, the outputs from its exit nodes are automatically written to the stream. You do not need to configure this manually -- the association between the graph and stream handles persistence.
This makes streams well suited for accumulating results over many executions: each run appends new records that you can query later.
Querying stream data
Stream data supports the following query parameters:
| Parameter | Description |
|---|---|
| filter | Restrict results to rows matching a condition (e.g. status = open, createdAt > 2024-01-01). |
| sort | Order results by one or more fields, each with an asc or desc direction. |
| limit | Cap the number of rows returned. |
| offset | Skip a number of rows for pagination. |
You can run queries from the Portal to browse stream data, or use stream nodes in a graph to query data at execution time.
Using streams in graphs
Stream nodes read from a stream and pass the results to downstream nodes. This enables "retrieve then reason" workflows where you fetch a relevant slice of stored data and feed it into an AI or code node.
- Add a stream node to your graph and select the target stream.
- Configure the query with optional filter, sort, limit, and offset parameters.
- Connect the stream node to downstream nodes. The query results become part of the input for the next step in the graph.
Set a limit to control how much context is sent to downstream nodes, and use sort to ensure the most relevant rows appear first.
Best practices
- Keep schemas stable. Use draft versions to iterate, and only promote to production when the schema is finalized. This prevents breaking changes for consumers of the stream data.
- Use filters to scope context. When injecting stream data into LLM nodes, filter for the most relevant records rather than sending everything. This improves response quality and reduces token usage.
- Set reasonable limits. Cap the number of rows returned by stream queries to avoid oversized payloads in your graph executions.
- Disable unused streams. If a graph no longer needs to persist outputs, disable the stream rather than deleting it to preserve historical data.
Related
- Stream node -- Configure stream nodes to query data within a graph.
- Graphs -- How exit node outputs are persisted to streams.
- Schemas -- Define data shapes for validation and type safety.