Skip to content

WebSocket reference

The unified live endpoint is GET /ws. It carries JSON text frames with a kind discriminator from server to client and a cmd discriminator from client to server. Authentication applies to the HTTP upgrade request: the workbench’s same-origin upgrade carries its axocoatl-token-<port> sign-in cookie, and other clients send Authorization: Bearer <token> or x-api-key: <token> with the local API token or a configured credential. A missing or wrong credential gets 401 before the upgrade; a cross-origin or Origin: null browser upgrade gets 403. See authentication.

On connect, the server sends ready, then an authoritative snapshot of live runs, every pending MCP approval, and any Session or Workspace Ways transition that currently owns primary-runtime teardown. A client that falls behind the broadcast buffer is disconnected so its normal reconnect can hydrate from a fresh snapshot rather than continuing with silently missing frames.

{ "cmd": "ping" }

Returns { "kind": "pong" }.

{
"cmd": "session",
"id": "session-id",
"input": "Implement the requested change.",
"display_input": "Implement the requested change.",
"context_references": [],
"turn_id": "browser-stable-turn-id",
"idempotency_key": "browser-stable-send-id",
"reference_ids": [],
"model_override": null,
"target_agent": null
}
FieldMeaning
idSession ID
inputEffective execution input, including any structured inline context rendering
display_inputOptional user-visible composer text stored separately from execution expansion
context_referencesImmutable inline editor/Preview reference snapshots
turn_idStable client identity for durable accept, reconnect, and exact Stop; generated if absent
idempotency_keyStable send-attempt identity; defaults to turn_id
reference_idsSession-owned uploaded attachment relations
model_overrideOptional one-turn model within the Agent provider for compatibility execution; native execution requires the exact approved model
target_agentOptional one-Agent target in a multi-Agent Session

If the same accepted identity is already running, the runtime reattaches rather than starting duplicate work. The normal sequence is session-accepted, session-start, streaming frames, then exactly one terminal Session frame.

{
"cmd": "session-stop",
"id": "session-id",
"turn_id": "browser-stable-turn-id"
}

A stale or already-finished ID produces session-stop-rejected. Stop is cooperative; a started tool may reach a safe boundary before terminal state. If a retry reuses a live turn ID with different request data, Axocoatl emits session-request-rejected; that control response rejects only the conflicting request and leaves the original run and its Stop control live.

{
"cmd": "mcp-approve",
"approval_id": "approval-id",
"decision": "allow",
"persist": "once"
}

decision is allow or deny. persist is one of:

  • once;
  • agent_tool;
  • agent_server;
  • any_agent_server.

An unknown/already-resolved ID returns mcp-approval-unknown.

CommandFieldsPurpose
run-workflowid, inputRun a manual Automation through the legacy workflow stream
chat-turnchat_id, contentRun one lightweight compatibility Chat turn
chat-stopchat_idStop the active compatibility Chat stream

These retained commands do not create separate browser destinations.

kindImportant fieldsMeaning
ready—Upgrade handling is ready
snapshotruns, approvals, environment_transitions?, attempt_ownerships?Complete live-run, pending-approval, and active primary-runtime ownership state at connection time
pong—JSON ping response
errormessageMalformed/unsupported command error

Each snapshot run includes workflow (the run key), optional turn_id, optional attempt_set_id, kind (workflow, session, or attempt), Agent buffers/status, optional awaiting-human state, and coordinator plan fields when present. A lane run key alone can be reused by a later set, so clients must also compare attempt_set_id.

Each environment_transitions entry carries session and the durable environment generation that teardown invalidated. An omitted or empty array means no environment transition owns teardown at that snapshot cursor. Clients should still re-read the canonical Session record after reconnect because a complete transition may have happened while the socket was offline.

Each attempt_ownerships entry carries workspace, the owning session, and the durable attempt_set_id. Every Session anchored to that Workspace must suspend primary Files, Source Control, Preview, and Terminal access until the exact set settles. The array is hydrated from durable current-set pointers, so an unresolved Ways decision remains authoritative after a daemon restart.

kindImportant fieldsMeaning
session-acceptedsession, turn_idDurable begin exists
session-startsession, turn_id?Execution started
tokenworkflow, agent, turn_id?, deltaText delta
reasoningworkflow, agent, turn_id?, deltaReasoning-channel delta when supplied
tool-callworkflow, agent, turn_id?, call_id, occurrence, coordination_generation?, name, phase, arguments?, result?, is_errorTool start/result pair
session-donesession, turn_id?, input/output/reasoning tokens, token_usage_knownSuccessful terminal state; a false known flag marks the counts as a subtotal
session-cancelledsession, turn_id, input/output/reasoning tokens, token_usage_knownCooperative Stop terminal state; a false known flag marks the counts as a subtotal
session-needs-attentionsession, turn_id, input_tokens, output_tokens, reasoning_tokens, token_usage_knownNative turns only. The execution epoch ended but the turn stays open for an explicit intervention; not a terminal state. See below
activation-streameventNative turns only. One retained observation of one exact Agent activation; replaces token, reasoning, and tool-call for native Sessions. See below
activation-control-changedactivation, blocker_id, canonical_command_id, turn_revisionNative turns only. A durable blocker or control change for one activation; re-read the turn’s control-plane. It grants nothing by itself
session-errorsession, turn_id?, error, input/output/reasoning tokens, token_usage_knownFailed terminal state; paid work completed before the failure remains visible as a complete tracked total or known subtotal
session-request-rejectedsession, turn_id, errorNonterminal request rejection; the existing live run with that ID remains active. A refusal from a native provider check carries that check’s message alone (for example “Ollama was upgraded from 0.20.6 to 0.40.8; review Team & budget again”)
session-stop-rejectedsession, turn_id, errorStop control response; not a terminal transition
session-environment-changingsession, generationThe Session runtime is unavailable while an explicit change, Close/Delete, or cold reconstruction owns its lifecycle boundary
session-environment-settledsessionThe announced lifecycle owner exited on success, failure, or cancellation; re-read the canonical Session before exposing runtime-backed tools
workspace-attempt-changingworkspace, session, attempt_set_idThe exact Ways set is taking exclusive Workspace ownership; suspend primary runtime surfaces for every Session in that Workspace
workspace-attempt-settledworkspace, attempt_set_idThe exact set’s durable current pointer is gone; re-read and reconstruct the primary runtime before exposing it

occurrence distinguishes repeated provider-local call IDs inside one Agent activation. coordination_generation is present on native Ways candidate activations and carries the native activation generation, so correlate those live tool pairs with the run, Agent, turn, generation, call ID, and occurrence. Other frames omit the generation and retain their run/Agent/turn/call/occurrence identity rather than assuming call_id is globally unique. For coordinator work, agent is the logical declared Worker that executed the tool; workflow and turn_id retain the outer Session/turn ownership.

A native Session turn publishes activation-stream instead of token, reasoning, and tool-call: the live output of each Agent is keyed by its exact activation, not by the run key and Agent name. session-accepted, session-start, session-done, session-cancelled, and session-needs-attention still frame the turn. A native Ways candidate additionally publishes the compatibility token, reasoning, and tool-call frames under its lane run key with coordination_generation, so the Ways view keeps working.

session-needs-attention is sent when a native turn’s execution ends without finishing it: an Agent failed or was interrupted, a required check failed, the required review did not approve, or a limit was reached. The turn stays open with its accepted work, and the token counts follow the same known/subtotal rule as session-done. Until the turn is continued (Continue, Retry, or Revise) or closed (Finish or Stop), a new request for that Session is refused with session-request-rejected, whose error names both ways out; see a new request while a turn needs attention. Read the turn’s control-plane for its blockers and available controls.

An activation-stream frame is published only after the Session’s content store has retained the observation, so a reconnecting client can read the same observations from History. Its event is:

{
"kind": "activation-stream",
"event": {
"reference": "…",
"content": {
"schema_version": 1,
"activation": {
"session_id": "…", "turn_id": "…", "execution_epoch_id": "…",
"node_id": "lead", "generation": 1, "activation_id": "…"
},
"sequence": 0,
"recorded_at_unix_ms": 1790000000000,
"payload": { "kind": "text", "delta": "Reading the failing test" }
}
}
}

reference identifies the retained record. sequence counts from 0 within one activation, without gaps. payload.kind is one of:

kindFieldsMeaning
textdeltaAnswer text delta
reasoning_summarydeltaReasoning-channel delta when the provider supplies one
provider_retryreasonThe provider call is made once more: its response ended early, or the model’s completed response held no answer and no tool call that can run and the model is asked again with a note; text before this marker belongs to the abandoned attempt
provider_responsefinish_reason, offered_tools, tool_callsA model response completed: how it ended (stop, tool_use, max_tokens, content_filter or error), how many tools its request offered and how many calls it returned
tool_proposedcall_id, name, provider_response_group, provider_call_index, provider_call_count, arguments_sha256, arguments_bytesThe Agent proposed a tool call; it still has to pass dispatch
tool_resultcall_id, name, result_sha256, result_bytes, is_errorThe result the Agent saw

Tool arguments and results are not in the frame, only their SHA-256 and size. call_id is provider-local and can repeat within an activation.

Environment lifecycle frames are broadcast to every connected client, not only the tab that issued an HTTP request. Suspend Files, Source Control, Preview, and Terminal work on session-environment-changing. The settled frame is not a success claim: the canonical Session may now be Ready, Failed, Closed, or deleted.

Workspace attempt frames are also broadcast before primary runtime teardown. Settlement is exact-set guarded, so a delayed frame from an older exploration cannot release a newer set’s suspension. A reconnecting client must replace its local ownership map from attempt_ownerships; an empty array can mean a whole start-to-Keep/Discard lifecycle completed while it was offline, so any runtime surface bound before the outage must still be revalidated. For the owning Session, an exact settlement also re-reads durable Results, canonical History, and current Git state before restoring the primary runtime; this clears a completed comparison and hydrates the kept Turn without trusting the event as the result itself.

kindImportant fieldsMeaning
lane-startedrun, attempt_set_id, session, index, model?, agentDurable identity for one Way’s live stream
lane-verifiedattempt_set_id, session, index, passed, changed_files, touched_testsOne Check result arrived
coordinator-planworkflow, coordinator, goal, subtasksCoordinator decomposition and the worker assigned to each subtask

Other Agent stream frames for an Attempt use the lane run key. Reject frames whose set ID belongs to a previous exploration.

Events and Automation compatibility frames

Section titled “Events and Automation compatibility frames”
kindImportant fieldsMeaning
eventtype, agent?, task?, name?, output?, tokens?, workflow?A Skill event from the event feed (type Custom, name the event name), or a Coordinator, Automation or legacy team lifecycle event
workflow-doneworkflow, output, completed, tokens, token_usage_knownLegacy manual workflow terminal success; a false known flag marks tokens as a subtotal
workflow-errorworkflow, error, input/output/reasoning tokens, token_usage_knownLegacy manual workflow terminal failure; paid Agent work before the structural error remains visible

Canonical Automation run and node history should also be read through the HTTP run endpoints. The event frame is an integration feed, not a separate workbench timeline.

Coordinator Worker lifecycle events use AgentActivated, TaskCompleted, AgentFailed, AgentCancelled, and AgentPanicked. Their agent is the stable logical Worker id, not its Session-scoped actor/checkpoint id.

kindImportant fieldsMeaning
mcp-approval-requiredapproval_id, run?, agent_id, server, tool, tool_display, arguments_preview, requested_atA call is parked for a decision
mcp-approval-resolvedapproval_id, decisionClose the prompt in every connected client
mcp-approval-unknownapproval_idThis client tried to resolve a non-pending ID

Pending approvals are included in snapshot, including approvals that cannot be associated with a scoped run.

kindImportant fields
chat-startchat_id, turn_id, agent
chat-tokenchat_id, turn_id, delta
chat-reasoningchat_id, turn_id, delta
chat-tool-startchat_id, turn_id, agent, call_id, name, arguments
chat-tool-resultchat_id, turn_id, agent, call_id, name, result, is_error
chat-donechat_id, turn_id, input/output/reasoning/total tokens, token_usage_known
chat-stoppedchat_id, turn_id, input/output/reasoning/total tokens, token_usage_known
chat-errorchat_id, turn_id, error, input/output/reasoning/total tokens, token_usage_known

These are sent directly to the connection that issued the Chat command; common token/session projections can also appear on the shared bus. chat-stop requests cooperative cancellation of the current turn_id; the terminal frame is sent only after that run reaches a safe boundary and its queued deltas have drained. A false known flag marks the numeric fields as a known subtotal.

Interactive PTYs use a distinct endpoint:

GET /api/sessions/{id}/terminals/{tid}/ws

The server first sends retained scrollback, then raw terminal output as binary frames. Send keystrokes as binary or text. Send resize as JSON text:

{ "kind": "resize", "rows": 40, "cols": 120 }

The upgrade needs the same credential as /ws. An unknown terminal is rejected before upgrade with HTTP 404 JSON. If a connected client falls behind the bounded output broadcast, the server closes that socket with code 4001 and reason terminal-resync-required; clear the stale terminal view and reconnect for a fresh retained-scrollback snapshot instead of appending across the gap.