Skip to content

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

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

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

Conversation

@andrewpark-scaleai

@andrewpark-scaleai andrewpark-scaleai commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Merge order for this group:

  1. Framework: https://github.com/scaleapi/agentenv-framework/pull/821 and feat(gateway): open pgweb in a browser with a signed link #824 (merged), then feat(env): give each computer in a multi env a control token of its own #825 (any time).
  2. Consumers (internal PRs) pin a framework release that has 821 and 824, then merge and deploy.
  3. The gateway image with 821, 824 and 825 is promoted.
  4. refactor(env): reach pgweb and db-mcp only through the gateway's /svc routes #823 merges last, after every consumer is deployed on that release and envs on older gateways have expired. Merging it earlier breaks every caller that still uses the old console URLs.

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.

RetriggerView in GreptileConfidence Score: 5/5

The reviewed update appears safe to merge.

Summary

Each computer gets its own control token. Drivers that support it receive only the token’s SHA256 hash.

  • Each computer uses its own control token for framework-only routes.
  • The gateway forwards each computer’s token only to that computer.
  • Task calls use the token granted for the route they reach.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Caller[Framework caller] -->|Computer route grant| Gateway[Gateway]
  Gateway -->|Computer A token| A[Computer A]
  Gateway -->|Computer B token| B[Computer B]
  A -->|Own read token| Watch[Gateway clock watch]
  B -->|Own read token| Watch
Loading

Reviews (10) · Last reviewed commit: "test(gateway): a computer's token on a s..." · Reviewed by Greptile

Comment thread src/agent_env/cli/env/deploy.py Resolved
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.
@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrewpark/per-computer-control-tokens branch from 3238617 to 2dac273 Compare November 20, 2026 23:15
Ubuntu and others added 4 commits November 21, 2026 01:00
env deploy and env get-instance print pgweb's gateway URL, which takes the control token as a header a browser
doesn't send. They now also print a link that opens pgweb once within five minutes and carries no token.
# Conflicts:
#	AGENTS.md
#	packages/agentenv-protocol/src/agentenv_protocol/client.py
#	src/agent_env/task/task.py
The CLI keeps printing no pgweb link; this pull request is about each computer's own control token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on without it

/export-state now takes the env's control token, so a computer's token there is refused; the refusal case already covers it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants