A session pins its configuration when it is created (agent definition, model, environment, memory) and keeps an append-only event log. You drive it by sending events and observe it by reading events.

Session status

Status is computed per session; sibling sessions of the same agent never leak into it.

Sending events

POST /v1/sessions with Idempotency-Key is replay-safe: the same key returns the same session.

Events you receive

Streaming and resuming

GET /v1/sessions/{id}/events/stream is a server-sent event stream.
  • Without Last-Event-ID, the stream delivers events emitted after it opens. Open it before you send, or rely on BMA’s rule that a stream opened during a running turn starts at that turn’s input.
  • Every durable event carries bma_sequence. Store the last value you processed and reconnect with Last-Event-ID: <bma_sequence>. A browser EventSource sends back the opaque SSE id automatically; BMA accepts both. Last-Event-ID: 0 replays the whole session. A malformed or unknown value is 400.
  • History: GET /v1/sessions/{id}/events pages with limit/page and filters by types[]. If the last page ends with an open permission request, BMA appends the same requires_action idle event the stream announced, so a restarted worker knows it must answer.

Fork a session

POST /v1/sessions/{session_id}/fork (BMA extension; Idempotency-Key required) creates a new idle session that starts with a copy of the source’s conversation up to a turn boundary. The source is unchanged.
  • The conversation only. No file is copied, snapshotted or rolled back. The fork uses the same environment and gets its machine by the usual rules: on the same persistent or BYO machine it sees that machine’s workspace as it is now; a pool machine is a new, clean one.
  • Copied: messages, tool calls and their results, under new event ids and bma_input_ids (references such as tool_use_id follow), with the source’s frozen agent, brain, environment and resources. Not copied: session tool grants, queued or running input, usage, metadata, bma_model_override.
  • The answer is the new session (as POST /v1/sessions answers) with bma_forked_from {session_id, through_input_id, before_input_id, inherited_through_sequence}: events up to that bma_sequence were inherited.
  • The fork’s first turn rebuilds the context from the copied events, so it reads the whole inherited history again.
  • Fork and source are independent: archiving or deleting one leaves the other.
  • Refusals: fork_point_invalid (not a turn’s opening input, both points, or a turn before the cut has not ended), fork_unsupported (the session’s brain cannot rebuild context from events; today only the platform default brain can), fork_too_large (more than 10,000 events or 64 MiB), 404 for a session of another workspace.