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
All public Event objects share the base fields below. The per-event sections that follow list only the fields specific to each event type:
List and stream endpoints currently expose 36 public event types:
User input message supporting text and images.
Interrupts the active Session turn or a specific Thread.
Submits an approval decision for a pending
Returns the execution result of a built-in tool from a self-hosted worker. When submitted, the service persists and returns an
Returns the execution result of a client-side custom tool.
Defines an Outcome acceptance task for the Session. See Outcome Evaluation.
Attaches a system instruction after a user message or tool result. At most one per request, placed last in the batch, immediately following
All fields below are required. Use only the fields for the selected block type.
All image
Image limits:
Each example is a single event object to place in the
Base64 image:
URL image:
File image:
See Send events for the endpoint.
Text response generated by the Agent.
Marks a reasoning phase by the Agent. Contains no additional public fields beyond Common event fields; thinking content is not exposed.
Built-in tool call initiated by the Agent.
Execution result of a built-in tool call.
MCP tool call initiated by the Agent.
Execution result of an MCP tool call.
Client custom tool call initiated by the Agent, awaiting a
Emitted after context compaction completes. Token counts are not exposed.
The same amount is already included in the Session's
Recorded on the sender's event stream when one Thread sends a message to another Thread.
Recorded on the recipient's event stream when one Thread receives a message from another Thread.
After receiving the event, use
The Session entered the
The Session entered the
The Session entered
The Session terminated (terminal event). Contains no additional public fields beyond Common event fields. Clients should stop reconnecting; no further events will arrive.
The
Common
Common
Common
Before each public
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
Emitted when Session configuration is modified via Update a Session. Contains only the fields that were updated:
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.
In multi-agent and Advisor Sessions, all 5 Thread lifecycle events include
Additional fields per event:
Advisor lifecycle events have
Example of the main thread receiving advice:
A failed consultation does not stop the main Agent's task or produce an advice message. Read error details through the Thread events endpoint.
The
There are 8 currently known
Thread idle applies only to that thread; Session idle does not mean the Session has terminated. Clients should tolerate unknown
Marks the beginning of one model request. Contains no additional public fields beyond Common event fields.
Marks completion of that model request and includes
Span events emitted during Outcome evaluation. See Outcome Evaluation for the full lifecycle.
Marks the start of an Outcome evaluation iteration.
Indicates that Outcome evaluation is still in progress. Emission intervals are not fixed; do not use it as a timeout signal.
Marks the end of an Outcome evaluation iteration.
A buffered event is a complete public Event object emitted after generation finishes and recorded in Session event history. It is the authoritative result.
An
The
An
An
The
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:
| Field | Type | Description |
|---|---|---|
id | string | Event ID with the evt_ prefix |
type | string | Event type; see Public event types |
processed_at | string | null | Processing 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:
| Category | Event types | Description |
|---|---|---|
| User & System (7) | user.message, user.interrupt, user.tool_confirmation, user.tool_result, user.custom_tool_result, user.define_outcome, system.message | Events 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_delivered | Agent 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.deleted | Session-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_terminated | Thread 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_end | Execution 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:
| Type | Required fields | Notes |
|---|---|---|
user.message | content | content must be a non-empty array of content blocks |
user.interrupt | none | session_thread_id is optional and is echoed as null when omitted |
user.tool_confirmation | tool_use_id, result | result must be allow or deny; deny_message is optional |
user.tool_result | tool_use_id | Returns 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_result | custom_tool_use_id | Returns a client custom tool result. content is optional; when present, it must be an array of content blocks. is_error is optional |
user.define_outcome | description, rubric | rubric is a text or file object; max_iterations is optional |
system.message | content | content 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.
| Field | Type | Description |
|---|---|---|
content | array | Non-empty array of text and/or image content blocks; see Message content blocks |
user.interrupt
Interrupts the active Session turn or a specific Thread.
| Field | Type | Description |
|---|---|---|
session_thread_id | string | null | Optional. 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.
| Field | Type | Description |
|---|---|---|
tool_use_id | string | Required. The id of the corresponding agent.tool_use or agent.mcp_tool_use event |
result | string | Required. Decision: "allow" or "deny" |
deny_message | string | null | Optional. Allowed only when result is "deny"; supplying it (even null) when result is "allow" returns 400 |
session_thread_id | string | Response 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.
| Field | Type | Description |
|---|---|---|
tool_use_id | string | Required. The id of the corresponding agent.tool_use event |
content | array | Optional. Array of text, image, document, or search_result content blocks |
is_error | boolean | null | Optional. Whether the tool execution failed |
user.custom_tool_result
Returns the execution result of a client-side custom tool.
| Field | Type | Description |
|---|---|---|
custom_tool_use_id | string | Required. The id of the corresponding agent.custom_tool_use event |
content | array | Optional. Array of text, image, document, or search_result content blocks |
is_error | boolean | null | Optional. Whether the custom tool execution failed |
session_thread_id | string | Response 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.
| Field | Type | Description |
|---|---|---|
description | string | Required. Task goal description, used as the input to the initial Agent turn |
rubric | object | Required. 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_iterations | integer | null | Optional (1–20). Defaults to 3 when omitted or null; responses echo the effective value |
outcome_id | string | Response 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.
| Field | Type | Description |
|---|---|---|
content | array | Required. 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.
| Event | Accepted content[].type | content requirements |
|---|---|---|
user.message | text, image | Required, non-empty array; text and images may be mixed |
system.message | text | Required, non-empty array |
user.tool_result, user.custom_tool_result | text, image, document, search_result | Optional; 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[].type | Fields | Description |
|---|---|---|
text | type, text | text must be a non-empty, non-whitespace string |
image | type, source | source is one of the three formats below |
source fields are strings:
source.type | Required fields | Description |
|---|---|---|
base64 | type, media_type, data | media_type is image/png, image/jpeg, image/webp, or image/gif; data is raw Base64, with optional trailing = padding and no Data URL prefix |
url | type, url | External HTTPS image URL readable by the model service; private, loopback, and other restricted destinations are rejected |
file | type, file_id | Image 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) |
- 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:
Agent events
agent.message
Text response generated by the Agent.
| Field | Type | Description |
|---|---|---|
content | array | Array 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.
| Field | Type | Description |
|---|---|---|
name | string | Tool name |
input | object | JSON arguments passed to the tool; {} when empty |
evaluated_permission | string | Permission evaluation result: "allow", "ask", or "deny" |
evaluation | object | Optional. 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_id | string | Optional. 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.
| Field | Type | Description |
|---|---|---|
tool_use_id | string | The id of the paired agent.tool_use event |
content | array | Array of tool result content blocks |
is_error | boolean | Whether the tool execution failed |
agent.mcp_tool_use
MCP tool call initiated by the Agent.
| Field | Type | Description |
|---|---|---|
mcp_server_name | string | MCP server name |
name | string | MCP tool name |
input | object | JSON arguments passed to the tool; {} when empty |
evaluated_permission | string | Permission evaluation result: "allow", "ask", or "deny" |
evaluation | object | Optional. Permission policy evaluation details, same shape as agent.tool_use.evaluation |
session_thread_id | string | Optional. 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.
| Field | Type | Description |
|---|---|---|
mcp_tool_use_id | string | The id of the paired agent.mcp_tool_use event |
content | array | Array of tool result content blocks |
is_error | boolean | Whether 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.
| Field | Type | Description |
|---|---|---|
name | string | Custom tool name |
input | object | JSON arguments passed to the tool; {} when empty |
session_thread_id | string | Optional. 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.
| Field | Type | Description |
|---|---|---|
usage | object | Optional. Present when the upstream provider returns billable credits, containing usage.credits (number, floored to at most 2 decimal places); omitted otherwise |
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.
| Field | Type | Description |
|---|---|---|
content | array | Array of text content blocks, each {"type": "text", "text": "..."} |
to_session_thread_id | string | Target Thread ID (sthr_ prefix) |
to_agent_name | string | Agent 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.
| Field | Type | Description |
|---|---|---|
content | array | Array of text content blocks, each {"type": "text", "text": "..."} |
from_session_thread_id | string | Sender Thread ID (sthr_ prefix) |
from_agent_name | string | Agent 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.
| Field | Type | Description |
|---|---|---|
file_id | string | File ID of the delivered file, with the file_ prefix |
original_filename | string | Original filename of the delivered file |
size | integer (int64) | File size in bytes |
content_type | string | File MIME type, such as application/pdf |
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.
| Field | Type | Description |
|---|---|---|
stop_reason | Stop reason object | Reason execution stopped or is waiting |
reason | string | Optional. 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.
| Field | Type | Description |
|---|---|---|
error | object | Error details object; see fields below |
error object has these fields:
| Field | Type | Description |
|---|---|---|
type | string | Error category; see common values below. Clients should handle unknown_error and future types |
message | string | Human-readable error description |
retry_status | object | Retry state. Its type is retrying, exhausted, or terminal |
qoder_error_code | string | Optional diagnostic code. Clients must not use it to decide whether to retry |
mcp_server_name | string | Optional. Present only for mcp_connection_failed_error and mcp_authentication_failed_error |
credential_id | string | Optional. Present only for credential_host_unreachable_error |
vault_id | string | Optional. Present only for credential_host_unreachable_error |
error.type values:
| Value | Description |
|---|---|
model_overloaded_error | Model service overloaded |
model_rate_limited_error | Model request rate-limited |
model_request_failed_error | Model request failed |
mcp_connection_failed_error | Failed to connect to MCP server (includes mcp_server_name) |
mcp_authentication_failed_error | MCP server authentication failed (includes mcp_server_name) |
billing_error | Billing or credit-related error |
credential_host_unreachable_error | Target host for credential unreachable (includes credential_id, vault_id) |
unknown_error | Other uncategorized error |
retry_status.type has these meanings:
| Value | Description |
|---|---|
retrying | The service is retrying automatically; the client should continue waiting |
exhausted | The 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 |
terminal | The error is not recoverable and will not be retried automatically. Use subsequent Session/Thread status events to determine the final state |
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_code | Typical error.type | Description |
|---|---|---|
112 | billing_error | Credit usage limit reached; upgrade your subscription plan for additional resources |
10605 | model_overloaded_error | Model service busy; request queued |
429 | model_overloaded_error | Model request rate-limited or upstream quota congested |
504 | model_request_failed_error | Upstream model request timed out |
500 | model_request_failed_error | Upstream model service internal error |
406 | model_request_failed_error | Session blocked by safety/compliance policy; clear context or start a new Session |
418 | model_request_failed_error | Input or content rejected by safety moderation |
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):
| Category | Typical error.message examples |
|---|---|
| Rate limiting and queue timeout | model rate limited: model request queue wait timeout |
| Safety and content policy blocks | Session 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 exhaustion | Qoder error 112, Billing quota exceeded. |
| Interrupted model stream or upstream outage | Model response stream ended without a completion signal, Service Unavailable, All models failed |
| Input or context limits exceeded | Your 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.
| Field | Type | Description |
|---|---|---|
model_credits | number | Cumulative credits consumed by recorded model calls in the Session |
sandbox_runtime_credits | number | Cumulative credits consumed by billable cloud sandbox runtime in the Session |
total_credits | number | Total cumulative credits across all usage components in the Session |
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:
| Field | Type | Description |
|---|---|---|
title | string | Optional. Updated Session title |
agent | object | Optional. Updated Agent snapshot; see Session embedded agent |
budget | object | null | Optional. 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 field | Type | Description |
|---|---|---|
session_thread_id | string | Thread ID with the sthr_ prefix |
agent_name | string | Agent name for this Thread; "qoder.advisor" for Advisor Threads |
| Event type | Additional fields | Description |
|---|---|---|
session.thread_created | none | A new Thread was created |
session.thread_status_running | none | The Thread entered running |
session.thread_status_rescheduled | none | The Thread entered rescheduling; does not imply the Session status changed |
session.thread_status_idle | stop_reason (Stop reason object) | The Thread stopped or is waiting; does not mean the entire Session is idle |
session.thread_status_terminated | none | The Thread terminated |
Advisor events
Advisor lifecycle events have agent_name: "qoder.advisor". Use session_thread_id to identify each consultation.
| Event | Where to read it | Key fields |
|---|---|---|
agent.thread_message_received | Main thread event stream | from_session_thread_id identifies the consultation thread, from_agent_name is qoder.advisor, and content contains the advice |
agent.thread_message_sent | Advisor Thread event stream | to_session_thread_id and to_agent_name identify the main thread; content contains the advice |
session.error | Advisor Thread event stream | error contains the cause and retry status; see session.error |
session.thread_status_idle | Session event stream | stop_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 |
Stop reason object
The stop_reason object on session.status_idle and session.thread_status_idle describes why execution stopped or is waiting.
| Field | Type | Description |
|---|---|---|
type | string | Reason execution stopped or is waiting. Currently known values are listed below |
event_ids | array | Present only for requires_action; lists tool event IDs awaiting client action |
event_ids[] | string | Tool event id to reference when submitting confirmation or a tool result |
stop_reason.type values:
| Value | Meaning |
|---|---|
end_turn | The turn ended, possibly through thread interruption or evaluation closure; does not guarantee task success |
requires_action | Waiting for tool approval or client tool results. Handle the actions in event_ids to continue; the turn has not ended |
max_tokens | Model output reached the token limit; the response may be incomplete |
max_turns | The current turn reached its tool-use round limit |
cancelled | The current turn was cancelled |
error | Execution ended with an error; see session.error for details |
retries_exhausted | Retries exhausted or execution closed with a platform error, including non-retryable rejections; see session.error for details |
budget_reached | The Session budget was exhausted |
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.
| Field | Type | Description |
|---|---|---|
model_request_start_id | string | ID of the corresponding span.model_request_start event |
is_error | boolean | Whether the model request ended with an error or cancellation |
model_usage | object | Usage for this model call; credits is 0 when no billable usage was recorded |
model_usage contains only:
| Field | Type | Description |
|---|---|---|
credits | number | Credits 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.
| Field | Type | Description |
|---|---|---|
outcome_id | string | Owning Outcome ID |
iteration | integer | Zero-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.
| Field | Type | Description |
|---|---|---|
outcome_id | string | Owning Outcome ID |
iteration | integer | Zero-based evaluation iteration index |
span.outcome_evaluation_end
Marks the end of an Outcome evaluation iteration.
| Field | Type | Description |
|---|---|---|
outcome_id | string | Owning Outcome ID |
iteration | integer | Zero-based evaluation iteration index |
outcome_evaluation_start_id | string | ID of the paired span.outcome_evaluation_start event, or "" if interrupted before evaluation started |
result | string | Evaluation verdict: satisfied, needs_revision, failed, max_iterations_reached, or interrupted |
explanation | string | Explanation of the verdict |
usage | object | Optional. 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.
| Field | Type | Description |
|---|---|---|
type | string | Always "event_start" |
event | object | Streamed event reference |
event object has these fields:
| Field | Type | Description |
|---|---|---|
id | string | Event ID with the evt_ prefix. The SSE id:, related deltas, and buffered event use this same ID. |
type | string | "agent.message" or "agent.thinking" |
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.
Event delta frame
An event_delta frame appends text to an incrementally streamed agent.message.
| Field | Type | Description |
|---|---|---|
type | string | Always "event_delta" |
event_id | string | ID from the matching event_start.event.id and SSE id: field |
delta | object | Content delta |
delta object has these fields:
| Field | Type | Description |
|---|---|---|
type | string | Always "content_delta" |
index | integer | Zero-based index of the content block being updated |
content | object | Text fragment with type: "text" and a text string |