Skip to content

feat(gateway): a computer's browser requests take the role of whoever drives it, and its calls claim no one's writes - #725

Merged
earakely-scale merged 3 commits into
mainfrom
edgararakelyan/browser-requests-take-the-drivers-role
Nov 17, 2026
Merged

earakely-scale merged 3 commits into
mainfrom
edgararakelyan/browser-requests-take-the-drivers-role

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Part of FD-5968. Part of FD-5944.

Why

On a multi env with a computer, the agent writes to the sites through its browser. Those requests go from the computer's site proxy to the gateway with no AgentEnv-Role, so the gateway read them as default. In HB1.12's weekend-away run 2, all 8 website trigger detections came from the agent's Chromium as default. That meant three things:

  • a website trigger meant for the agent had to watch default, and then any other browser set it off too;
  • a state trigger watching the agent saw a GUI write only at the agent's next input call;
  • changes/v1 recorded the agent's browser writes as others' (19 in run 2).

changes/v1 also gave a computer call a write window for as long as it ran. A desktop_computer_wait can run for seconds, and every write another party made meanwhile was counted as the agent's (20 in run 2).

Several agents may share one computer with different roles, so the role can't be fixed per computer. It follows whoever is driving. Design: Triggers on Computers, gap 1, decision 1 (option C), and gap 2.

What changes

  • The gateway keeps each computer's driver. The provider tells the gateway its computers, a multi env's children on sandboxes of their own (COMPUTERS, with or without a control token). A computer's driver is the role of the last input call to its tools, one without readOnlyHint. It's set as the call starts, in _call_child_tool, the path every child call takes: /mcp, /step, and a trigger action under its as role. Setting it at the start means a request the page sends before the call returns is credited to the caller. A screenshot or a wait changes nothing.

  • A request names its computer. The computer's site proxy sends AgentEnv-Computer: <its name in the multi env> from its private upstream headers (sites.route's label, the name the gateway knows the child by). It drops any AgentEnv-Computer or AgentEnv-Role a page sends.

  • The gateway gives the request its driver's role (_request_role):

    • an explicit AgentEnv-Role still wins;
    • otherwise the named computer's driver;
    • otherwise default, as before anyone has driven, or for a computer the gateway doesn't front, such as one deployed alone.

    Website triggers, state re-checks, the forwarded role and changes/v1 all read this role.

  • A computer's calls claim no writes. changes/v1 (ChangeAttribution) counts no write window for a call to a computer's tools, through /mcp, /step or a trigger action. A computer writes the env's data only through its browser's requests, which carry their own windows. So a write the browser made goes to the request's role, and one another party made during the call goes to that party. The trajectory still records every call's changelog ids.

  • A request's role is read once and kept on the request, so its forwarding, its write and its triggers name one role even if someone else drives before it ends.

  • Docs: AGENTS.md's gateway entry describes the rule.

always_on needs no change: its app_changes count a write as the agent's when a request or call of the agent's role made it, which is now right on a computer.

Tests

  • Unit, new (tst/unit/env/gateway/computer_driver_test.py), on an in-process gateway with a site and a computer:
    • a click, a read-only screenshot by someone else, a typing call, and an MCP call each leave the right driver for the next browser POST;
    • a request without the header, or naming a computer the gateway doesn't front, is default;
    • an explicit AgentEnv-Role still wins;
    • a write made during a click, or during a trigger's typing, has no actor;
    • a request keeps the role it arrived with when someone else drives before it ends;
    • a trigger action typing as: nora makes nora the driver.
  • Unit: the site proxy sends the configured computer and drops a page's AgentEnv-Role and AgentEnv-Computer, and its header names equal the gateway's. sites.route puts the computer's name in each site's upstream headers.
  • Integration, new (computer_triggers_test.py): on a real computer with site routing, person and then helper each move the pointer and load https://shop.test/api/health from inside the computer. The site's website trigger sees person, then helper. Both tests in the file passed on a Linux host with Docker, the gateway image built from this branch, in 4 min 26 s.
  • tst/unit/env and tst/unit/task_step pass locally, except test_disk_recipe.py's Windows install test, which fails the same way on main on macOS because its temporary path is too long for a Unix socket.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues remain.

Summary

Browser requests take the role driving their computer, while computer tool calls claim no writes.

  • Computer browser requests now use the role of their latest input caller.
  • Computer calls no longer claim other people’s writes.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Input tool call"] --> B["Save caller as computer driver"]
  B --> C["Browser request names computer"]
  C --> D["Read and keep request role"]
  D --> E["Forward request"]
  D --> F["Attribute writes and check triggers"]
  A --> G["No tool write window"]
Loading

Reviews (8) · Last reviewed commit: "refactor(gateway): the gateway is told i..." · Reviewed by Greptile

… drives it, and its calls claim no one's writes

The gateway keeps each computer's driver, the role of the last input call to its tools (set as the call starts, on
every child-call path, a trigger action's under its `as`). The computer's site proxy names its computer
(AgentEnv-Computer) and drops a page's AgentEnv-Role, and a request naming a computer takes its driver's role.
A computer's tool calls log no write window, so changes/v1 names the browser's request or the party that wrote.

Part of FD-5968. Part of FD-5944.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 17, 2026 00:03
Comment thread src/agent_env/env/gateway/gateway.py Resolved
Comment thread src/agent_env/env/gateway/gateway.py Resolved
…ry computer call's window, a trigger's too

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tools and input tools apart

A computer was a child the gateway passes its control token on to, which the provider names only when the gateway has
a token. The provider now names the gateway's computers (COMPUTERS) whether it has one or not, and the gateway keeps
each computer tool's computer and the set of input tools rather than a tuple of both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale merged commit de3eefe into main Nov 17, 2026
37 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/browser-requests-take-the-drivers-role branch November 17, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant