mirror of
https://github.com/openai/codex.git
synced 2026-05-29 23:40:29 +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:
@@ -32,7 +32,7 @@ impl CodeModeExecuteHandler {
|
||||
let stored_values = service.stored_values().await;
|
||||
let source =
|
||||
build_source(&code, &enabled_tools).map_err(FunctionCallError::RespondToModel)?;
|
||||
let session_id = service.allocate_session_id().await;
|
||||
let cell_id = service.allocate_cell_id().await;
|
||||
let request_id = service.allocate_request_id().await;
|
||||
let process_slot = service
|
||||
.ensure_started()
|
||||
@@ -41,7 +41,7 @@ impl CodeModeExecuteHandler {
|
||||
let started_at = std::time::Instant::now();
|
||||
let message = HostToNodeMessage::Start {
|
||||
request_id: request_id.clone(),
|
||||
session_id,
|
||||
cell_id: cell_id.clone(),
|
||||
default_yield_time_ms: super::DEFAULT_EXEC_YIELD_TIME_MS,
|
||||
enabled_tools,
|
||||
stored_values,
|
||||
@@ -62,7 +62,7 @@ impl CodeModeExecuteHandler {
|
||||
Ok(message) => message,
|
||||
Err(error) => return Err(FunctionCallError::RespondToModel(error)),
|
||||
};
|
||||
handle_node_message(&exec, session_id, message, None, started_at).await
|
||||
handle_node_message(&exec, cell_id, message, None, started_at).await
|
||||
};
|
||||
match result {
|
||||
Ok(CodeModeSessionProgress::Finished(output))
|
||||
|
||||
@@ -57,7 +57,7 @@ enum CodeModeSessionProgress {
|
||||
enum CodeModeExecutionStatus {
|
||||
Completed,
|
||||
Failed,
|
||||
Running(i32),
|
||||
Running(String),
|
||||
Terminated,
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ pub(crate) fn wait_tool_description() -> &'static str {
|
||||
|
||||
async fn handle_node_message(
|
||||
exec: &ExecContext,
|
||||
session_id: i32,
|
||||
cell_id: String,
|
||||
message: protocol::NodeToHostMessage,
|
||||
poll_max_output_tokens: Option<Option<usize>>,
|
||||
started_at: std::time::Instant,
|
||||
@@ -91,7 +91,7 @@ async fn handle_node_message(
|
||||
delta_items = truncate_code_mode_result(delta_items, poll_max_output_tokens.flatten());
|
||||
prepend_script_status(
|
||||
&mut delta_items,
|
||||
CodeModeExecutionStatus::Running(session_id),
|
||||
CodeModeExecutionStatus::Running(cell_id),
|
||||
started_at.elapsed(),
|
||||
);
|
||||
Ok(CodeModeSessionProgress::Yielded {
|
||||
@@ -161,8 +161,8 @@ fn prepend_script_status(
|
||||
match status {
|
||||
CodeModeExecutionStatus::Completed => "Script completed".to_string(),
|
||||
CodeModeExecutionStatus::Failed => "Script failed".to_string(),
|
||||
CodeModeExecutionStatus::Running(session_id) => {
|
||||
format!("Script running with session ID {session_id}")
|
||||
CodeModeExecutionStatus::Running(cell_id) => {
|
||||
format!("Script running with cell ID {cell_id}")
|
||||
}
|
||||
CodeModeExecutionStatus::Terminated => "Script terminated".to_string(),
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ pub(super) struct CodeModeToolCall {
|
||||
pub(super) enum HostToNodeMessage {
|
||||
Start {
|
||||
request_id: String,
|
||||
session_id: i32,
|
||||
cell_id: String,
|
||||
default_yield_time_ms: u64,
|
||||
enabled_tools: Vec<EnabledTool>,
|
||||
stored_values: HashMap<String, JsonValue>,
|
||||
@@ -49,12 +49,12 @@ pub(super) enum HostToNodeMessage {
|
||||
},
|
||||
Poll {
|
||||
request_id: String,
|
||||
session_id: i32,
|
||||
cell_id: String,
|
||||
yield_time_ms: u64,
|
||||
},
|
||||
Terminate {
|
||||
request_id: String,
|
||||
session_id: i32,
|
||||
cell_id: String,
|
||||
},
|
||||
Response {
|
||||
request_id: String,
|
||||
|
||||
@@ -486,7 +486,7 @@ function createProtocol() {
|
||||
}
|
||||
|
||||
if (message.type === 'poll') {
|
||||
const session = sessions.get(message.session_id);
|
||||
const session = sessions.get(message.cell_id);
|
||||
if (session) {
|
||||
session.request_id = String(message.request_id);
|
||||
if (session.pending_result) {
|
||||
@@ -500,7 +500,7 @@ function createProtocol() {
|
||||
request_id: message.request_id,
|
||||
content_items: [],
|
||||
stored_values: {},
|
||||
error_text: `exec session ${message.session_id} not found`,
|
||||
error_text: `exec cell ${message.cell_id} not found`,
|
||||
max_output_tokens_per_exec_call: DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL,
|
||||
});
|
||||
}
|
||||
@@ -508,7 +508,7 @@ function createProtocol() {
|
||||
}
|
||||
|
||||
if (message.type === 'terminate') {
|
||||
const session = sessions.get(message.session_id);
|
||||
const session = sessions.get(message.cell_id);
|
||||
if (session) {
|
||||
session.request_id = String(message.request_id);
|
||||
void terminateSession(protocol, sessions, session);
|
||||
@@ -518,7 +518,7 @@ function createProtocol() {
|
||||
request_id: message.request_id,
|
||||
content_items: [],
|
||||
stored_values: {},
|
||||
error_text: `exec session ${message.session_id} not found`,
|
||||
error_text: `exec cell ${message.cell_id} not found`,
|
||||
max_output_tokens_per_exec_call: DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL,
|
||||
});
|
||||
}
|
||||
@@ -591,7 +591,7 @@ function startSession(protocol, sessions, start) {
|
||||
completed: false,
|
||||
content_items: [],
|
||||
default_yield_time_ms: normalizeYieldTime(start.default_yield_time_ms),
|
||||
id: start.session_id,
|
||||
id: start.cell_id,
|
||||
initial_yield_timer: null,
|
||||
initial_yield_triggered: false,
|
||||
max_output_tokens_per_exec_call: DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL,
|
||||
|
||||
@@ -24,7 +24,7 @@ pub(crate) struct CodeModeService {
|
||||
js_repl_node_path: Option<PathBuf>,
|
||||
stored_values: Mutex<HashMap<String, JsonValue>>,
|
||||
process: Arc<Mutex<Option<CodeModeProcess>>>,
|
||||
next_session_id: Mutex<i32>,
|
||||
next_cell_id: Mutex<u64>,
|
||||
}
|
||||
|
||||
impl CodeModeService {
|
||||
@@ -33,7 +33,7 @@ impl CodeModeService {
|
||||
js_repl_node_path,
|
||||
stored_values: Mutex::new(HashMap::new()),
|
||||
process: Arc::new(Mutex::new(None)),
|
||||
next_session_id: Mutex::new(1),
|
||||
next_cell_id: Mutex::new(1),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ impl CodeModeService {
|
||||
Some(process.worker(exec, tool_runtime))
|
||||
}
|
||||
|
||||
pub(crate) async fn allocate_session_id(&self) -> i32 {
|
||||
let mut next_session_id = self.next_session_id.lock().await;
|
||||
let session_id = *next_session_id;
|
||||
*next_session_id = next_session_id.saturating_add(1);
|
||||
session_id
|
||||
pub(crate) async fn allocate_cell_id(&self) -> String {
|
||||
let mut next_cell_id = self.next_cell_id.lock().await;
|
||||
let cell_id = *next_cell_id;
|
||||
*next_cell_id = next_cell_id.saturating_add(1);
|
||||
cell_id.to_string()
|
||||
}
|
||||
|
||||
pub(crate) async fn allocate_request_id(&self) -> String {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
- Use `exec_wait` only after `exec` returns `Script running with session ID ...`.
|
||||
- `session_id` identifies the running `exec` session to resume.
|
||||
- Use `exec_wait` only after `exec` returns `Script running with cell ID ...`.
|
||||
- `cell_id` identifies the running `exec` cell to resume.
|
||||
- `yield_time_ms` controls how long to wait for more output before yielding again. If omitted, `exec_wait` uses its default wait timeout.
|
||||
- `max_tokens` limits how much new output this wait call returns.
|
||||
- `terminate: true` stops the running session instead of waiting for more output.
|
||||
- `exec_wait` returns only the new output since the last yield, or the final completion or termination result for that session.
|
||||
- If the session is still running, `exec_wait` may yield again with the same `session_id`.
|
||||
- If the session has already finished, `exec_wait` returns the completed result and closes the session.
|
||||
- `terminate: true` stops the running cell instead of waiting for more output.
|
||||
- `exec_wait` returns only the new output since the last yield, or the final completion or termination result for that cell.
|
||||
- If the cell is still running, `exec_wait` may yield again with the same `cell_id`.
|
||||
- If the cell has already finished, `exec_wait` returns the completed result and closes the cell.
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct CodeModeWaitHandler;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ExecWaitArgs {
|
||||
session_id: i32,
|
||||
cell_id: String,
|
||||
#[serde(default = "default_wait_yield_time_ms")]
|
||||
yield_time_ms: u64,
|
||||
#[serde(default)]
|
||||
@@ -73,12 +73,12 @@ impl ToolHandler for CodeModeWaitHandler {
|
||||
let message = if args.terminate {
|
||||
HostToNodeMessage::Terminate {
|
||||
request_id: request_id.clone(),
|
||||
session_id: args.session_id,
|
||||
cell_id: args.cell_id.clone(),
|
||||
}
|
||||
} else {
|
||||
HostToNodeMessage::Poll {
|
||||
request_id: request_id.clone(),
|
||||
session_id: args.session_id,
|
||||
cell_id: args.cell_id.clone(),
|
||||
yield_time_ms: args.yield_time_ms,
|
||||
}
|
||||
};
|
||||
@@ -111,7 +111,7 @@ impl ToolHandler for CodeModeWaitHandler {
|
||||
};
|
||||
handle_node_message(
|
||||
&exec,
|
||||
args.session_id,
|
||||
args.cell_id,
|
||||
message,
|
||||
Some(args.max_tokens),
|
||||
started_at,
|
||||
|
||||
Reference in New Issue
Block a user