Skip to content

Use selected environment cwd for filesystem helpers#22542

Merged
pakrym-oai merged 1 commit into
mainfrom
pakrym/file-system-sandbox-context-explicit-cwd
May 13, 2026
Merged

Use selected environment cwd for filesystem helpers#22542
pakrym-oai merged 1 commit into
mainfrom
pakrym/file-system-sandbox-context-explicit-cwd

Conversation

@pakrym-oai

Copy link
Copy Markdown
Collaborator

Why

TurnContext::cwd is deprecated in favor of resolving paths from the selected turn environment cwd. A few filesystem-oriented paths were still constructing sandbox context from the legacy cwd and then mutating it afterward, or resolving local file paths through the deprecated helper.

What changed

  • Make TurnContext::file_system_sandbox_context take the trusted cwd explicitly.
  • Pass the selected turn environment cwd directly from apply_patch and view_image call sites.
  • Restrict spawn_agents_on_csv to exactly one local environment and resolve input/output CSV paths from that local environment cwd.
  • Remove a redundant test setup assignment that only synchronized deprecated TurnContext::cwd with a replaced config.

Validation

  • cargo test -p codex-core view_image
  • cargo test -p codex-core maybe_persist_mcp_tool_approval_writes_project_config_for_project_server
  • cargo test -p codex-core parse_csv_supports_quotes_and_commas
  • git diff --check

@pakrym-oai pakrym-oai marked this pull request as ready for review May 13, 2026 20:14
@pakrym-oai pakrym-oai requested a review from a team as a code owner May 13, 2026 20:14

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

Copy link
Copy Markdown
Contributor

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: 36b5df0dd7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +293 to +296
let [turn_environment] = turn.environments.turn_environments.as_slice() else {
return Err(FunctionCallError::RespondToModel(
"spawn_agents_on_csv requires exactly one local environment".to_string(),
));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Hide the CSV tool when the selected environments are unsupported

When a turn has multiple selected environments, or a single remote environment, spawn_agents_on_csv is still registered whenever config.agent_jobs_tools is true, but this new check makes every invocation fail before reading the CSV. For example, EnvironmentManager::default_environment_ids() can select both a remote default and local, which makes ToolEnvironmentMode::Multiple while collect_handler_tools still pushes SpawnAgentsOnCsvHandler; the model then sees a tool that deterministically returns this error. Either gate the tool spec to the same single-local condition or let the call select/use the local environment.

Useful? React with 👍 / 👎.

@pakrym-oai pakrym-oai merged commit 3ac1d15 into main May 13, 2026
27 checks passed
@pakrym-oai pakrym-oai deleted the pakrym/file-system-sandbox-context-explicit-cwd branch May 13, 2026 20:18
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 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