What a session is
A session is a separate browser context inside a shared Chrome process, with its own cookies, storage, cache and permissions. Creating one takes about 100 to 200 ms and starts no new Chrome.
vitro has no "current" page or active element. Each call names its session and page, so several agents can share one runtime safely.
Leases
create_session returns a session_id and a
lease. Each call that acts on the session must send both. The
lease is returned once (only reattach returns it again), so store
it immediately.
A lease does not defend against a hostile process on your machine. The
loopback binding and the per-install token do that. The lease stops a dozen
agents, each told to "clean up stray sessions", from closing each other's
work. list_sessions shows only your own sessions unless you
pass scope: "all", and it never returns a lease.
Client keys and reattaching
create_session takes a client_key that stays the same
across your restarts, such as the agent name plus the working directory.
reattach finds your sessions by it and nothing else.
Call reattach(client_key:) before creating a session. Browsers
outlive the process that opened them, so after a crash or an editor restart
your sessions are usually still there. A new session leaves the old one holding
quota and loses its cookies.
Stalling and resuming
A session left unused for the idle limit (30 minutes by default) stops its browser. The context, renderer and quota slot are freed at once. The record stays: open pages, their cookies and storage, and the journal position.
A stalled session shows up in reattach with
state: "stalled" and no lease. Bring it back with
resume_session(session_id, client_key). It keeps its id, gets a
new lease, and restores its pages and cookies, so a logged-in agent stays
logged in. The journal records session_stalled
and session_resumed. The second carries gap_ms, so
a long break does not read as a hang.
In the five minutes before the limit, vitro marks the session orphaned. Its
browser is still warm, and reattach brings it back instantly. A
session someone is watching in the wall does not stall.
Quotas
On the desktop, the defaults are 12 sessions and 10 pages per session. Set
them to what your machine holds, up to 256, in Settings, then Capacity, or
with vitro config set max_sessions 24 (and
max_pages_per_session). Both apply from the next call without a
restart. VITRO_MAX_SESSIONS overrides the saved value for one
run. On hosted, the session limit comes from your plan and the sessions you
add to it (see hosted). At the limit, vitro refuses
the call immediately with the current count. It does not queue: a blocked
call can outlast the client's tool timeout, and the retry would create a
second session.
Resuming a stalled session needs a free slot. A quota refusal on
resume_session means the fleet is full right now. The session
will resume when there is room.
What a session does not survive
Quitting the desktop app ends its sessions. A Chrome crash ends the sessions in that browser, and vitro marks them dead with a message that says so. Sessions survive an MCP client restart, a network drop and the idle limit.
Refusals
| Refusal | What it means |
|---|---|
| stale snapshot | The page loaded a new document, by a navigation or a reload, since the snapshot was taken. Take a new snapshot and use its uids. |
| no longer in the page | The document is the same, but that node has left it, as when a single-page app re-renders a list. Take a new snapshot. |
| not actionable | The element is covered, hidden, disabled, detached or still moving. The usual cause is a dialog or an overlay. |
| quota | The limit is reached. status shows live sessions against it. Close your own idle sessions. |
| stalled | The session sat idle and its browser was stopped. Use resume_session. |
| unauthorized | The credential did not resolve. On the desktop, the client sent a token that does not match ~/.vitro/token. On hosted, check the key or the OAuth grant. |
Retrying an unchanged call rarely helps. Read the reason in the refusal and change something.
Closing sessions
Close sessions when you finish with them. An abandoned session holds its cookies and cache until it stalls, and on a shared fleet, capacity a colleague could use. Do not close a session while a person is watching it: it leaves the wall, and they lose it.