TheDocumentation Index
Fetch the complete documentation index at: https://agentrail.app/docs/llms.txt
Use this file to discover all available pages before exploring further.
stream_events method opens a server-sent event (SSE) connection and yields TaskLifecycleEvent Pydantic models as they arrive. Pass a StreamOptions instance to filter by event type, set a heartbeat interval, and resume from a cursor after reconnection.
Basic usage
async for loop runs until the server closes the stream or an error is raised. Each event is a validated TaskLifecycleEvent with id, type, and data fields.
Reconnect with a cursor
After a disconnect, pass the last received event ID ascursor to resume the stream without missing events:
Event types
TaskEventType value | String value | When it fires |
|---|---|---|
TaskEventType.TASK_UPDATED | task.updated | The task’s status, branch, or metadata changed |
TaskEventType.TASK_REVIEWED | task.reviewed | A review decision was posted |
TaskEventType.TASK_SHIPPED | task.shipped | The task was shipped (merged and deployed) |
StreamOptions fields
| Field | Type | Description |
|---|---|---|
event_types | list[str] | None | Event type strings to subscribe to. None receives all types. |
task_id | str | None | Scope the stream to a single task. |
cursor | str | None | Resume from this event ID. |
heartbeat_seconds | int | None | Interval for server-sent heartbeat pings. |
Required scope
Streaming events requires theevents:read scope on your API key. A missing scope raises an InsufficientScopeError before the stream opens..png?fit=max&auto=format&n=TNCV8lxzL1ij3U4N&q=85&s=7345b71aa1c450c74f35b67c2655fc43)