mirror of
https://github.com/openai/codex.git
synced 2026-10-28 16:06:15 +00:00
Refresh step world state for all sessions (#33665)
## Why Changes to the selected working directory can select different `AGENTS.md` instructions. These updates need to reach the model even when the deferred executor feature is disabled. ## What changed - Refresh environment readiness and `AGENTS.md` before capturing each step. - Record model-visible world-state changes for every session instead of gating them on the deferred executor feature. - Preserve the initial environment context without duplicating it. ## Testing - Cover `AGENTS.md` replacement after a working-directory change. - Verify that initial environment context remains unique with the deferred executor both enabled and disabled. GitOrigin-RevId: ea5dbe590cc049170259e7eccb6a3346fb2ed8e6
This commit is contained in:
@@ -204,8 +204,7 @@ impl Session {
|
||||
.iter()
|
||||
.chain(
|
||||
environments
|
||||
.turn_environments
|
||||
.iter()
|
||||
.turn_environments()
|
||||
.flat_map(|environment| environment.environment.selected_capability_roots()),
|
||||
)
|
||||
.enumerate()
|
||||
|
||||
@@ -2849,22 +2849,12 @@ impl Session {
|
||||
self: &Arc<Self>,
|
||||
turn_context: Arc<TurnContext>,
|
||||
) -> Arc<StepContext> {
|
||||
let deferred_executor_enabled = turn_context
|
||||
.config
|
||||
.features
|
||||
.enabled(Feature::DeferredExecutor);
|
||||
let environments = if deferred_executor_enabled {
|
||||
// Keep selections fixed for the turn while allowing their startup work to finish.
|
||||
turn_context.environments.refresh_readiness()
|
||||
} else {
|
||||
turn_context.environments.clone()
|
||||
};
|
||||
if deferred_executor_enabled {
|
||||
self.services
|
||||
.agents_md_manager
|
||||
.refresh(&turn_context.config, &environments)
|
||||
.await;
|
||||
}
|
||||
// Keep selections fixed for the turn while allowing their startup work to finish.
|
||||
let environments = turn_context.environments.refresh_readiness();
|
||||
self.services
|
||||
.agents_md_manager
|
||||
.refresh(&turn_context.config, &environments)
|
||||
.await;
|
||||
let loaded_agents_md = self.services.agents_md_manager.get_loaded().await;
|
||||
let selected_capability_roots = self
|
||||
.resolve_selected_capability_roots_for_step(&environments)
|
||||
|
||||
@@ -7793,14 +7793,13 @@ async fn deferred_environment_roots_refresh_plugin_availability() {
|
||||
.primary()
|
||||
.expect("ready local environment");
|
||||
let environments = TurnEnvironmentSnapshot {
|
||||
turn_environments: vec![TurnEnvironment::new(
|
||||
environments: vec![TurnEnvironmentState::Ready(TurnEnvironment::new(
|
||||
"executor".to_string(),
|
||||
environment,
|
||||
local_environment.cwd().clone(),
|
||||
local_environment.workspace_roots().to_vec(),
|
||||
local_environment.shell.clone(),
|
||||
)],
|
||||
starting: Vec::new(),
|
||||
))],
|
||||
};
|
||||
let resolved_roots = session
|
||||
.resolve_selected_capability_roots_for_step(&environments)
|
||||
@@ -7873,8 +7872,10 @@ async fn conflicting_ready_environment_root_ids_keep_first_location() {
|
||||
));
|
||||
}
|
||||
let environments = TurnEnvironmentSnapshot {
|
||||
turn_environments,
|
||||
starting: Vec::new(),
|
||||
environments: turn_environments
|
||||
.into_iter()
|
||||
.map(TurnEnvironmentState::Ready)
|
||||
.collect(),
|
||||
};
|
||||
|
||||
let resolved_roots = session
|
||||
|
||||
@@ -259,15 +259,9 @@ pub(crate) async fn run_turn(
|
||||
)
|
||||
.await?;
|
||||
|
||||
if turn_context
|
||||
.config
|
||||
.features
|
||||
.enabled(Feature::DeferredExecutor)
|
||||
{
|
||||
world_state = sess
|
||||
.record_step_world_state_if_changed(&world_state, step_context.as_ref())
|
||||
.await;
|
||||
}
|
||||
world_state = sess
|
||||
.record_step_world_state_if_changed(&world_state, step_context.as_ref())
|
||||
.await;
|
||||
|
||||
// Construct the input that we will send to the model.
|
||||
let sampling_request_input: Vec<ResponseItem> = async {
|
||||
|
||||
Reference in New Issue
Block a user