mirror of
https://github.com/openai/codex.git
synced 2026-04-28 08:34:54 +00:00
Rename exec session IDs to cell IDs (#14510)
- Update the code-mode executor, wait handler, and protocol plumbing to use cell IDs instead of session IDs for node communication - Switch tool metadata, wait description, and suite tests to refer to cell IDs so user-visible messages match the new terminology **Testing** - Not run (not requested)
This commit is contained in:
@@ -52,12 +52,11 @@ fn text_item(items: &[Value], index: usize) -> &str {
|
||||
.expect("content item should be input_text")
|
||||
}
|
||||
|
||||
fn extract_running_session_id(text: &str) -> i32 {
|
||||
text.strip_prefix("Script running with session ID ")
|
||||
fn extract_running_cell_id(text: &str) -> String {
|
||||
text.strip_prefix("Script running with cell ID ")
|
||||
.and_then(|rest| rest.split('\n').next())
|
||||
.expect("running header should contain a session ID")
|
||||
.parse()
|
||||
.expect("session ID should parse as i32")
|
||||
.expect("running header should contain a cell ID")
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn wait_for_file_source(path: &Path) -> Result<String> {
|
||||
@@ -422,12 +421,12 @@ output_text("phase 3");
|
||||
assert_regex_match(
|
||||
concat!(
|
||||
r"(?s)\A",
|
||||
r"Script running with session ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
r"Script running with cell ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
),
|
||||
text_item(&first_items, 0),
|
||||
);
|
||||
assert_eq!(text_item(&first_items, 1), "phase 1");
|
||||
let session_id = extract_running_session_id(text_item(&first_items, 0));
|
||||
let cell_id = extract_running_cell_id(text_item(&first_items, 0));
|
||||
|
||||
responses::mount_sse_once(
|
||||
&server,
|
||||
@@ -437,7 +436,7 @@ output_text("phase 3");
|
||||
"call-2",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_id,
|
||||
"cell_id": cell_id.clone(),
|
||||
"yield_time_ms": 1_000,
|
||||
}))?,
|
||||
),
|
||||
@@ -463,13 +462,13 @@ output_text("phase 3");
|
||||
assert_regex_match(
|
||||
concat!(
|
||||
r"(?s)\A",
|
||||
r"Script running with session ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
r"Script running with cell ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
),
|
||||
text_item(&second_items, 0),
|
||||
);
|
||||
assert_eq!(
|
||||
extract_running_session_id(text_item(&second_items, 0)),
|
||||
session_id
|
||||
extract_running_cell_id(text_item(&second_items, 0)),
|
||||
cell_id
|
||||
);
|
||||
assert_eq!(text_item(&second_items, 1), "phase 2");
|
||||
|
||||
@@ -481,7 +480,7 @@ output_text("phase 3");
|
||||
"call-3",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_id,
|
||||
"cell_id": cell_id.clone(),
|
||||
"yield_time_ms": 1_000,
|
||||
}))?,
|
||||
),
|
||||
@@ -565,12 +564,12 @@ while (true) {}
|
||||
assert_regex_match(
|
||||
concat!(
|
||||
r"(?s)\A",
|
||||
r"Script running with session ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
r"Script running with cell ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
),
|
||||
text_item(&first_items, 0),
|
||||
);
|
||||
assert_eq!(text_item(&first_items, 1), "phase 1");
|
||||
let session_id = extract_running_session_id(text_item(&first_items, 0));
|
||||
let cell_id = extract_running_cell_id(text_item(&first_items, 0));
|
||||
|
||||
responses::mount_sse_once(
|
||||
&server,
|
||||
@@ -580,7 +579,7 @@ while (true) {}
|
||||
"call-2",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_id,
|
||||
"cell_id": cell_id.clone(),
|
||||
"terminate": true,
|
||||
}))?,
|
||||
),
|
||||
@@ -674,7 +673,7 @@ output_text("session b done");
|
||||
let first_request = first_completion.single_request();
|
||||
let first_items = custom_tool_output_items(&first_request, "call-1");
|
||||
assert_eq!(first_items.len(), 2);
|
||||
let session_a_id = extract_running_session_id(text_item(&first_items, 0));
|
||||
let session_a_id = extract_running_cell_id(text_item(&first_items, 0));
|
||||
assert_eq!(text_item(&first_items, 1), "session a start");
|
||||
|
||||
responses::mount_sse_once(
|
||||
@@ -700,7 +699,7 @@ output_text("session b done");
|
||||
let second_request = second_completion.single_request();
|
||||
let second_items = custom_tool_output_items(&second_request, "call-2");
|
||||
assert_eq!(second_items.len(), 2);
|
||||
let session_b_id = extract_running_session_id(text_item(&second_items, 0));
|
||||
let session_b_id = extract_running_cell_id(text_item(&second_items, 0));
|
||||
assert_eq!(text_item(&second_items, 1), "session b start");
|
||||
assert_ne!(session_a_id, session_b_id);
|
||||
|
||||
@@ -713,7 +712,7 @@ output_text("session b done");
|
||||
"call-3",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_a_id,
|
||||
"cell_id": session_a_id.clone(),
|
||||
"yield_time_ms": 1_000,
|
||||
}))?,
|
||||
),
|
||||
@@ -753,7 +752,7 @@ output_text("session b done");
|
||||
"call-4",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_b_id,
|
||||
"cell_id": session_b_id.clone(),
|
||||
"yield_time_ms": 1_000,
|
||||
}))?,
|
||||
),
|
||||
@@ -835,7 +834,7 @@ output_text("phase 2");
|
||||
let first_request = first_completion.single_request();
|
||||
let first_items = custom_tool_output_items(&first_request, "call-1");
|
||||
assert_eq!(first_items.len(), 2);
|
||||
let session_id = extract_running_session_id(text_item(&first_items, 0));
|
||||
let cell_id = extract_running_cell_id(text_item(&first_items, 0));
|
||||
assert_eq!(text_item(&first_items, 1), "phase 1");
|
||||
|
||||
responses::mount_sse_once(
|
||||
@@ -846,7 +845,7 @@ output_text("phase 2");
|
||||
"call-2",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_id,
|
||||
"cell_id": cell_id.clone(),
|
||||
"terminate": true,
|
||||
}))?,
|
||||
),
|
||||
@@ -937,7 +936,7 @@ async fn code_mode_exec_wait_returns_error_for_unknown_session() -> Result<()> {
|
||||
"call-1",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": 999_999,
|
||||
"cell_id": "999999",
|
||||
"yield_time_ms": 1_000,
|
||||
}))?,
|
||||
),
|
||||
@@ -954,7 +953,7 @@ async fn code_mode_exec_wait_returns_error_for_unknown_session() -> Result<()> {
|
||||
)
|
||||
.await;
|
||||
|
||||
test.submit_turn("wait on an unknown exec session").await?;
|
||||
test.submit_turn("wait on an unknown exec cell").await?;
|
||||
|
||||
let request = completion.single_request();
|
||||
let (_, success) = request
|
||||
@@ -973,7 +972,7 @@ async fn code_mode_exec_wait_returns_error_for_unknown_session() -> Result<()> {
|
||||
);
|
||||
assert_eq!(
|
||||
text_item(&items, 1),
|
||||
"Script error:\nexec session 999999 not found"
|
||||
"Script error:\nexec cell 999999 not found"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
@@ -1046,7 +1045,7 @@ output_text("session b done");
|
||||
let first_request = first_completion.single_request();
|
||||
let first_items = custom_tool_output_items(&first_request, "call-1");
|
||||
assert_eq!(first_items.len(), 2);
|
||||
let session_a_id = extract_running_session_id(text_item(&first_items, 0));
|
||||
let session_a_id = extract_running_cell_id(text_item(&first_items, 0));
|
||||
assert_eq!(text_item(&first_items, 1), "session a start");
|
||||
|
||||
responses::mount_sse_once(
|
||||
@@ -1072,7 +1071,7 @@ output_text("session b done");
|
||||
let second_request = second_completion.single_request();
|
||||
let second_items = custom_tool_output_items(&second_request, "call-2");
|
||||
assert_eq!(second_items.len(), 2);
|
||||
let session_b_id = extract_running_session_id(text_item(&second_items, 0));
|
||||
let session_b_id = extract_running_cell_id(text_item(&second_items, 0));
|
||||
assert_eq!(text_item(&second_items, 1), "session b start");
|
||||
|
||||
fs::write(&session_a_gate, "ready")?;
|
||||
@@ -1084,7 +1083,7 @@ output_text("session b done");
|
||||
"call-3",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_b_id,
|
||||
"cell_id": session_b_id.clone(),
|
||||
"yield_time_ms": 1_000,
|
||||
}))?,
|
||||
),
|
||||
@@ -1109,12 +1108,12 @@ output_text("session b done");
|
||||
assert_regex_match(
|
||||
concat!(
|
||||
r"(?s)\A",
|
||||
r"Script running with session ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
r"Script running with cell ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
),
|
||||
text_item(&third_items, 0),
|
||||
);
|
||||
assert_eq!(
|
||||
extract_running_session_id(text_item(&third_items, 0)),
|
||||
extract_running_cell_id(text_item(&third_items, 0)),
|
||||
session_b_id
|
||||
);
|
||||
|
||||
@@ -1134,7 +1133,7 @@ output_text("session b done");
|
||||
"call-4",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_a_id,
|
||||
"cell_id": session_a_id.clone(),
|
||||
"terminate": true,
|
||||
}))?,
|
||||
),
|
||||
@@ -1234,7 +1233,7 @@ output_text("after yield");
|
||||
assert_regex_match(
|
||||
concat!(
|
||||
r"(?s)\A",
|
||||
r"Script running with session ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
r"Script running with cell ID \d+\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
),
|
||||
text_item(&first_items, 0),
|
||||
);
|
||||
@@ -1327,7 +1326,7 @@ output_text("token one token two token three token four token five token six tok
|
||||
let first_items = custom_tool_output_items(&first_request, "call-1");
|
||||
assert_eq!(first_items.len(), 2);
|
||||
assert_eq!(text_item(&first_items, 1), "phase 1");
|
||||
let session_id = extract_running_session_id(text_item(&first_items, 0));
|
||||
let cell_id = extract_running_cell_id(text_item(&first_items, 0));
|
||||
|
||||
fs::write(&completion_gate, "ready")?;
|
||||
responses::mount_sse_once(
|
||||
@@ -1338,7 +1337,7 @@ output_text("token one token two token three token four token five token six tok
|
||||
"call-2",
|
||||
"exec_wait",
|
||||
&serde_json::to_string(&serde_json::json!({
|
||||
"session_id": session_id,
|
||||
"cell_id": cell_id.clone(),
|
||||
"yield_time_ms": 1_000,
|
||||
"max_tokens": 6,
|
||||
}))?,
|
||||
|
||||
Reference in New Issue
Block a user