Skip to content

fix(env): a multi env and its computers share one control token, which its gateway passes on to them (FD-5903) - #690

Merged
earakely-scale merged 4 commits into
mainfrom
edgararakelyan/multi-env-computer-token
Nov 15, 2026
Merged

earakely-scale merged 4 commits into
mainfrom
edgararakelyan/multi-env-computer-token

Conversation

@earakely-scale

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

Copy link
Copy Markdown
Collaborator

What changes

FD-5903. A multi env and the computers it fronts now share one control token, and its gateway passes that token on to them.

The bug. A step couldn't reach a framework-only route of a multi env's computer through the multi env's gateway; the computer answered 401 unauthorized: this route is agent-env's own: it takes the env's control token.

  • The gateway took its own token off every request and passed any other on.
  • Each computer it fronted had a token of its own.
  • So a call to <gateway>/svc/<computer>/... with the multi env's token, as Task.run's grant and DeployedEnv.invoke(environment_name=...) send it, reached the computer with none.

This broke:

  • an env_outcome_verifier that reads files in the computer with computer-exec (the FD-5483 pilot's check does);
  • start_computer_recording with an environment_name, which is best effort and only warns;
  • anything else that calls a multi env's computer by environment_name.

The fix:

  • The gateway provider hands the token it mints to the children it starts (children(reach, control_token)). MultiEnv's deployer deploys each computer with it (ComputerEnv.deploy(control_token=...)), so each computer's framework-only routes take the multi env's token.
  • The gateway learns which children those are (CONTROL_TOKEN_CHILDREN, written in both the VM compose and the container path). It keeps its token on just two kinds of request:
    • their /svc/<computer> routes;
    • its own clock watch, where the computers send the same token as their read token.
  • Every other request, to an MCP server, a website or a route of its own, still goes on without the token.
  • Steps, DeployedEnv and the protocol are unchanged: they keep sending the multi env's one token.

Trade-off: FD-4922 is still open. Code in a computer's session can read the computer's token from its environment or from /proc. Until FD-4922 lands, that token is the whole multi env's, so it opens the gateway's control routes (clock, triggers, tool rules) and every computer of the multi env, not only that computer. Agreed for now; FD-4922 closes it.

Testing

  • Unit:

    • which requests keep the gateway's token: a computer's /svc routes and the clock watch yes; an MCP server's, a similarly named child's, a website's and the gateway's own routes no;
    • a computer whose read token is the gateway's own acknowledges a clock write;
    • the multi env deploys each computer, the browser computer included, with the token its gateway hands it;
    • the gateway provider hands its token to its children and names them in its environment, in the VM and container paths, and names none without a token.

    The new gateway tests fail without the change.

  • tst/unit/env, task, task_step, providers and the protocol's tests: 9504 passed. One time-trigger test (process_scope_socket_test) failed once under the full parallel run; it passed three times alone and three times in its module. The Windows disk recipe test fails on main on macOS too. ruff check is clean.

  • Integration, on the x86 host (local Docker):

    • multi_env_computers_test.py's first test runs a command in the desktop through the gateway with invoke(..., environment_name="desktop") and checks that the computer's record holds the multi env's token. It passed (105 s); without a fix it fails with that 401.
    • computer_clock_test.py: the desktop follows a multi env's clock through jumps, a rate change and a freeze, and clock writes wait for its acknowledgement with the shared token. It passed (94 s).
    • The FD-5483 pilot's no-model run passes on this branch, its check reading the desktop's documents through the gateway.
  • Regression and chaos run on this branch, on two x86 hosts (local Docker). Every test that ran passed:

    • A computer in a multi env: multi_env_computers_test.py, all four tests:
      • two computers through a killed container, a gateway restart and a failed redeploy. After the restart, each computer now also runs a command through the gateway with the multi env's token;
      • a computer failing mid-deploy;
      • a refused entry.
    • The browser in a multi env: browser_multi_env_test.py, 10 tests.
    • The gateway's chaos: browser_gateway_test.py (a gateway restart or data reset, a browser down at first, a dying server or driver), and gateway_test.py's tool rules through /svc.
    • Recording chaos: recording_chaos_test.py, 5 tests.
    • A computer alone: computer_env_test.py (its control-token test included), container_stopped_test.py and desktop_example_test.py.
    • The browser alone: browser_computer_test.py, 21 tests, and website_browser_test.py, 4 tests.

    Totals: 22 passed on one host, 42 on the other, and the restart check passed alone. Six tests were skipped: five CDP-client tests need Node 20, which the hosts lack, and one needs a model endpoint.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge with the documented shared-token trade-off.

Summary

The PR gives a multi env and its computers one control token. The gateway keeps that token on their /svc requests and its clock watch.

  • Multi-env computers now share their gateway's control token.

Diagram

sequenceDiagram
    participant Caller as Framework caller
    participant Gateway
    participant Computer
    Caller->>Gateway: /svc/computer with shared token
    Gateway->>Computer: Forward request with shared token
    Computer-->>Caller: Command result through gateway
    Computer->>Gateway: /clock/watch with shared token
Loading

Reviews (8) · Last reviewed commit: "test(env): after a gateway restart both ..." · Reviewed by Greptile

earakely-scale and others added 2 commits November 14, 2026 21:52
…ith the computer's own token

A multi env's gateway takes its own control token off a call and passes any other on, and each computer it fronts takes
only its own. A step's grant and DeployedEnv.invoke gave a call to the gateway's /svc/<computer> route the gateway's
token, so the computer refused its framework-only routes: an env_outcome_verifier reading files in the computer with
computer-exec, or start_computer_recording with an environment_name. A record's control_grants now add, for each child
env a gateway fronts on a sandbox of its own, the gateway's route to it with the child's own token, and the protocol's
granted_headers picks the longest address a call is under.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r through the gateway's route to it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h its gateway passes on to them

Replaces the per-computer grants: a multi env's gateway took its own token off every request and passed any other on,
while each computer it fronts took a token of its own, so a step's call to a computer through the gateway, with the
multi env's token, was refused (401). Now the gateway provider hands its token to the computers it starts
(`children(reach, control_token)`), each boots with it, and the gateway keeps it on their /svc routes
(`CONTROL_TOKEN_CHILDREN`) and on its clock watch, where they send it as their read token; every other request still
goes on without it. The protocol's grants and DeployedEnv are back to main's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale earakely-scale changed the title fix(env): a step reaches a multi env's computer through its gateway with the computer's own token (FD-5903) fix(env): a multi env and its computers share one control token, which its gateway passes on to them (FD-5903) Nov 15, 2026
…l take its token through the gateway

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale merged commit 99e651e into main Nov 15, 2026
38 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/multi-env-computer-token branch November 15, 2026 22:52
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