Skip to main content
Accessed via sandbox.agent.

await sandbox.agent.start(...)

Start an agent session. HTTP API →
prompt
str
Initial prompt
model
str
Claude model
system_prompt
str
System prompt
allowed_tools
list[str]
Restrict tools
permission_mode
str
Permission mode
max_turns
int
default:"50"
Max turns
cwd
str
Working directory
mcp_servers
dict[str, Any]
MCP server configuration
on_event
Callable[[AgentEvent], None]
Event callback
on_error
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