Skip to content

Commit 01d28ed

Browse files
committed
fix: reconcile post-rebase core fallout
1 parent c393f65 commit 01d28ed

4 files changed

Lines changed: 24 additions & 5 deletions

File tree

codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::Arc;
33
use crate::function_tool::FunctionCallError;
44
use crate::maybe_emit_implicit_skill_invocation;
55
use crate::tools::context::ExecCommandToolOutput;
6+
use crate::tools::context::ToolCallSource;
67
use crate::tools::context::ToolInvocation;
78
use crate::tools::context::ToolPayload;
89
use crate::tools::context::boxed_tool_output;
@@ -98,6 +99,7 @@ impl ToolExecutor<ToolInvocation> for ExecCommandHandler {
9899
cancellation_token,
99100
tracker,
100101
call_id,
102+
source,
101103
payload,
102104
..
103105
} = invocation;
@@ -112,6 +114,10 @@ impl ToolExecutor<ToolInvocation> for ExecCommandHandler {
112114
};
113115

114116
let manager: &UnifiedExecProcessManager = &session.services.unified_exec_manager;
117+
let cancellation_token = match source {
118+
ToolCallSource::CodeMode { .. } => cancellation_token,
119+
ToolCallSource::Direct => tokio_util::sync::CancellationToken::new(),
120+
};
115121
let context = UnifiedExecContext::new_with_cancellation(
116122
session.clone(),
117123
turn.clone(),

codex-rs/core/src/tools/parallel.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,21 @@ impl ToolCallRuntime {
156156
Err(err) => return Err(Self::tool_task_join_error(err)),
157157
}
158158
} else {
159-
handle.abort();
160-
match handle.await {
161-
Ok(result) => return result,
162-
Err(err) if err.is_cancelled() => {}
163-
Err(err) => return Err(Self::tool_task_join_error(err)),
159+
match tokio::time::timeout(
160+
TOOL_CANCELLATION_CLEANUP_GRACE,
161+
&mut handle,
162+
)
163+
.await
164+
{
165+
Ok(result) => return result.map_err(Self::tool_task_join_error)?,
166+
Err(_) => {
167+
handle.abort();
168+
match handle.await {
169+
Ok(result) => return result,
170+
Err(err) if err.is_cancelled() => {}
171+
Err(err) => return Err(Self::tool_task_join_error(err)),
172+
}
173+
}
164174
}
165175
}
166176
let response = Self::aborted_response(&call, secs);

codex-rs/core/tests/suite/compact_remote.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3431,6 +3431,7 @@ async fn remote_sampling_context_window_exceeded_compacts_and_retries() -> Resul
34313431
}],
34323432
final_output_json_schema: None,
34333433
responsesapi_client_metadata: None,
3434+
additional_context: Default::default(),
34343435
thread_settings: Default::default(),
34353436
})
34363437
.await?;
@@ -3445,6 +3446,7 @@ async fn remote_sampling_context_window_exceeded_compacts_and_retries() -> Resul
34453446
}],
34463447
final_output_json_schema: None,
34473448
responsesapi_client_metadata: None,
3449+
additional_context: Default::default(),
34483450
thread_settings: Default::default(),
34493451
})
34503452
.await?;

codex-rs/core/tests/suite/hooks_operator_smoke.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ async fn submit_smoke_turn(
280280
}],
281281
final_output_json_schema: None,
282282
responsesapi_client_metadata: None,
283+
additional_context: Default::default(),
283284
thread_settings: codex_protocol::protocol::ThreadSettingsOverrides {
284285
cwd: Some(test.config.cwd.to_path_buf()),
285286
approval_policy: Some(approval_policy),

0 commit comments

Comments
 (0)