Skip to content
Python

Allowed sites: the session keeps the stored entries; docs say web tools follow the list

Rohit C Prasad319f511336cb
diff --git a/coworker/agent.py b/coworker/agent.py
index 77724d79..2d7fd078 100644
--- a/coworker/agent.py
+++ b/coworker/agent.py
@@ -737,8 +737,8 @@ def build_engine(
engine.permissions.sandbox_sites = list(getattr(_sandbox_provider, "extra_hosts", None) or [])
engine.permissions.search_host = lambda: _provider_host(secrets)
- def _grant_site(host: str) -> None:
- _sandbox_settings.add_site(host)
+ def _grant_site(host: str) -> list[str]:
+ return _sandbox_settings.add_site(host)
engine.permissions.grant_site = _grant_site
engine.todo = todo # type: ignore[attr-defined]
diff --git a/coworker/permissions.py b/coworker/permissions.py
index c3085fd7..58fdc384 100644
--- a/coworker/permissions.py
+++ b/coworker/permissions.py
@@ -310,8 +310,9 @@ class PermissionEngine:
sandbox_sites: Optional[list[str]] = None
# Where `web_search` goes: the configured provider's host (it has no url argument).
search_host: Optional[Callable[[], str]] = None
- # Persists a site the user chose to always allow (adds it to the machine's list).
- grant_site: Optional[Callable[[str], None]] = None
+ # Persists a site the user chose to always allow (adds it to the machine's list) and
+ # returns that list, so this session's copy carries the same entries.
+ grant_site: Optional[Callable[[str], Optional[list[str]]]] = None
# Session-wide read-only grant (owner ask 2026-08-11): auto-allow shell commands the
# conservative classifier (coworker/readonly.py) accepts. User-elected per session.
session_readonly: bool = False
@@ -620,7 +621,9 @@ class PermissionEngine:
if self.sandbox_sites is not None and not self._on_site_list(host):
self.sandbox_sites.append(host)
if self.grant_site is not None:
- self.grant_site(host)
+ stored = self.grant_site(host)
+ if stored is not None and self.sandbox_sites is not None:
+ self.sandbox_sites[:] = [str(x) for x in stored]
else:
self.session_allow_domains.add(host)
diff --git a/docs/macos-sandbox.md b/docs/macos-sandbox.md
index 342e9498..e293c6ad 100644
--- a/docs/macos-sandbox.md
+++ b/docs/macos-sandbox.md
@@ -71,6 +71,14 @@ Two choices, shared with the other sandboxes:
A credential entry (below) also lets through the sites its tool needs.
+The coworker's **web search** and **web fetch** tools run in the OpenWorker app, not in the
+sandbox, and follow the same list. A site that is not on it asks you first; the card offers
+once, this session, or **Always allow**, which adds the site to the list. With full access
+(no approvals) the fetch is refused instead. A site added this way is open to the web tools
+at once; commands reach it from the next session, because the running sandbox keeps the
+list it started with. Connectors and MCP servers are not covered by the list; each has its
+own approval.
+
## Sharing a credential on purpose
By default the sandbox has none of your logins, which also means `git push` over SSH has
diff --git a/docs/openshell.md b/docs/openshell.md
index dbdd08ca..d53bc86e 100644
--- a/docs/openshell.md
+++ b/docs/openshell.md
@@ -129,6 +129,14 @@ Two choices, shared with the other sandboxes:
A credential entry (below) also lets through the sites its tool needs.
+The coworker's **web search** and **web fetch** tools run in the OpenWorker app, not in the
+sandbox, and follow the same list. A site that is not on it asks you first; the card offers
+once, this session, or **Always allow**, which adds the site to the list. With full access
+(no approvals) the fetch is refused instead. A site added this way is open to the web tools
+at once; commands reach it from the next session, because the running sandbox keeps the
+list it started with. Connectors and MCP servers are not covered by the list; each has its
+own approval.
+
OpenShell enforces the list in the container.
## Sharing a credential on purpose
diff --git a/docs/windows-sandbox.md b/docs/windows-sandbox.md
index 88b8c61d..1d0c9df4 100644
--- a/docs/windows-sandbox.md
+++ b/docs/windows-sandbox.md
@@ -140,6 +140,14 @@ One elevated PowerShell script, one prompt. It:
A credential entry (below) also lets through the sites its tool needs.
+The coworker's **web search** and **web fetch** tools run in the OpenWorker app, not in the
+sandbox, and follow the same list. A site that is not on it asks you first; the card offers
+once, this session, or **Always allow**, which adds the site to the list. With full access
+(no approvals) the fetch is refused instead. A site added this way is open to the web tools
+at once; commands reach it from the next session, because the running sandbox keeps the
+list it started with. Connectors and MCP servers are not covered by the list; each has its
+own approval.
+
Choosing a mode never touches the firewall. The rules are written once at setup; OpenWorker
picks the account. In the closed mode a sandbox can still **listen** on a local port (a dev
server your browser can open); it cannot **connect** to one, other than the proxy.
diff --git a/tests/test_site_wall.py b/tests/test_site_wall.py
index 3021b0bd..d2e47ded 100644
--- a/tests/test_site_wall.py
+++ b/tests/test_site_wall.py
@@ -60,6 +60,13 @@ def test_session_and_always_choices(tmp_path):
assert eng2.evaluate("web_fetch", {"url": "https://docs.python.org/3/library/"}, None).allowed
assert eng2.evaluate("web_fetch", {"url": "https://python.org/"}, None).needs_user # that host only
+ # The store returns the list as it keeps it (with ports); the session takes that copy,
+ # so the header chip and Settings show the same entries.
+ eng3 = engine(tmp_path, Mode.INTERACTIVE, grant_site=lambda host: ["github.com:443", f"{host}:443"])
+ eng3.allow_site_always("https://docs.python.org/3/")
+ assert eng3.sandbox_sites == ["github.com:443", "docs.python.org:443"]
+ assert eng3.evaluate("web_fetch", {"url": "https://docs.python.org/3/library/"}, None).allowed
+
def test_web_search_is_held_to_the_provider_host(tmp_path):
eng = engine(tmp_path, Mode.BYPASS_APPROVALS, search_host=lambda: "api.search.brave.com")