Repository navigation
fix(env): send the control token to the REST routes behind the gateway - #820
Draft
andrewpark-scaleai wants to merge 1 commit into
Draft
andrewpark-scaleai wants to merge 1 commit into
andrewpark-scaleai wants to merge 1 commit into
Conversation
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.
This was referenced Nov 19, 2026
This branch has not been deployed
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.
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.