A browser session lifecycle an agent can reason about
Create, inspect, connect and close Cloudflare Browser Run sessions without confusing access links with persistent browser state.
Bound runtime, avoid duplicate allocation and close idle work while keeping search action costs separate from browser seconds.
Budget a browser task around a specific deliverable: read a source, inspect a form or complete an authorized interaction. Choose a finite runtime and define what partial result is acceptable if the budget runs out. Workspace billing eligibility, usage limits and provider capacity apply before allocation; a successful bootstrap registration does not authorize paid browser creation. The agent should explain a missing prerequisite rather than finding a path around it. A small well-defined operation is easier to budget than an open-ended session whose purpose keeps changing as the agent browses.
Browser runtime and a search provider action are different activities. Lupin's public search uses a Composio app action to obtain results and browser runtime to read a source; explicit public reading uses browser runtime without that search action. If the target URL is already known, reading it directly avoids unnecessary discovery work. Do not infer the final charge solely from wall-clock time in a local client or from the number of search snippets returned. Review the workspace's current billing catalog and recorded usage, because plan allowances and runtime reservations influence what the application permits.
Preserve an Idempotency-Key for each intended browser creation. If the response is lost, retry with the same name, duration and key rather than allocating another browser under a new identity. Lupin reserves usage and runtime before the provider effect and may return reconciliation_required when an allocation's outcome is unfinished. That guard is a reason to inspect the known operation, not an inconvenience to bypass. Keep session_id and cleanup state with the task so a scheduler or retry worker can find the original resource. A duplicate browser consumes capacity even if neither copy produces useful evidence.
const session = await lupin.browsers.create(
{ name: "bounded-source-read", timeout_seconds: 60 },
"bounded-source-read-allocation-001"
);Use temporary research for bounded public reads and interactive sessions for work that actually needs page state. Reuse an active session for related approved steps, while recognizing that reuse does not remove runtime costs or grant durable profiles. Keep a small tab set and avoid repeated screenshots when text answers the question. A human handoff can require waiting, so start it within a deliberate remaining budget. The returned inactivity timeout is not an unlimited-runtime promise; billing-enforced workspaces use a finite lease that can end the session even while the task would prefer to continue.
Save useful evidence outside the browser as each stage finishes, then end the session when its work is done. Confirm closure instead of assuming a disconnected client stopped runtime. For temporary research, inspect session_closed and cleanup_pending separately from the information result. If the budget prevents completion, report the completed sources, unresolved step and cleanup state. Do not keep an idle browser alive solely because the final prose answer has not been written. Cost control works best when it removes unnecessary runtime while preserving an honest account of the evidence gathered and the work that remains.
Reviewed against the current Lupin route, provider adapter and shared input contracts, plus the linked official references. Examples were not run against live services.
Prepared with AI assistance by Lupin editorial. How we research and maintain these guides.