---
title: "Sessions"
description: "Open a live browser and release it. The session ID an agent gets and the CDP URL only your code gets"
canonical_url: "https://browsers.agntn.dev/guide/sessions"
---
# Sessions

> Open a live browser and release it. The session ID an agent gets and the CDP URL only your code gets

A session is a browser the vendor keeps running for you until you release it. Most of the time you don't need one. The CLI and the tools open one only when a provider can't do the job without it, and close it in the same call.

## In TypeScript

```ts
import { create } from "@agntn/browsers";

const provider = await create("browserless");
const session = await provider.createSession({ viewport: { width: 1280, height: 800 } });

session.id;
session.cdpUrl; // connect Playwright or Puppeteer here

await provider.releaseSession(session.id);
```

`createSession` takes `region`, `headless`, `viewport`, `profileId`, `timeout`, `proxy`, `stealth`, `captchaSolving` and an `extra` bag for vendor fields. What a vendor does with each is the vendor's business. `listSessions()` and `getSession(id)` read back what's open.

With a session you also get `navigate(url, session)` and `evaluate(script, session)` on Kernel, Browserless, Playwright and Lightpanda. That's where the library ends and your own automation begins. For clicks and logins, take `cdpUrl` and drive the browser yourself.

## From the CLI

```bash
browsers session -p kernel
browsers sessions -p kernel
browsers release <session-id> -p kernel
```

Vendor sessions stay open after the command exits. Need to pick one up later? List it and release it as shown above.

Playwright and Lightpanda sessions are different: the CLI releases them before exiting, with a note on stderr. A command that prints an ID and then just sits there isn't a feature. For lasting local sessions, use code or the MCP tools.

Attach gives you `evaluate`, but not `navigate`. It evaluates in the tab picked by its last scrape or screenshot. The CLI releases attach sessions too. Good: Firefox's single BiDi slot isn't left occupied.

Kitesurf on Cloudflare doesn't do sessions at all. Its browser lives exactly as long as one CDP socket. Ask anyway and you get `InvalidInputError`, not the Chromium in a Kitesurf costume this used to hand out. `session`, `sessions` and `release` dropped `--browser`. A session opened with it earlier was Chromium all along, so it lists and releases without the flag.

## For a model

`browsers_session` creates one and answers with an opaque ID. `browsers_release` releases it. That's all a model can do with it. No other tool takes a session ID, and the CDP URL never goes back into the conversation.

Sounds limiting. It's on purpose. The tools never grew `navigate` or `evaluate`, so a model can read pages but can't click through your logins. Release what you open. The description of `browsers_release` says it to the model too, because a forgotten browser is a line on somebody's invoice.


## Sitemap

See the full [sitemap](https://browsers.agntn.dev/sitemap.md) for all pages.
