Repository navigation
fix(env): send the control token to the REST routes behind the gateway - #820
Merged
Merged
Conversation
This was referenced Nov 19, 2026
andrewpark-scaleai
marked this pull request as ready for review
November 20, 2026 16:53
The legacy REST helpers (reset_via_rest, add_via_rest, export_state, reset) take headers and default to the run's grant. Legacy loads, resets, state reads and streamed snapshots send the deployment's token. A grant covers a URL only when it resolves under the grant's address, by whole path segments. A legacy reset refused with 401 or 403 raises instead of falling back to the MCP tool.
andrewpark-scaleai
force-pushed
the
andrewpark/legacy-rest-callers-send-token
branch
from
November 20, 2026 17:14
58f18f0 to
f3ff3b3
Compare
Collaborator
|
🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review. Context from outside this diff: #776 (open, non-draft) is a second, independent implementation of this same change — same five source files — and the two disagree in ways only visible when you hold them side by side.
Raising it only because none of this is visible from this diff alone; which of the two is the one to keep is yours to call. Generated by Claude Code |
Five call sites spelled `(deployed.control_headers_for(url) or None)`, where the `or None` is what lets a record with no token for the url fall back to the run's grant; an empty dict would send nothing. control_headers_or_grant says that once, and each site calls it. 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.
Merge order for this pair:
Why
The gateway's data plane calls send the control token. This PR makes agent-env's calls to the older REST state routes send it too, so a later gateway change can require it there.
What changed
reset_via_rest,add_via_rest,export_stateandresetinlegacy_protocoltakeheaders. Without them, each call sends the run's grant (request_headers).data_plane_headers).service_stateand the snapshot step send the deployment's token to/export-stateand to a streamed/export-snapshot.granted_headersmatches a URL to a grant only when the URL resolves under the grant's address, by whole path segments.<name>_resetMCP tool.Scope
/api/reset,/api/add,/export-stateand/export-snapshot.Verification
Authorizationheader on each legacy route when a token exists, and its absence when none does.pytest packages/agentenv-protocol/tests tst/unit/env tst/unit/task_step -n 4: 7808 passed, 1 skipped, 0 failed.ruff checkis clean.tst/integration/env/envs/multi_env_local_test.pypassed on local Docker.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issues were found.Summary
Sends control tokens on legacy REST loads, resets, and state exports.
Reviews (6) · Last reviewed commit: "refactor(env): one record method for a t..." · Reviewed by Greptile