Add turn-scoped environment selections (#18416)

## Summary
- add experimental turn/start.environments params for per-turn
environment id + cwd selections
- pass selections through core protocol ops and resolve them with
EnvironmentManager before TurnContext creation
- treat omitted selections as default behavior, empty selections as no
environment, and non-empty selections as first environment/cwd as the
turn primary

## Testing
- ran `just fmt`
- ran `just write-app-server-schema`
- not run: unit tests for this stacked PR

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
starr-openai
2026-04-21 17:48:33 -07:00
committed by GitHub
parent 6368f506b7
commit 1d4cc494c9
85 changed files with 974 additions and 35 deletions

View File

@@ -121,6 +121,7 @@ async fn model_change_appends_model_instructions_developer_message() -> Result<(
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -158,6 +159,7 @@ async fn model_change_appends_model_instructions_developer_message() -> Result<(
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "switch models".into(),
text_elements: Vec::new(),
@@ -218,6 +220,7 @@ async fn model_and_personality_change_only_appends_model_instructions() -> Resul
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -255,6 +258,7 @@ async fn model_and_personality_change_only_appends_model_instructions() -> Resul
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "switch model and personality".into(),
text_elements: Vec::new(),
@@ -392,6 +396,7 @@ async fn model_change_from_image_to_text_strips_prior_image_content() -> Result<
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![
UserInput::Image {
image_url: image_url.clone(),
@@ -418,6 +423,7 @@ async fn model_change_from_image_to_text_strips_prior_image_content() -> Result<
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "second turn".to_string(),
text_elements: Vec::new(),
@@ -526,6 +532,7 @@ async fn generated_image_is_replayed_for_image_capable_models() -> Result<()> {
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "generate a lobster".to_string(),
text_elements: Vec::new(),
@@ -547,6 +554,7 @@ async fn generated_image_is_replayed_for_image_capable_models() -> Result<()> {
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "describe the generated image".to_string(),
text_elements: Vec::new(),
@@ -658,6 +666,7 @@ async fn model_change_from_generated_image_to_text_preserves_prior_generated_ima
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "generate a lobster".to_string(),
text_elements: Vec::new(),
@@ -679,6 +688,7 @@ async fn model_change_from_generated_image_to_text_preserves_prior_generated_ima
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "describe the generated image".to_string(),
text_elements: Vec::new(),
@@ -792,6 +802,7 @@ async fn thread_rollback_after_generated_image_drops_entire_image_turn_history()
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "generate a lobster".to_string(),
text_elements: Vec::new(),
@@ -821,6 +832,7 @@ async fn thread_rollback_after_generated_image_drops_entire_image_turn_history()
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "after rollback".to_string(),
text_elements: Vec::new(),
@@ -978,6 +990,7 @@ async fn model_switch_to_smaller_model_updates_token_context_window() -> Result<
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "use larger model".into(),
text_elements: Vec::new(),
@@ -1037,6 +1050,7 @@ async fn model_switch_to_smaller_model_updates_token_context_window() -> Result<
test.codex
.submit(Op::UserTurn {
environments: None,
items: vec![UserInput::Text {
text: "switch to smaller model".into(),
text_elements: Vec::new(),