Skip to content

Event Types

Every SSE event has a type field that identifies what kind of event it is. Events are defined as Pydantic models in dockrion_events/models.py.

TypeClassCategoryDescription
startedStartedEventMandatoryRun started. Contains agent_name and framework.
completeCompleteEventMandatoryRun finished. Contains output, latency_seconds, metadata.
errorErrorEventMandatoryRun failed. Contains error message, code, details.
cancelledCancelledEventMandatoryRun was cancelled. Contains reason.
progressProgressEventConfigurableProgress update. Contains step, progress (0.0–1.0), message.
tokenTokenEventConfigurableStreaming token. Contains content, optional finish_reason.
stepStepEventConfigurableGraph node completed. Contains node_name, duration_ms, input_keys, output_keys.
checkpointCheckpointEventConfigurableCheckpoint saved. Contains name, data.
heartbeatHeartbeatEventConfigurableKeep-alive signal. No extra fields.

Mandatory events (started, complete, error, cancelled) are always emitted regardless of event configuration. They define the run lifecycle.

Configurable events can be included or excluded using presets or explicit lists.

Every event includes:

FieldTypeDescription
idstringUnique event ID (auto-generated UUID)
typestringEvent type name
run_idstringRun this event belongs to
sequenceintMonotonic sequence number within the run
timestampstringISO 8601 UTC timestamp

TERMINAL_EVENT_TYPES = {"complete", "error", "cancelled"}

When a terminal event is received on an SSE connection, the client should expect the connection to close.

Configure which events are emitted using the streaming.events.allowed field:

streaming:
events:
allowed: chat # preset name or explicit list
PresetIncluded Events
minimal(mandatory only)started, complete, error, cancelled
chattoken + mandatory
debugtoken, step, progress, checkpoint, heartbeat + mandatory
allAll event types + mandatory

Instead of a preset, you can specify individual event types:

streaming:
events:
allowed:
- token
- progress
- heartbeat

Mandatory events are always included even if not listed.

Your agent can emit custom events using the custom: prefix:

streaming:
events:
allowed:
- token
- custom # allow ALL custom events
- custom:my_event # or allow specific custom events

Custom event names must match ^[a-zA-Z_][a-zA-Z0-9_]*$.

To emit custom events from your agent code, use StreamContext.emit() — see StreamContext.

streaming:
events:
heartbeat_interval: 15 # seconds between heartbeats (1–300)
max_run_duration: 3600 # max run lifetime in seconds (1–86400)
FieldTypeDefaultRangeDescription
heartbeat_intervalint151–300Seconds between heartbeat events
max_run_durationint36001–86400Maximum run duration before timeout

Each event is serialized to SSE format by BaseEvent.to_sse():

event: token
data: {"id":"evt_abc","type":"token","run_id":"run_123","sequence":5,"timestamp":"2025-01-15T10:30:05Z","content":"Hello","finish_reason":null}

Source: Event models in packages/events/dockrion_events/models.py; EventsFilter in packages/events/dockrion_events/filter.py; StreamingEventsConfig in packages/schema/dockrion_schema/dockfile_v1.py


Previous: Async Runs | Next: Backends →