Use selected environment cwd for filesystem helpers#22542
Conversation
There was a problem hiding this comment.
💡 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".
| 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(), | ||
| )); |
There was a problem hiding this comment.
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 👍 / 👎.
Why
TurnContext::cwdis 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
TurnContext::file_system_sandbox_contexttake the trusted cwd explicitly.apply_patchandview_imagecall sites.spawn_agents_on_csvto exactly one local environment and resolve input/output CSV paths from that local environment cwd.TurnContext::cwdwith a replaced config.Validation
cargo test -p codex-core view_imagecargo test -p codex-core maybe_persist_mcp_tool_approval_writes_project_config_for_project_servercargo test -p codex-core parse_csv_supports_quotes_and_commasgit diff --check