Prerequisites
- A rig in the
active/running/startedstate. See Create a rig. - Agent credentials injected at rig-create time. See Inject credentials.
Step 1 — Send a prompt
By default the call uses Claude. Pass--agent / agent to switch agents.
Step 2 — Continue or start a fresh session
By default, both the CLI and SDK resume the most recent session for the rig. Force a new session with--new-session / newSession, or pick a
specific one with --session-id / sessionId.
Stream the reply
sendStream takes the same request and calls your handlers as the turn runs.
onDelta receives reply text in order, and onStatus reports milestones. It
resolves with the completed turn, like send.
Over HTTP, POST /agent-sessions/stream takes the same body and answers with
a text/event-stream. Each frame’s SSE event: field names it: status for
milestones, delta for reply text, done for the completed turn (the same
object POST /agent-sessions returns), or error.
Response shape
send and sendStream return the agent’s reply, the session ID it ran in,
and whether the agent reported an error.
AgentSessionUsage.
The HTTP API returns the same fields in snake case (session_id,
sandbox_id, is_error, is_new_session, created_sandbox, usage).
Things to know
- Sends block. The call waits for the agent to finish before returning. The SDK uses a 10-minute HTTP timeout for sends (the default elsewhere is 30 seconds). Anything that wraps the SDK (Lambda, Cloudflare Worker, etc.) needs at least that much runtime budget.
- Check
isError. An agent failure, such as a rejected agent credential, returnsisError: truewith details inresponse, even though the HTTP request succeeded. To fix a credential problem, see Inject credentials. - Default is resume. Without
--new-session/newSessionor--session-id/sessionId, both the CLI and the SDK continue the rig’s current session.