#Events

Events are the durable interface for a session. Send user input as events, then list or stream events to observe status, agent output, tool calls, and errors.

Official references:

Send User Input#

typescript
await client.beta.sessions.events.send(session.id, { events: [{ type: "user.message", content: [{ type: "text", text: "Inspect the test failure and propose a fix." }], }], });

List Events#

typescript
for await (const event of client.beta.sessions.events.list(session.id, { order: "asc", limit: 100, types: ["agent.message", "session.status_idle"], })) { console.log(event.type); }

Direct HTTP callers can also filter by types[] or types, plus created_at[gt], created_at[gte], created_at[lt], and created_at[lte].

Stream Events#

typescript
const stream = await client.beta.sessions.events.stream(session.id); for await (const event of stream) { if (event.type === "agent.message") { console.log(event.content); } if (event.type === "session.status_idle") { break; } }

Supported Event Types#

Claude Managed Agents groups events into five domains: user, agent, session, span, and system events. Sandbox0 tracks the current official event shape for capabilities implemented by Sandbox0.

Outcome events are not supported because Sandbox0 does not implement Managed Agents outcomes. Memory has no standalone memory.* event family in the official event catalog, and Sandbox0 does not implement Managed Agents memory.

User Events#

EventMeaning
user.messageUser input sent by your application
user.interruptStop the active run and return the session toward idle
user.custom_tool_resultResult for an agent.custom_tool_use request
user.tool_confirmationAllow or deny a tool that requires confirmation
user.tool_resultResult for an agent-toolset tool when the integration is responsible for returning the result

session_thread_id is accepted on interrupt, tool confirmation, and tool-result events for SDK compatibility. Sandbox0 does not emit multi-agent thread events from its own backend today.

Agent Events#

EventMeaning
agent.messageAgent text output
agent.thinkingAgent thinking output when the selected harness exposes it
agent.tool_useBuilt-in tool request
agent.tool_resultBuilt-in tool result
agent.mcp_tool_useMCP tool request
agent.mcp_tool_resultMCP tool result
agent.custom_tool_useCustom tool request for your application
agent.thread_context_compactedConversation history was compacted
agent.thread_message_receivedRecognized for SDK compatibility; not emitted without multi-agent thread support
agent.thread_message_sentRecognized for SDK compatibility; not emitted without multi-agent thread support

Session Events#

EventMeaning
session.status_runningA run is active
session.status_rescheduledThe active run is waiting for an automatic harness retry after a retriable error
session.status_idleThe turn ended or the agent requires action
session.status_terminatedThe session reached a terminal state
session.deletedThe session was deleted and event streams should stop
session.updatedA session update changed at least one supported field
session.errorSession-level error
session.thread_createdRecognized for SDK compatibility; not emitted without multi-agent thread support
session.thread_status_runningRecognized for SDK compatibility; not emitted without multi-agent thread support
session.thread_status_idleRecognized for SDK compatibility; not emitted without multi-agent thread support
session.thread_status_rescheduledRecognized for SDK compatibility; not emitted without multi-agent thread support
session.thread_status_terminatedRecognized for SDK compatibility; not emitted without multi-agent thread support

Span Events#

EventMeaning
span.model_request_startA model request started
span.model_request_endA model request ended and includes model usage when available

System Events#

EventMeaning
system.messageAdds privileged system context for the accompanying turn and subsequent turns

Treat session.status_idle with stop_reason.type = "end_turn" as a normal turn completion. If the stop reason is requires_action, send the required confirmation or custom tool result before expecting the run to continue.

system.message follows the official request ordering rule: at most one per request, it must be the final event, and it must immediately follow user.message, user.tool_result, or user.custom_tool_result.

Action Resolution#

When a tool needs application input, the session emits session.status_idle with stop_reason.type = "requires_action" and one or more event ids.

Pending eventResponse event
agent.tool_use requiring confirmationuser.tool_confirmation
agent.mcp_tool_use requiring confirmationuser.tool_confirmation
agent.custom_tool_useuser.custom_tool_result
agent.tool_use whose result is provided by the integrationuser.tool_result

Tool result content supports text, image, document, and search_result blocks for tool-result events. search_result is not accepted in user.message content.

Session Update Events#

UpdateSession appends session.updated when a supported field actually changes. The event includes only changed official fields. Sandbox0 vault_ids updates refresh runtime credential state but are not emitted as non-official session.updated fields.

Retry Events#

Sandbox0 exposes automatic model retries through the normal event stream:

SequenceMeaning
session.error with error.retry_status.type = "retrying"The harness observed a retriable model or transport error and will retry the same run automatically
session.status_rescheduledThe session is in the transient rescheduling state while the retry is pending
session.status_runningThe same run resumed and is producing output or completion events again
session.status_idle with stop_reason.type = "retries_exhausted"The retry budget was exhausted and the turn ended without success
session.status_terminatedThe error was terminal and the session is no longer active

Do not send duplicate user input when a session is rescheduling. Wait for either session.status_running, session.status_idle, or session.status_terminated.

File-Backed Input#

Uploaded files can be referenced from message content. See Files for upload, session-scoped copies, and output files.

typescript
await client.beta.sessions.events.send(session.id, { events: [{ type: "user.message", content: [ { type: "text", text: "Summarize this document." }, { type: "document", source: { type: "file", file_id: uploaded.id }, title: "input", citations: { enabled: true }, }, ], }], });

Sandbox0 Notes#

  • Event history is stored outside the sandbox.
  • Runtime callbacks are signed before being appended to the session log.
  • Event streaming is compatible with the SDK surface and backed by Sandbox0 session events.

Next Steps#

Vaults

Store model and external service credentials outside agent code.

Agent Harnesses

Choose the runtime adapter that should execute each managed session.