Repository navigation
feat(browser): browser/v1 contexts, leased beside the default one (M8.15) - #642
Merged
earakely-scale merged 9 commits intoNov 12, 2026
Conversation
A website browser now leases browser contexts by a label: each has its own cookies, local storage, tabs and a downloads folder in ~/Contexts/<label>/Downloads. contexts/lease is idempotent, contexts/grant records the agents a lease is for (not enforced yet), contexts/release ends it and contexts/list lists them. The tabs, cookies, local_storage and downloads ops take a context, else act on the default context as before. A context an agent makes over its CDP address is leased to it as agent-<user>-<n>; only that agent may dispose it, and a lease's downloads stay pinned to its folder. A reset or relaunch of the browser ends every lease. data/get carries each lease under contexts, with its downloads, and data/add leases any it names that are missing, so a snapshot round-trips. Task steps: browser_lease_context and browser_release_context, and a context on the cookie, local storage, tab and sign-in steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd clear leftover folders before each launch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…2-m815-browserv1-contexts-leases-grants # Conflicts: # packages/agentenv-protocol/src/agentenv_protocol/website_browser/environment.py # src/agent_env/task/episode/rules.py
…d leases a context by its cookies, then a tab opens Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…2-m815-browserv1-contexts-leases-grants # Conflicts: # packages/agentenv-protocol/src/agentenv_protocol/website_browser/environment.py # packages/agentenv-protocol/src/agentenv_protocol/website_browser/log.py # packages/agentenv-protocol/tests/test_browser_data.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
marked this pull request as ready for review
November 12, 2026 20:18
- The page's operations (page/*, navigate, history, dialog/answer, files/choose) follow the tab last brought to the front in any context, as before contexts, rather than only the default context's. - A context an agent disposed has its folder moved aside at once, so a lease of its label right after keeps a folder of its own. - A load into a lease that exists finds it before checking who may lease the label, so signing in to an agent's lease works. - Origins are kept by context id from the first load, so a context found only later keeps its local storage. - A download an iframe began belongs to its tab's context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…an't lease an ended agent's label as the task's Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n-in needs a lease - tabs/list takes every: all contexts' tabs, each naming its context, the page's tab the active one. The page driver's computer_tabs uses it when the browser leases contexts, and switches to or closes a lease's tab in its lease, so an agent can act on the tab on its screen. - browser_sign_in into a context refuses a label that isn't leased, before it asks the site for a session, rather than leasing a new one. - A multi env test: two leases in chromium as its browser each sign in to its site and open it by name, over https through the gateway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
deleted the
edgararakelyan/fd-4962-m815-browserv1-contexts-leases-grants
branch
November 12, 2026 22:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
M8.15 (FD-4962): a website browser leases browser contexts beside its default one.
Until now a website browser had one set of cookies, local storage, tabs and downloads, so a task couldn't sign two users in at once, and contexts an agent made over CDP were invisible to agentenv. Now a task leases a context by a label, and each lease has its own cookies, local storage, tabs and downloads folder in the same Chromium.
Design note: M8.15: browser/v1 contexts, decisions 1a, 2a, 3a, 4b and 5a.
What changes
contexts/lease {label}returns{context, id}. Leasing the same label again returns the same lease, so a retried step is harmless.contexts/grant {context, user}records an agent a lease is for. Nothing enforces grants yet; M8.16 will (decision 1a).contexts/release {context}closes the lease's tabs, disposes the context and deletes its folder. Releasing a label that isn't leased does nothing.contexts/listlists every lease with who made it and its grants.-, at most 40 characters. A task's label can't start withagent-(decision 2a).contexton the existing ops:tabs/*,cookies/*,local_storage/*,downloads/listanddownloads/gettake an optionalcontext, a lease's label. Without one they act on the default context exactly as before, error messages included.~/Contexts/<label>/Downloads/, and~/Downloadsstays the default context's (decision 4b). Uploads stay shared. Each download and tab inrecordnames its context.agent-<user>-<n>and granted to it. One made where the relay didn't see is listed asagent-unknown-<n>, granted to nobody.setDownloadBehaviorfor a lease is pinned to that lease's folder.data/getgainscontexts: each lease's cookies, local storage, tabs, downloads, grants and who made it. Each lease's finished downloads are among the files.data/addleases any context it names that isn't leased, then loads its cookies, local storage and tabs. A snapshot therefore round-trips (decision 5a). Files underContexts/<label>/Downloads/load into that lease.browser_lease_context {label, grants?}andbrowser_release_context {label}are new.context.to_dictonly gainscontextwhen it's set, so tasks saved before this don't get new versions.Decided while building, for your review
disposeOnDetach: an agent context made with it (Playwright's default) ends its lease when that agent's connection closes, as Chromium disposes it.~/Contextsis cleared before each launch, since a killed app server can't clean up after itself.data/gettop level:closed_tabsstays the browser's whole history, each tab naming its context.cookies,local_storage,tabsanddownloadsare the default context's.target_unavailable. The note saidnot_found; this uses the computer error that already exists.label, and the other steps name a lease ascontext.How it was tested
Unit:
test_browser_contexts.py, new, 24 tests:disposeOnDetachcontext ends on disconnect.contexton cookies and tabs, a browser that leases none, config problems, round trips, and sign-in into a lease.tst/unit/task_step+tst/unit/taskall pass.Integration, local Docker on agent-environments-admin VMs (amd64 and arm64), a new test in
browser_computer_test.py:agent-ada-1; bob can't dispose it, and ada can't dispose the task's lease but can dispose her own.data/getcarries the leases and their downloads. After agents have acted, a load still leases a released one back with its cookies; its tabs, like the default context's, can't be loaded then, so the test opens one with an op.Chaos, on the same VMs, not committed:
Results:
browser_computer_test.py, the rest of itwebsite_browser_test.pydisposeOnDetachwere gone once they closed. The other 4 stayed leased to their own agents.Review fixes (Greptile rounds 1 and 2, in b819fd8 and 375d168, each with a unit test):
Review round (d0b104b), from Edgar's read of the PR:
The page driver's
computer_tabssees every context.tabs/listtakesevery: all contexts' tabs, each naming its context, the screen's the active one. Switching to or closing a lease's tab acts in its lease, so an agent can act on whatever its screen shows. A browser built before this gets the old list.browser_sign_ininto a context refuses a label that isn't leased, before it asks the site for a session, rather than signing a new, empty lease in.A new multi env test: chromium as the multi env's browser, two leases each signed in to the env's
shop.testas their own user, each openinghttps://shop.test/api/sessionby name, over https through the gateway. Each page says its own user; the default context has neither's cookies.VMs, amd64 and arm64, on d0b104b (both torn down):
-k multi_env)website_browser_test.pybrowser_computer_test.pyarm64's four failures are the echo agent's: it's built for linux/amd64, and that box has no emulation.
CI on d0b104b: all 34 checks and the CodeBuild integration tests passed. A
plugin_settings_test.pyfailure in one unit shard, unrelated to this PR, passed on a rerun.🤖 Generated with Claude Code


Confidence Score: 5/5
The changes appear safe to merge; no new blocking issue was found.Summary
Adds named browser contexts with separate cookies, storage, tabs, and downloads.
Reviews (8) · Last reviewed commit: "browser/v1 contexts: the agent's tab too..." · Reviewed by Greptile