client.run(), the SDK creates a session and runs your first task inside it — you don’t have to manage sessions yourself unless you want to.
Session vs. task vs. browser session
These three are easy to confuse:
A session holds tasks and wraps a browser. If you want the agent to decide the clicks, you’re in session/task territory. If you want to drive Chrome yourself, use a browser session directly.
Create a session and run tasks in it
Passsession_id to client.run() to run each task in the same session. The browser state carries over between tasks — see Follow-up tasks.
sessions.create() returns a live_url you can embed to watch tasks execute — see Live preview.
Sessions time out after 15 minutes of inactivity by default. The maximum session duration is 4 hours.
Lifecycle
A session isactive while its browser is running and stopped once it ends — whether you stop it, it times out, or it hits the 4-hour cap. Stopping a session stops every task still running inside it.
Manage sessions
Share a session
Create a public share link to let anyone view a session’s replay without an API key.client.sessions.purge(session_id) immediately deletes all data for a session.
Next
- Follow-up tasks — run multiple tasks in one session
- Streaming — watch steps as they happen
- Live preview — embed the browser in your UI
- Browser sessions — drive Chrome directly without an agent