Repository navigation
fix(env): a multi env and its computers share one control token, which its gateway passes on to them (FD-5903) - #690
Merged
Conversation
…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>
…l take its token through the gateway Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 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.<gateway>/svc/<computer>/...with the multi env's token, asTask.run's grant andDeployedEnv.invoke(environment_name=...)send it, reached the computer with none.This broke:
env_outcome_verifierthat reads files in the computer withcomputer-exec(the FD-5483 pilot's check does);start_computer_recordingwith anenvironment_name, which is best effort and only warns;environment_name.The fix:
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.CONTROL_TOKEN_CHILDREN, written in both the VM compose and the container path). It keeps its token on just two kinds of request:/svc/<computer>routes;DeployedEnvand 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:
/svcroutes and the clock watch yes; an MCP server's, a similarly named child's, a website's and the gateway's own routes no;The new gateway tests fail without the change.
tst/unit/env,task,task_step,providersand 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 onmainon macOS too.ruff checkis 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 withinvoke(..., 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).Regression and chaos run on this branch, on two x86 hosts (local Docker). Every test that ran passed:
multi_env_computers_test.py, all four tests:browser_multi_env_test.py, 10 tests.browser_gateway_test.py(a gateway restart or data reset, a browser down at first, a dying server or driver), andgateway_test.py's tool rules through/svc.recording_chaos_test.py, 5 tests.computer_env_test.py(its control-token test included),container_stopped_test.pyanddesktop_example_test.py.browser_computer_test.py, 21 tests, andwebsite_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


Confidence 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
/svcrequests and its clock watch.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 tokenReviews (8) · Last reviewed commit: "test(env): after a gateway restart both ..." · Reviewed by Greptile