mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
fix: release session ID when not used (#7592)
This commit is contained in:
@@ -146,6 +146,7 @@ impl ToolHandler for UnifiedExecHandler {
|
||||
codex_protocol::protocol::AskForApproval::OnRequest
|
||||
)
|
||||
{
|
||||
manager.release_process_id(&process_id).await;
|
||||
return Err(FunctionCallError::RespondToModel(format!(
|
||||
"approval policy is {policy:?}; reject command — you cannot ask for escalated permissions if the approval policy is {policy:?}",
|
||||
policy = context.turn.approval_policy
|
||||
@@ -169,6 +170,7 @@ impl ToolHandler for UnifiedExecHandler {
|
||||
)
|
||||
.await?
|
||||
{
|
||||
manager.release_process_id(&process_id).await;
|
||||
return Ok(output);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,11 @@ impl UnifiedExecSessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn release_process_id(&self, process_id: &str) {
|
||||
let mut store = self.session_store.lock().await;
|
||||
store.remove(process_id);
|
||||
}
|
||||
|
||||
pub(crate) async fn exec_command(
|
||||
&self,
|
||||
request: ExecCommandRequest,
|
||||
@@ -129,7 +134,15 @@ impl UnifiedExecSessionManager {
|
||||
request.justification,
|
||||
context,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
let session = match session {
|
||||
Ok(session) => session,
|
||||
Err(err) => {
|
||||
self.release_process_id(&request.process_id).await;
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
|
||||
let max_tokens = resolve_max_tokens(request.max_output_tokens);
|
||||
let yield_time_ms = clamp_yield_time(request.yield_time_ms);
|
||||
@@ -157,6 +170,7 @@ impl UnifiedExecSessionManager {
|
||||
let chunk_id = generate_chunk_id();
|
||||
let process_id = request.process_id.clone();
|
||||
if has_exited {
|
||||
self.release_process_id(&request.process_id).await;
|
||||
let exit = exit_code.unwrap_or(-1);
|
||||
Self::emit_exec_end_from_context(
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user