Use selected turn environments for runtime context#20281
Conversation
21fea44 to
bcbd73f
Compare
f8326f6 to
cc129d8
Compare
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
|
Follow-up rationale for the latest cwd/environment cleanup:
This keeps the PR pointed in the direction of relying on explicit env cwd rather than deriving or mutating env cwd from unrelated turn-level cwd updates. |
| && let Some(primary_environment) = next_configuration.environments.first_mut() | ||
| { | ||
| primary_environment.cwd = absolute_cwd; | ||
| } |
There was a problem hiding this comment.
re previous comments about cwd handling:
im removing places where we took turn level cwd and overrode primary env cwd. instead, we'll rely on the explicit TurnEnvironmentParams.cwd for this, and only use turn level cwd as a fallback if none was provided.
22ab549 to
ab4f206
Compare
| }); | ||
| if let Some(environment_selections) = environment_selections.as_ref() { | ||
| self.thread_manager | ||
| .validate_environment_selections(environment_selections) |
There was a problem hiding this comment.
nit, move this method from thread_manager into message processor?
| ) -> CodexResult<()> { | ||
| validate_environment_selections(self.state.environment_manager.as_ref(), environments) | ||
| resolve_environment_selections(self.state.environment_manager.as_ref(), environments) | ||
| .map(|_| ()) |
There was a problem hiding this comment.
nit: what does this map do?
There was a problem hiding this comment.
we're just calling resolve_environment_selections for validation here but dropping the result
| @@ -672,8 +656,6 @@ impl Session { | |||
| turn_environments: Vec<TurnEnvironment>, | |||
| ) -> Arc<TurnContext> { | |||
| let primary_turn_environment = turn_environments.first(); | |||
There was a problem hiding this comment.
nit: not for this round, but we are still having multiple places deciding what primary is
| let mcp_servers = with_codex_apps_mcp(mcp_servers, auth.as_ref(), &mcp_config); | ||
| let auth_statuses = | ||
| compute_auth_statuses(mcp_servers.iter(), store_mode, auth.as_ref()).await; | ||
| let mcp_runtime_environment = match turn_context.primary_environment() { |
There was a problem hiding this comment.
is this a copy of logic in session.rs?
2190528 to
1d64860
Compare
1d64860 to
4deeb8d
Compare
Route session runtime cwd and MCP startup state through selected turn environments so multi-environment turns avoid a parallel legacy Environment field. Keep fallback behavior for local/no-selection sessions and add focused coverage for duplicate selections, cwd resolution, and MCP runtime environment selection. Validation: git diff --check Co-authored-by: Codex <noreply@openai.com>
Resolve relative cwd updates against turn-local environment selections, and keep the TurnContext helper surface minimal. Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Keep environment cwd ownership on explicit environment selections, tighten MCP runtime environment fallback, and clarify resolved environment projection naming. Co-authored-by: Codex <noreply@openai.com>
Route the remaining validation convenience API through resolve_environment_selections and keep the resolver tests attached to the resolver itself. Co-authored-by: Codex <noreply@openai.com>
Keep the explicit turn-environment cwd assertion focused on the selected environment cwd, and remove fallback wording from the RMCP stored-environment test identifiers. Co-authored-by: Codex <noreply@openai.com>
Add the test-only imports and current McpServerConfig fields required by the rebased branch, and derive Debug for ResolvedTurnEnvironments so resolver error tests compile under Bazel. Co-authored-by: Codex <noreply@openai.com>
Use the shared test PathBufExt import for RMCP integration tests and run environment selection tests that touch the local executor under Tokio. Co-authored-by: Codex <noreply@openai.com>
Use turn-local environments for pending MCP refreshes, keep disabled-environment sessions startable when no MCP servers are enabled, and reject ambiguous cwd plus explicit environment updates. Co-authored-by: Codex <noreply@openai.com>
Add the required argument comment for the default-environment fallback flag. Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Keep selected environment cwd scoped to resolved turn environments, remove fallback helpers added during review, and preserve existing MCP default/local fallback behavior inline. Co-authored-by: Codex <noreply@openai.com>
Preserve environment cwd as an explicit environment-selection value, and keep session cwd updates scoped to session configuration only. Co-authored-by: Codex <noreply@openai.com>
Remove the RMCP integration test added during the environment-selection review pass so this PR does not carry that broader test change. Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Apply turn-level cwd overrides to the primary selected environment only for the active turn so runtime cwd, environment context diffs, and app-server turn-start behavior stay aligned without rewriting stored sticky environment selections. Co-authored-by: Codex <noreply@openai.com>
4deeb8d to
5a0b31b
Compare
Summary
Validation
CI should provide the full Bazel/test signal.