Skip to main content

Event data structures

Public Session and Thread event types, common fields, per-event field schemas, the stop reason object, and event delta stream frames.

Events returned by Session send, list, and stream endpoints (Send events, List events, Stream events, and Thread event endpoints) are JSON objects distinguished by type. Public responses expose only the documented public fields. For Session, resource, stats, usage, budget, and Thread object schemas, see Session data structures.

Common event fields

All public Event objects share the base fields below. The per-event sections that follow list only the fields specific to each event type:
FieldTypeDescription
idstringEvent ID with the evt_ prefix
typestringEvent type; see Public event types
processed_atstring | nullProcessing timestamp in RFC 3339 format. Populated once the event has been processed; many agent-generated events and pending receipts omit this field or return null

Public event types

List and stream endpoints currently expose 36 public event types:
CategoryEvent typesDescription
User & System (7)user.message, user.interrupt, user.tool_confirmation, user.tool_result, user.custom_tool_result, user.define_outcome, system.messageEvents that clients can submit via Send events
Agent (11)agent.message, agent.thinking, agent.tool_use, agent.tool_result, agent.mcp_tool_use, agent.mcp_tool_result, agent.custom_tool_use, agent.thread_context_compacted, agent.thread_message_sent, agent.thread_message_received, agent.artifact_deliveredAgent output, reasoning markers, tool calls, inter-thread messaging, and artifact delivery
Session lifecycle & metadata (8)session.status_running, session.status_idle, session.status_rescheduled, session.status_terminated, session.error, session.usage, session.updated, session.deletedSession-level status transitions, errors, usage snapshots, and updates
Thread lifecycle (5)session.thread_created, session.thread_status_running, session.thread_status_rescheduled, session.thread_status_idle, session.thread_status_terminatedThread status transitions in multi-agent and Advisor Sessions
Span (5)span.model_request_start, span.model_request_end, span.outcome_evaluation_start, span.outcome_evaluation_ongoing, span.outcome_evaluation_endExecution boundaries for model requests and Outcome evaluations

Client event request types

POST /api/v1/cloud/sessions/{session_id}/events accepts exactly these 7 event types:
TypeRequired fieldsNotes
user.messagecontentcontent must be a non-empty array of content blocks
user.interruptnonesession_thread_id is optional and is echoed as null when omitted
user.tool_confirmationtool_use_id, resultresult must be allow or deny; deny_message is optional
user.tool_resulttool_use_idReturns a built-in tool result from a self-hosted worker. content is optional; when present, it must be an array of content blocks. is_error is optional
user.custom_tool_resultcustom_tool_use_idReturns a client custom tool result. content is optional; when present, it must be an array of content blocks. is_error is optional
user.define_outcomedescription, rubricrubric is a text or file object; max_iterations is optional
system.messagecontentcontent must be a non-empty array of text content blocks, and must follow user.message, user.tool_result, or user.custom_tool_result

user.message

User input message supporting text and images.
FieldTypeDescription
contentarrayNon-empty array of text and/or image content blocks; see Message content blocks

user.interrupt

Interrupts the active Session turn or a specific Thread.
FieldTypeDescription
session_thread_idstring | nullOptional. Thread ID to interrupt; when omitted, interrupts the primary execution flow and echoes null

user.tool_confirmation

Submits an approval decision for a pending agent.tool_use or agent.mcp_tool_use.
FieldTypeDescription
tool_use_idstringRequired. The id of the corresponding agent.tool_use or agent.mcp_tool_use event
resultstringRequired. Decision: "allow" or "deny"
deny_messagestring | nullOptional. Allowed only when result is "deny"; supplying it (even null) when result is "allow" returns 400
session_thread_idstringResponse only (populated by the server). Thread ID owning the pending tool call; supplying it in the request returns 400

user.tool_result

Returns the execution result of a built-in tool from a self-hosted worker. When submitted, the service persists and returns an agent.tool_result event rather than a user.tool_result event.
FieldTypeDescription
tool_use_idstringRequired. The id of the corresponding agent.tool_use event
contentarrayOptional. Array of text, image, document, or search_result content blocks
is_errorboolean | nullOptional. Whether the tool execution failed

user.custom_tool_result

Returns the execution result of a client-side custom tool.
FieldTypeDescription
custom_tool_use_idstringRequired. The id of the corresponding agent.custom_tool_use event
contentarrayOptional. Array of text, image, document, or search_result content blocks
is_errorboolean | nullOptional. Whether the custom tool execution failed
session_thread_idstringResponse only (populated by the server). Thread ID owning the tool call; supplying it in the request returns 400

user.define_outcome

Defines an Outcome acceptance task for the Session. See Outcome Evaluation.
FieldTypeDescription
descriptionstringRequired. Task goal description, used as the input to the initial Agent turn
rubricobjectRequired. Acceptance rubric: {"type":"text","content":"..."} or {"type":"file","file_id":"file_..."} (up to 64 KiB; file rubrics cannot reference platform-generated artifact files directly)
max_iterationsinteger | nullOptional (1–20). Defaults to 3 when omitted or null; responses echo the effective value
outcome_idstringResponse only. Server-generated Outcome ID

system.message

Attaches a system instruction after a user message or tool result. At most one per request, placed last in the batch, immediately following user.message, user.tool_result, or user.custom_tool_result.
FieldTypeDescription
contentarrayRequired. Non-empty array of text content blocks

Message content blocks

events[].type identifies the event, content[].type identifies the content block, and an image's source.type identifies its source.
EventAccepted content[].typecontent requirements
user.messagetext, imageRequired, non-empty array; text and images may be mixed
system.messagetextRequired, non-empty array
user.tool_result, user.custom_tool_resulttext, image, document, search_resultOptional; when supplied, must be an array, which may be empty

User messages

All fields below are required. Use only the fields for the selected block type.
content[].typeFieldsDescription
texttype, texttext must be a non-empty, non-whitespace string
imagetype, sourcesource is one of the three formats below
All image source fields are strings:
source.typeRequired fieldsDescription
base64type, media_type, datamedia_type is image/png, image/jpeg, image/webp, or image/gif; data is raw Base64, with optional trailing = padding and no Data URL prefix
urltype, urlExternal HTTPS image URL readable by the model service; private, loopback, and other restricted destinations are rejected
filetype, file_idImage File ID from Upload file, readable by the current identity with status ready; supports PNG, JPEG, WebP, and GIF; platform-generated artifact files cannot be referenced directly (download and re-upload first)
Image limits:
  • Each request or turn input accepts at most 60 image blocks and at most 32 MiB of total image size; exceeding either limit returns 400. Use a Session model that supports image input.
  • Each Base64 value is limited to 10 MiB (10,485,760 bytes) of encoded text, with width and height each at most 8000 pixels. Use a File source when a single image's encoded length exceeds the limit.
  • Base64 and File images may be resized or compressed; URL images are fetched by the downstream model service.

User message examples

Each example is a single event object to place in the events array. Text:
{
  "type": "user.message",
  "content": [{"type": "text", "text": "Hello"}]
}
Base64 image:
{
  "type": "user.message",
  "content": [{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "<raw Base64 image data>"}}]
}
URL image:
{
  "type": "user.message",
  "content": [{"type": "image", "source": {"type": "url", "url": "https://example.com/image.png"}}]
}
File image:
{
  "type": "user.message",
  "content": [{"type": "image", "source": {"type": "file", "file_id": "file_..."}}]
}
See Send events for the endpoint.

Agent events

agent.message

Text response generated by the Agent.
FieldTypeDescription
contentarrayArray of text content blocks, each {"type": "text", "text": "..."}

agent.thinking

Marks a reasoning phase by the Agent. Contains no additional public fields beyond Common event fields; thinking content is not exposed.

agent.tool_use

Built-in tool call initiated by the Agent.
FieldTypeDescription
namestringTool name
inputobjectJSON arguments passed to the tool; {} when empty
evaluated_permissionstringPermission evaluation result: "allow", "ask", or "deny"
evaluationobjectOptional. Permission policy evaluation details (e.g., {"type":"always_allow"}, {"type":"always_ask"}, or {"type":"auto","evaluated_permission":{"type":"allow"|"ask"|"deny","reason_code":"..."}})
session_thread_idstringOptional. Present only when a child thread's pending tool call is surfaced on the primary Session stream

agent.tool_result

Execution result of a built-in tool call.
FieldTypeDescription
tool_use_idstringThe id of the paired agent.tool_use event
contentarrayArray of tool result content blocks
is_errorbooleanWhether the tool execution failed

agent.mcp_tool_use

MCP tool call initiated by the Agent.
FieldTypeDescription
mcp_server_namestringMCP server name
namestringMCP tool name
inputobjectJSON arguments passed to the tool; {} when empty
evaluated_permissionstringPermission evaluation result: "allow", "ask", or "deny"
evaluationobjectOptional. Permission policy evaluation details, same shape as agent.tool_use.evaluation
session_thread_idstringOptional. Present only when a child thread's pending MCP tool call is surfaced on the primary Session stream

agent.mcp_tool_result

Execution result of an MCP tool call.
FieldTypeDescription
mcp_tool_use_idstringThe id of the paired agent.mcp_tool_use event
contentarrayArray of tool result content blocks
is_errorbooleanWhether the tool execution failed

agent.custom_tool_use

Client custom tool call initiated by the Agent, awaiting a user.custom_tool_result event from the client.
FieldTypeDescription
namestringCustom tool name
inputobjectJSON arguments passed to the tool; {} when empty
session_thread_idstringOptional. Present only when a child thread's custom tool call is surfaced on the primary Session stream

agent.thread_context_compacted

Emitted after context compaction completes. Token counts are not exposed.
FieldTypeDescription
usageobjectOptional. Present when the upstream provider returns billable credits, containing usage.credits (number, floored to at most 2 decimal places); omitted otherwise
The same amount is already included in the Session's usage.model_credits, so clients must not add it again.

agent.thread_message_sent

Recorded on the sender's event stream when one Thread sends a message to another Thread.
FieldTypeDescription
contentarrayArray of text content blocks, each {"type": "text", "text": "..."}
to_session_thread_idstringTarget Thread ID (sthr_ prefix)
to_agent_namestringAgent name of the target Thread

agent.thread_message_received

Recorded on the recipient's event stream when one Thread receives a message from another Thread.
FieldTypeDescription
contentarrayArray of text content blocks, each {"type": "text", "text": "..."}
from_session_thread_idstringSender Thread ID (sthr_ prefix)
from_agent_namestringAgent name of the sender Thread ("qoder.advisor" for Advisor consultations)

agent.artifact_delivered

agent.artifact_delivered indicates that the Agent has successfully delivered an artifact file. Each successfully delivered file produces one event; delivering multiple files produces multiple events. This server-generated event is available through event list and stream endpoints and cannot be submitted through the send events endpoint.
FieldTypeDescription
file_idstringFile ID of the delivered file, with the file_ prefix
original_filenamestringOriginal filename of the delivered file
sizeinteger (int64)File size in bytes
content_typestringFile MIME type, such as application/pdf
{
  "id": "evt_019e392c0d787cfaa21bda98e06cd914",
  "type": "agent.artifact_delivered",
  "file_id": "file_019e3bb9b0c2752688aeb5fdacf00565",
  "original_filename": "report.pdf",
  "size": 1234,
  "content_type": "application/pdf",
  "processed_at": "2026-05-18T03:40:50Z"
}
After receiving the event, use file_id to get the file details. If the file's downloadable field is true, call Download file content (GET /api/v1/cloud/files/{file_id}/content) to obtain a temporary download URL, then request that URL to download the file. The event itself contains neither file content nor a download URL.

Session lifecycle and metadata events

session.status_running

The Session entered the running state. Contains no additional public fields beyond Common event fields.

session.status_idle

The Session entered the idle state, indicating the current turn finished or is waiting for client action.
FieldTypeDescription
stop_reasonStop reason objectReason execution stopped or is waiting
reasonstringOptional. Set to "outcome_evaluation" for certain Outcome evaluation closes; omitted for ordinary turns

session.status_rescheduled

The Session entered rescheduling (for example, during an automatic model request retry). Contains no additional public fields beyond Common event fields. Keep the SSE connection open and wait for the subsequent session.status_running or session.status_idle.

session.status_terminated

The Session terminated (terminal event). Contains no additional public fields beyond Common event fields. Clients should stop reconnecting; no further events will arrive.

session.error

session.error reports an error during Session execution.
FieldTypeDescription
errorobjectError details object; see fields below
The error object has these fields:
FieldTypeDescription
typestringError category; see common values below. Clients should handle unknown_error and future types
messagestringHuman-readable error description
retry_statusobjectRetry state. Its type is retrying, exhausted, or terminal
qoder_error_codestringOptional diagnostic code. Clients must not use it to decide whether to retry
mcp_server_namestringOptional. Present only for mcp_connection_failed_error and mcp_authentication_failed_error
credential_idstringOptional. Present only for credential_host_unreachable_error
vault_idstringOptional. Present only for credential_host_unreachable_error
Common error.type values:
ValueDescription
model_overloaded_errorModel service overloaded
model_rate_limited_errorModel request rate-limited
model_request_failed_errorModel request failed
mcp_connection_failed_errorFailed to connect to MCP server (includes mcp_server_name)
mcp_authentication_failed_errorMCP server authentication failed (includes mcp_server_name)
billing_errorBilling or credit-related error
credential_host_unreachable_errorTarget host for credential unreachable (includes credential_id, vault_id)
unknown_errorOther uncategorized error
retry_status.type has these meanings:
ValueDescription
retryingThe service is retrying automatically; the client should continue waiting
exhaustedThe retry count or recovery window has been exhausted, or a non-retryable error failed immediately. No further automatic recovery is scheduled for this turn. Wait for subsequent status events before deciding whether to send a new message
terminalThe error is not recoverable and will not be retried automatically. Use subsequent Session/Thread status events to determine the final state
Common qoder_error_code values (for diagnostics and troubleshooting only; do not use them to decide whether to retry, and expect new codes over time):
qoder_error_codeTypical error.typeDescription
112billing_errorCredit usage limit reached; upgrade your subscription plan for additional resources
10605model_overloaded_errorModel service busy; request queued
429model_overloaded_errorModel request rate-limited or upstream quota congested
504model_request_failed_errorUpstream model request timed out
500model_request_failed_errorUpstream model service internal error
406model_request_failed_errorSession blocked by safety/compliance policy; clear context or start a new Session
418model_request_failed_errorInput or content rejected by safety moderation
Common error.message categories and examples (some messages are forwarded from upstream model providers and may change; rely on error.type and retry_status.type rather than exact string matching on message):
CategoryTypical error.message examples
Rate limiting and queue timeoutmodel rate limited: model request queue wait timeout
Safety and content policy blocksSession blocked, Please clear context try again, Model response was blocked by the provider safety policy., Image processing blocked due to content policy violation.
Billing and quota exhaustionQoder error 112, Billing quota exceeded.
Interrupted model stream or upstream outageModel response stream ended without a completion signal, Service Unavailable, All models failed
Input or context limits exceededYour input exceeds the context window of this model. Please adjust your input and try again., The image length and width do not meet the model restrictions...

session.usage

Before each public session.status_idle, the stream emits session.usage when usage data is available.
FieldTypeDescription
model_creditsnumberCumulative credits consumed by recorded model calls in the Session
sandbox_runtime_creditsnumberCumulative credits consumed by billable cloud sandbox runtime in the Session
total_creditsnumberTotal cumulative credits across all usage components in the Session
These values are cumulative snapshots (floored to at most 2 decimal places). Replace the previous snapshot instead of adding snapshots together. The stream does not emit usage events while a turn is running. Sandbox charges settled after the current idle event are not included in that session.usage snapshot; after settlement, they are available through Get a Session and are included in the snapshot emitted before the next idle event.

session.updated

Emitted when Session configuration is modified via Update a Session. Contains only the fields that were updated:
FieldTypeDescription
titlestringOptional. Updated Session title
agentobjectOptional. Updated Agent snapshot; see Session embedded agent
budgetobject | nullOptional. Updated budget configuration, or null when removed; see Session budget

session.deleted

The Session was deleted (terminal event). Contains no additional public fields beyond Common event fields. Thread event streams also receive this event after Session deletion and then close.

Thread lifecycle events

In multi-agent and Advisor Sessions, all 5 Thread lifecycle events include session_thread_id and agent_name in addition to Common event fields:
Shared fieldTypeDescription
session_thread_idstringThread ID with the sthr_ prefix
agent_namestringAgent name for this Thread; "qoder.advisor" for Advisor Threads
Additional fields per event:
Event typeAdditional fieldsDescription
session.thread_creatednoneA new Thread was created
session.thread_status_runningnoneThe Thread entered running
session.thread_status_reschedulednoneThe Thread entered rescheduling; does not imply the Session status changed
session.thread_status_idlestop_reason (Stop reason object)The Thread stopped or is waiting; does not mean the entire Session is idle
session.thread_status_terminatednoneThe Thread terminated

Advisor events

Advisor lifecycle events have agent_name: "qoder.advisor". Use session_thread_id to identify each consultation.
EventWhere to read itKey fields
agent.thread_message_receivedMain thread event streamfrom_session_thread_id identifies the consultation thread, from_agent_name is qoder.advisor, and content contains the advice
agent.thread_message_sentAdvisor Thread event streamto_session_thread_id and to_agent_name identify the main thread; content contains the advice
session.errorAdvisor Thread event streamerror contains the cause and retry status; see session.error
session.thread_status_idleSession event streamstop_reason.type is end_turn when the consultation ends (including interruption), or retries_exhausted on failure. See the thread's session.error for the cause
Example of the main thread receiving advice:
{
  "id": "evt_advisor_received",
  "type": "agent.thread_message_received",
  "processed_at": "2026-09-09T08:00:05Z",
  "from_session_thread_id": "sthr_advisor_call",
  "from_agent_name": "qoder.advisor",
  "content": [{"type": "text", "text": "Migrate through a canary rollout and verify the rollback steps."}]
}
A failed consultation does not stop the main Agent's task or produce an advice message. Read error details through the Thread events endpoint.

Stop reason object

The stop_reason object on session.status_idle and session.thread_status_idle describes why execution stopped or is waiting.
FieldTypeDescription
typestringReason execution stopped or is waiting. Currently known values are listed below
event_idsarrayPresent only for requires_action; lists tool event IDs awaiting client action
event_ids[]stringTool event id to reference when submitting confirmation or a tool result
There are 8 currently known stop_reason.type values:
ValueMeaning
end_turnThe turn ended, possibly through thread interruption or evaluation closure; does not guarantee task success
requires_actionWaiting for tool approval or client tool results. Handle the actions in event_ids to continue; the turn has not ended
max_tokensModel output reached the token limit; the response may be incomplete
max_turnsThe current turn reached its tool-use round limit
cancelledThe current turn was cancelled
errorExecution ended with an error; see session.error for details
retries_exhaustedRetries exhausted or execution closed with a platform error, including non-retryable rejections; see session.error for details
budget_reachedThe Session budget was exhausted
Thread idle applies only to that thread; Session idle does not mean the Session has terminated. Clients should tolerate unknown type values without treating them as success.

Span events

Model request span events

span.model_request_start

Marks the beginning of one model request. Contains no additional public fields beyond Common event fields.

span.model_request_end

Marks completion of that model request and includes model_usage for the call.
FieldTypeDescription
model_request_start_idstringID of the corresponding span.model_request_start event
is_errorbooleanWhether the model request ended with an error or cancellation
model_usageobjectUsage for this model call; credits is 0 when no billable usage was recorded
model_usage contains only:
FieldTypeDescription
creditsnumberCredits consumed by this model call (floored to at most 2 decimal places); 0 indicates no billable credits were recorded

Outcome evaluation span events

Span events emitted during Outcome evaluation. See Outcome Evaluation for the full lifecycle.

span.outcome_evaluation_start

Marks the start of an Outcome evaluation iteration.
FieldTypeDescription
outcome_idstringOwning Outcome ID
iterationintegerZero-based evaluation iteration index

span.outcome_evaluation_ongoing

Indicates that Outcome evaluation is still in progress. Emission intervals are not fixed; do not use it as a timeout signal.
FieldTypeDescription
outcome_idstringOwning Outcome ID
iterationintegerZero-based evaluation iteration index

span.outcome_evaluation_end

Marks the end of an Outcome evaluation iteration.
FieldTypeDescription
outcome_idstringOwning Outcome ID
iterationintegerZero-based evaluation iteration index
outcome_evaluation_start_idstringID of the paired span.outcome_evaluation_start event, or "" if interrupted before evaluation started
resultstringEvaluation verdict: satisfied, needs_revision, failed, max_iterations_reached, or interrupted
explanationstringExplanation of the verdict
usageobjectOptional. Evaluation usage containing usage.credits (number); omitted when no billable usage was recorded

Event delta stream frames

A buffered event is a complete public Event object emitted after generation finishes and recorded in Session event history. It is the authoritative result. event_start and event_delta are stream-only SSE payloads used for incremental output. They are not public Event objects and do not appear in event list/history responses. Their JSON payloads have no top-level id or processed_at; the SSE id: field carries the ID of the event being streamed and can be used with Last-Event-ID.

Event start frame

An event_start frame identifies the public event whose incremental output has begun.
FieldTypeDescription
typestringAlways "event_start"
eventobjectStreamed event reference
The event object has these fields:
FieldTypeDescription
idstringEvent ID with the evt_ prefix. The SSE id:, related deltas, and buffered event use this same ID.
typestring"agent.message" or "agent.thinking"
An agent.message start is followed by text event_delta frames. An agent.thinking start is start-only: no delta follows, and the buffered agent.thinking event with the same ID marks the end of that thinking phase when one is emitted.
{
  "type": "event_start",
  "event": {
    "id": "evt_00jjujk9fbnr4wkj2gh8",
    "type": "agent.message"
  }
}

Event delta frame

An event_delta frame appends text to an incrementally streamed agent.message.
FieldTypeDescription
typestringAlways "event_delta"
event_idstringID from the matching event_start.event.id and SSE id: field
deltaobjectContent delta
The delta object has these fields:
FieldTypeDescription
typestringAlways "content_delta"
indexintegerZero-based index of the content block being updated
contentobjectText fragment with type: "text" and a text string
{
  "type": "event_delta",
  "event_id": "evt_00jjujk9fbnr4wkj2gh8",
  "delta": {
    "type": "content_delta",
    "index": 0,
    "content": {
      "type": "text",
      "text": "Hello"
    }
  }
}