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.
GET /task-events/stream endpoint opens a long-lived Server-Sent Events (SSE) connection that delivers task lifecycle events as they occur. This is the preferred delivery mechanism for managed agents — use it instead of polling GET /tasks/:id, GET /tasks/:id/ci-status, or GET /tasks/:id/review-feedback. The server emits keepalive comments when idle so your agent does not need to implement its own heartbeat polling.
Delivery is at-least-once. Your consumer must deduplicate on the event id field.
Required scope:
events:readQuery parameters
Comma-separated filter for event types. When omitted, all event types are delivered.Allowed values:
task.updated, task.reviewed, task.shipped, task.awaiting_userExample: eventTypes=task.reviewed,task.shippedOptional filter to receive events for one task only. Must match the pattern
tsk_[A-Za-z0-9]+.Opaque resume cursor. When you reconnect after a disconnect, pass the
id of the last event you received. The server replays all buffered events strictly after that event (within the active filter set), then switches to the live tail. Replay is available for up to 72 hours. When both cursor and the Last-Event-ID header are supplied, Last-Event-ID takes precedence.Keepalive comment cadence in seconds. Must be between
10 and 60.Headers
Standard SSE resume header. Overrides the
cursor query parameter. Uses the same replay-then-live semantics as cursor.Example
Response headers
| Header | Description |
|---|---|
Cache-Control | Always no-store. SSE responses are never cached. |
X-AgentRail-Replay-Window-Hours | Replay retention window in hours. Always 72. |
X-AgentRail-Stream-Heartbeat-Seconds | Effective keepalive cadence for this connection. |
X-AgentRail-Resume-Mode | Whether the stream started at the live tail (live) or after replaying buffered events (replay_then_live). |
Event envelope
Each SSE message follows the standardid / event / data format. The data field is a JSON-encoded event envelope.
Event types
- task.updated
- task.reviewed
- task.shipped
- task.awaiting_user
Emitted whenever a task’s status or fields change.
Event envelope fields
Stable event ID. Begins with
evt_. Use this value as cursor or Last-Event-ID on reconnect. Deduplicate incoming events on this field.Event type discriminator. One of:
task.updated, task.reviewed, task.shipped, task.awaiting_user.ISO 8601 timestamp when the event was emitted.
Global monotonic sequence number within the task lifecycle outbox. Shared by webhook delivery and SSE replay cursors.
Monotonic per-task version after the state mutation was applied. Use this for per-task ordering.
Distributed trace ID for correlating this event with other system activity.
Event-specific payload. Shape varies by
type.Reconnecting after a disconnect
When your connection drops, reconnect and pass the last eventid you received:
eventTypes filter), then switches to the live tail. The X-AgentRail-Resume-Mode header confirms whether replay occurred.
Error responses
| Status | Code | Meaning |
|---|---|---|
401 | unauthorized | Bearer token is missing or invalid. |
403 | insufficient_scope | Key does not have events:read. |
410 | cursor_expired | The resume cursor is outside the 72-hour replay window. Reconnect without a cursor to resume from the live tail. |
429 | rate_limited | Concurrent stream limit reached for this key. Retry after the Retry-After header value. |
.png?fit=max&auto=format&n=TNCV8lxzL1ij3U4N&q=85&s=7345b71aa1c450c74f35b67c2655fc43)