Skip to main content
Accessed via sandbox.agent.

await sandbox.agent.start(...)

Start an agent session. HTTP API →
str
Initial prompt
str
Claude model
str
System prompt
list[str]
Restrict tools
str
Permission mode
int
default:"50"
Max turns
str
Working directory
dict[str, Any]
MCP server configuration
Callable[[AgentEvent], None]
Event callback
Callable[[str], None]
Stderr callback
Returns: AgentSession
resume, on_exit, and on_scrollback_end are not available in the Python SDK.

await sandbox.agent.attach(session_id, ...)

Reconnect to a running agent session. Accepts on_event and on_error. Returns: AgentSession

await sandbox.agent.list()

List all agent sessions. HTTP API → Returns: list[AgentSessionInfo]

AgentSession

await session.collect_events()

Collect all events until the agent process exits. Python-unique alternative to callbacks. Returns: list[AgentEvent]

await session.wait()

Wait for the agent to finish. Returns: int (exit code)

Types