Skip to content

Add environmentId to request_permissions#25858

Merged
jif-oai merged 2 commits into
mainfrom
jif/request-permissions-environment-id
Jun 2, 2026
Merged

Add environmentId to request_permissions#25858
jif-oai merged 2 commits into
mainfrom
jif/request-permissions-environment-id

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented Jun 2, 2026

Stack

  1. Key request-permission grants by environment #25850 - Key request-permission grants by environment: stores and applies sticky permission grants per environment id.
  2. This PR (Add environmentId to request_permissions #25858) - Add environmentId to request_permissions: lets the model target a selected environment and resolves relative permission paths against it.
  3. Propagate permission approval environment id #25862 - Propagate permission approval environment id: carries the selected environment id through approval events, app-server requests, TUI prompts, and delegate forwarding.
  4. Add remote request permissions integration coverage #25867 - Add remote request permissions integration coverage: verifies the selected remote environment across request, approval, grant reuse, and exec.

This PR is stacked on #25850; #25862 and #25867 are stacked on this PR.

Why

PR1 made request-permission grants internally environment-keyed, but the model-facing request_permissions tool could still only target the primary environment. For CCA and multi-environment turns, the tool needs an explicit way to bind a permission request to a selected attached environment before resolving relative paths.

What Changed

  • Added optional environmentId to RequestPermissionsArgs, with environment_id accepted as an alias.
  • Exposed environmentId in the request_permissions tool schema and description.
  • Resolve the selected environment before parsing filesystem permission paths, so relative paths bind to the selected environment cwd.
  • Route validated tool calls through request_permissions_for_environment directly instead of duplicating environment lookup in Session::request_permissions.
  • Reject unknown environment ids with a model-facing error.
  • Updated focused request-permissions and Guardian call sites for the new optional field.

Testing

Not run locally per instruction.

@jif-oai jif-oai marked this pull request as ready for review June 2, 2026 14:11
@jif-oai jif-oai requested a review from a team as a code owner June 2, 2026 14:11
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented Jun 2, 2026

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a301ee9d85

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/codex_delegate.rs
Comment thread codex-rs/core/src/tools/handlers/request_permissions.rs
Comment thread codex-rs/core/src/session/tests/guardian_tests.rs
Comment thread codex-rs/core/src/tools/handlers/shell_spec.rs Outdated
jif-oai added a commit that referenced this pull request Jun 2, 2026
## Stack

1. This PR (#25850) - Key request-permission grants by environment:
stores and applies sticky permission grants per environment id.
2. #25858 - Add `environmentId` to `request_permissions`: lets the model
target a selected environment and resolves relative permission paths
against it.
3. #25862 - Propagate permission approval environment id: carries the
selected environment id through approval events, app-server requests,
TUI prompts, and delegate forwarding.
4. #25867 - Add remote request permissions integration coverage:
verifies the selected remote environment across request, approval, grant
reuse, and exec.

#25858, #25862, and #25867 are stacked on this PR and should be reviewed
after it.

## Why

Multi-environment CCA turns can attach both local and remote executors,
but request-permission grants were still effectively cwd-only. Pending
permission requests tracked a cwd, while stored turn/session grants had
no environment identity, so sticky grants could be reused through the
wrong executor context.

This makes the first permission-grant step environment-aware without
changing the external `request_permissions` payload shape: omitted
environment targeting remains bound to the primary turn environment.

## What Changed

- Store turn- and session-scoped request-permission grants by
`environment_id`.
- Keep the selected `TurnEnvironmentSelection` with pending
`request_permissions` calls so approval responses normalize and record
grants against the same environment.
- Resolve relative `request_permissions` file paths against the primary
turn environment cwd instead of deprecated `turn.cwd`.
- Apply sticky grants in `shell`, `exec_command`, and `apply_patch` by
selected environment id while still using the actual tool cwd for
cwd-relative permission materialization.
- Update Guardian and request-permissions coverage for the
environment-keyed grant behavior.

## Testing

Not run locally. Added or updated focused coverage for:

- `request_permission_grants_are_environment_keyed`
-
`request_permissions_tool_resolves_relative_paths_against_primary_environment`
- related Guardian/request-permissions sticky grant tests
Base automatically changed from jif/perms-per-env to main June 2, 2026 18:17
@jif-oai jif-oai force-pushed the jif/request-permissions-environment-id branch from f6eb191 to 0d44957 Compare June 2, 2026 18:18
@jif-oai jif-oai merged commit e29071e into main Jun 2, 2026
31 checks passed
@jif-oai jif-oai deleted the jif/request-permissions-environment-id branch June 2, 2026 18:51
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants