mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Allow environment selection updates during an active turn (#47435)
## What changed - Add `environments` to `TurnSettingsUpdate` to replace the selection for subsequent steps without changing future turns. - Capture model settings and environments together so combined updates apply or reject atomically, while existing steps retain their captured selection. - Validate environment IDs, working directories, configuration ownership, and permission requirements against the running turn's selections. - Preserve executor startup behavior when switching environments and use the step's local working directory for tool hooks. ## Testing Add coverage for workspace switching and restoration on the next turn, atomic model and environment updates, permission validation, executor connection waits, and replacement of pending environment selections. GitOrigin-RevId: 02b5c57a78fd594b2aed84fc09d9e99eb97be28c
This commit is contained in:
@@ -109,8 +109,6 @@ use tracing::instrument;
|
||||
use tracing::warn;
|
||||
|
||||
const THREAD_CREATED_CHANNEL_CAPACITY: usize = 1024;
|
||||
// Reject pathological selected cwd values at the environment-selection boundary.
|
||||
const MAX_TURN_ENVIRONMENT_CWD_BYTES: usize = 8 * 1024;
|
||||
|
||||
/// Test-only override for enabling thread-manager behaviors used by integration
|
||||
/// tests.
|
||||
@@ -848,37 +846,6 @@ impl ThreadManager {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn validate_environment_selections(
|
||||
&self,
|
||||
environments: &[TurnEnvironmentSelection],
|
||||
) -> CodexResult<()> {
|
||||
let mut environment_ids = HashSet::with_capacity(environments.len());
|
||||
for environment in environments {
|
||||
if environment.cwd.inferred_native_path_string().len() > MAX_TURN_ENVIRONMENT_CWD_BYTES
|
||||
{
|
||||
return Err(CodexErr::InvalidRequest(
|
||||
"turn environment working directory exceeds the maximum size".to_string(),
|
||||
));
|
||||
}
|
||||
if !environment_ids.insert(environment.environment_id.as_str()) {
|
||||
return Err(CodexErr::InvalidRequest(format!(
|
||||
"duplicate turn environment id `{}`",
|
||||
environment.environment_id
|
||||
)));
|
||||
}
|
||||
self.state
|
||||
.environment_manager
|
||||
.get_environment(&environment.environment_id)
|
||||
.ok_or_else(|| {
|
||||
CodexErr::InvalidRequest(format!(
|
||||
"unknown turn environment id `{}`",
|
||||
environment.environment_id
|
||||
))
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn git_root_discovery(&self) -> Arc<GitRootDiscovery> {
|
||||
Arc::clone(&self.state.git_root_discovery)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user