sandbox.agent.
await sandbox.agent.start(...)
Start an agent session. HTTP API →
Initial prompt
Claude model
System prompt
Restrict tools
Permission mode
Max turns
Working directory
MCP server configuration
Event callback
Stderr callback
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
| Member | Type | Description |
|---|---|---|
session_id | str | Session ID |
sandbox_id | str | Sandbox ID |
send_prompt(text) | method | Send follow-up prompt |
interrupt() | method | Interrupt current turn |
configure(...) | method | Update model, tools, cwd |
await kill(signal=9) | method | Kill agent process |
await close() | method | Close WebSocket |
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
AgentEvent
AgentEvent
AgentSessionInfo
AgentSessionInfo