Events & callbacks
Exact wire shapes: conversation events (polling and webhook delivery) and the autonomous callback payload, with status and error-code tables.
Context — The exact wire shapes the agent emits: conversation events (delivered via the polling stream and via event webhooks — with optional extra context on webhook delivery) and the autonomous callback payload.
Conversation events
A session's event log is an ordered stream; every event carries:
kind
string
Discriminator — one of the kinds below.
offset
integer
Monotonic position in the session. Resume with min_offset = last + 1; dedupe on (session_id, offset).
created_at
RFC 3339 timestamp
Server-side creation time.
In webhook delivery mode each event is POSTed individually to your endpoint with Authorization: Bearer <agent api key> and the originating session in the x-session-id header. Retries with backoff on transient failures.
agent_config.event_webhook.url overrides the SDK destination for conversational sessions only. Its include allowlists optionally add context.customer_id, context.session_metadata, and context.customer_variables to the raw event body. These values are read at delivery time; missing keys are omitted. Without selected fields, the payload is unchanged. The SDK parser ignores this extra context; read it from the raw JSON. See SDK integration.
user_message
offset
integer
yes
—
Monotonic position in the session's event log. Resume polling with min_offset = last seen offset + 1; dedupe on (session_id, offset).
created_at
string
yes
—
Server-side event creation time.
text
string
yes
—
Message body.
kind
string
no
"user_message"
{
"kind": "user_message",
"offset": 4,
"created_at": "2026-06-04T10:15:00Z",
"text": "Can I rent a van for Saturday?"
}preamble
offset
integer
yes
—
Monotonic position in the session's event log. Resume polling with min_offset = last seen offset + 1; dedupe on (session_id, offset).
created_at
string
yes
—
Server-side event creation time.
text
string
yes
—
Message body.
kind
string
no
"preamble"
assistant_message
offset
integer
yes
—
Monotonic position in the session's event log. Resume polling with min_offset = last seen offset + 1; dedupe on (session_id, offset).
created_at
string
yes
—
Server-side event creation time.
text
string
yes
—
Message body.
kind
string
no
"assistant_message"
status
Engine lifecycle signal — typing, processing, ready, etc.
offset
integer
yes
—
Monotonic position in the session's event log. Resume polling with min_offset = last seen offset + 1; dedupe on (session_id, offset).
created_at
string
yes
—
Server-side event creation time.
kind
string
no
"status"
status
string
yes
—
Lifecycle signal: acknowledged, typing, processing, ready, cancelled, or error.
stage
string
no
null
Sub-stage label shown alongside 'processing' (e.g. 'Thinking').
error_detail
string
no
null
Failure detail, populated only when status is 'error'.
tool
One tool event — contains every tool call from that batch.
offset
integer
yes
—
Monotonic position in the session's event log. Resume polling with min_offset = last seen offset + 1; dedupe on (session_id, offset).
created_at
string
yes
—
Server-side event creation time.
kind
string
no
"tool"
tool_calls
list[ToolCall]
yes
—
Every tool call the engine ran in this batch.
status values: acknowledged, typing, processing (with optional stage sub-label), ready, cancelled, error (with error_detail). UI mapping: Integrating the SDK.
Unknown kinds and message events without text should be ignored by consumers (the SDK's parsers already do).
Autonomous trigger request
Body of POST /routines/{routine_id}/trigger — see the HTTP API for the endpoint semantics:
input
dict[string, JsonValue]
no
—
Validated against the routine's input_schema.
callback_url
string
yes
—
URL that receives the AutonomousCallbackPayload when the run settles.
session_id
string
no
null
Reuse an existing session. If omitted an ephemeral session + customer are created and deleted after the callback settles.
idempotency_key
string
no
null
Replay-safe key — duplicates return the prior run.
metadata
dict[string, JsonValue]
no
—
Opaque caller metadata echoed back in the callback payload.
Autonomous callback payload
POSTed once to the trigger's callback_url when the run settles (succeeds, fails, or times out), with Authorization: Bearer <agent api key>. Dedupe deliveries by run_id.
AutonomousCallbackPayload
Payload delivered to callback_url when a run settles.
schema_version
integer
no
1
Wire schema version of this payload.
run_id
string
yes
—
Unique id of this run — dedupe callbacks on it.
routine_id
string
yes
—
Id of the routine that was triggered.
status
AutonomousRunStatus
yes
—
Settled run status. Callbacks only carry the terminal values 'succeeded' or 'failed'.
output
dict[string, JsonValue]
no
null
Routine's typed output, matching its output_schema. Present only when status is 'succeeded'.
error
AutonomousRunError
no
null
Structured error detail. Present only when status is 'failed'.
session_id
string
yes
—
Session the run executed in — the caller's session_id if reused, else the server-created ephemeral one.
trace_id
string
no
null
Tracing id for correlating this run's logs/traces.
started_at
string
yes
—
When the run began executing.
completed_at
string
yes
—
When the run settled (success, failure, or timeout).
metadata
dict[string, JsonValue]
no
—
Caller-supplied metadata from the trigger request, echoed back verbatim.
idempotency_key
string
no
—
Random id generated for this callback delivery; stable across the delivery's own HTTP retries. Unrelated to the trigger request's idempotency_key, which dedupes runs, not deliveries.
origin_service
string
no
"agent-server"
Identifies the service that sent this callback.
status values: accepted, running, succeeded, failed (callbacks carry only the settled states succeeded / failed).
Error codes (error.code when status is failed)
timeout
Run exceeded its timeout_seconds.
engine_error
Internal engine failure during the run.
tool_error
A tool call failed irrecoverably.
output_validation_failed
The final output violated the routine's output_schema (details carry the JSON path).
input_validation_failed
The input payload violated input_schema.
session_error
Session preparation or engine dispatch failed.
max_engine_iterations_reached
The engine hit max_engine_iterations before emit_output was called.
error is an object: {code, message, details} — details is a code-specific object (e.g. the violating JSON path for validation failures).
Example — success:
Example — failure:
Last updated
Was this helpful?

