Skip to content

feat(env): give each computer in a multi env a control token of its own - #825

Draft
andrewpark-scaleai wants to merge 4 commits into
mainfrom
andrewpark/per-computer-control-tokens
Draft

andrewpark-scaleai wants to merge 4 commits into
mainfrom
andrewpark/per-computer-control-tokens

Conversation

@andrewpark-scaleai

Copy link
Copy Markdown
Contributor

Why

A multi env's computers shared the gateway's control token. This PR gives each computer a token of its own, so each credential opens only what it is for, and keeps the token out of the computer session's process environment.

What changed

  • Each computer mints its own control token at deploy.
  • The gateway gets them in CHILD_CONTROL_TOKENS and sends each computer's token on that computer's /svc routes.
  • The session holds only AGENTENV_CONTROL_TOKEN_SHA256, and the driver card advertises control_token: "sha256".
  • granted_headers picks the longest matching grant prefix.

Scope

  • Multi env computers and computers deployed alone.
  • CONTROL_TOKEN_CHILDREN stays in the gateway for computers an older agent-env booted. Delete it once no deploy sets it.

Blast Radius

  • New framework, older gateway image: steps still reach each computer through the record's per-computer grant.
  • Older framework, new gateway image: the gateway still honors CONTROL_TOKEN_CHILDREN.
  • Computer images composed before this change keep the plain token until recomposed. That token now belongs to the computer alone.
  • Each computer's token sits in child_envs[<name>].control_token of the multi env's record. A hub that strips the top-level token from reads should strip these too.

Verification

  • Unit trees tst/unit/env, tst/unit/providers, tst/unit/task, tst/unit/task_step, tst/unit/drivers and the protocol's tests pass, except environment-specific failures that also fail on the base branch.
  • multi_env_computers_test.py asserts each computer holds its own token.
  • A local Docker container check found no token in the session's process environments.

Ubuntu and others added 4 commits November 19, 2026 18:34
The gateway serves the env's SQL consoles at /svc/pgweb/ and /svc/db-mcp/
from a new CONSOLE_URLS variable, behind the deployment's control token like
its other guarded routes. The deploy records db_web_gateway_url and
db_mcp_gateway_url once it has checked the gateway serves both, and keeps
db_web_url and db_mcp_url as they are. db-mcp binds every address family on
the container path. The CLI prints the gateway URLs, and a website can no
longer be named pgweb or db-mcp.
…etry the console probe

- A multi env's computer can't be named pgweb or db-mcp. The gateway serves a
  computer at /svc/<name>/, so such a computer used to pass the env's name
  checks and stop the gateway at startup, after every sandbox was made.
- Requests to a SQL console are forwarded without a write window. Only the
  control token reaches a console, so a write through one is no role's, and it
  no longer runs the changelog queries on the event loop.
- The deploy asks each console up to four times: a dropped or refused
  connection is asked again, as a timeout or a 502-504 already was.
- _verify_list_tools uses the MCP SDK's client (30 s, redirects), as it did
  before it took headers, and the tests check the record names db-mcp at the
  gateway before using it.
- A bad CONSOLE_URLS or WEBSITE_URLS entry names its own variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each computer mints its own control token at deploy. The gateway receives
them in CHILD_CONTROL_TOKENS and sends each computer's token on that
computer's /svc routes. A driver whose card advertises control_token
"sha256" boots with only the token's digest (AGENTENV_CONTROL_TOKEN_SHA256).
granted_headers picks the longest matching grant. CONTROL_TOKEN_CHILDREN stays
for computers an older agent-env booted.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants