File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use std::sync::Arc;
33use crate :: function_tool:: FunctionCallError ;
44use crate :: maybe_emit_implicit_skill_invocation;
55use crate :: tools:: context:: ExecCommandToolOutput ;
6+ use crate :: tools:: context:: ToolCallSource ;
67use crate :: tools:: context:: ToolInvocation ;
78use crate :: tools:: context:: ToolPayload ;
89use 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 ( ) ,
Original file line number Diff line number Diff 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) ;
Original file line number Diff line number Diff 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 ?;
Original file line number Diff line number Diff 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) ,
You can’t perform that action at this time.
0 commit comments