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

@@ -102,6 +102,7 @@ async fn responses_api_emits_api_request_event() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -146,6 +147,7 @@ async fn process_sse_emits_tracing_for_output_item() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -190,6 +192,7 @@ async fn process_sse_emits_failed_event_on_parse_error() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -235,6 +238,7 @@ async fn process_sse_records_failed_event_when_stream_closes_without_completed()
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -300,6 +304,7 @@ async fn process_sse_failed_event_records_response_error_message() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -363,6 +368,7 @@ async fn process_sse_failed_event_logs_parse_error() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -413,6 +419,7 @@ async fn process_sse_failed_event_logs_missing_error() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -472,6 +479,7 @@ async fn process_sse_failed_event_logs_response_completed_parse_error() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -525,6 +533,7 @@ async fn process_sse_emits_completed_telemetry() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -598,6 +607,7 @@ async fn handle_responses_span_records_response_kind_and_tool_name() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -683,6 +693,7 @@ async fn record_responses_sets_span_fields_for_response_events() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -768,6 +779,7 @@ async fn handle_response_item_records_tool_result_for_custom_tool_call() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -842,6 +854,7 @@ async fn handle_response_item_records_tool_result_for_function_call() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -926,6 +939,7 @@ async fn handle_response_item_records_tool_result_for_local_shell_missing_ids()
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -995,6 +1009,7 @@ async fn handle_response_item_records_tool_result_for_local_shell_call() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -1104,6 +1119,7 @@ async fn handle_container_exec_autoapprove_from_config_records_tool_decision() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "hello".into(),
text_elements: Vec::new(),
@@ -1156,6 +1172,7 @@ async fn handle_container_exec_user_approved_records_tool_decision() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "approved".into(),
text_elements: Vec::new(),
@@ -1223,6 +1240,7 @@ async fn handle_container_exec_user_approved_for_session_records_tool_decision()
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "persist".into(),
text_elements: Vec::new(),
@@ -1290,6 +1308,7 @@ async fn handle_sandbox_error_user_approves_retry_records_tool_decision() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "retry".into(),
text_elements: Vec::new(),
@@ -1357,6 +1376,7 @@ async fn handle_container_exec_user_denies_records_tool_decision() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "deny".into(),
text_elements: Vec::new(),
@@ -1424,6 +1444,7 @@ async fn handle_sandbox_error_user_approves_for_session_records_tool_decision()
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "persist".into(),
text_elements: Vec::new(),
@@ -1492,6 +1513,7 @@ async fn handle_sandbox_error_user_denies_records_tool_decision() {
codex
.submit(Op::UserInput {
environments: None,
items: vec![UserInput::Text {
text: "deny".into(),
text_elements: Vec::new(),