@@ -177,33 +177,10 @@ async fn execute_bash_async(
177177 let mut command = prepare_tokio_command ( & input. command , & cwd, & sandbox_status, true ) ;
178178
179179 let output_result = if let Some ( timeout_ms) = input. timeout {
180- match timeout ( Duration :: from_millis ( timeout_ms) , command. output ( ) ) . await {
181- Ok ( result) => ( result?, false ) ,
182- Err ( _) => {
183- let is_test = is_test_command ( & input. command ) ;
184- let return_code_interpretation = if is_test { "test.hung" } else { "timeout" } ;
185- return Ok ( BashCommandOutput {
186- stdout : String :: new ( ) ,
187- stderr : format ! ( "Command exceeded timeout of {timeout_ms} ms" ) ,
188- raw_output_path : None ,
189- interrupted : true ,
190- is_image : None ,
191- background_task_id : None ,
192- backgrounded_by_user : None ,
193- assistant_auto_backgrounded : None ,
194- dangerously_disable_sandbox : input. dangerously_disable_sandbox ,
195- return_code_interpretation : Some ( String :: from ( return_code_interpretation) ) ,
196- no_output_expected : Some ( true ) ,
197- structured_content : Some ( vec ! [ test_timeout_provenance(
198- & input. command,
199- timeout_ms,
200- is_test,
201- ) ] ) ,
202- persisted_output_path : None ,
203- persisted_output_size : None ,
204- sandbox_status : Some ( sandbox_status) ,
205- } ) ;
206- }
180+ if let Ok ( result) = timeout ( Duration :: from_millis ( timeout_ms) , command. output ( ) ) . await {
181+ ( result?, false )
182+ } else {
183+ return Ok ( timeout_output ( & input, timeout_ms, sandbox_status) ) ;
207184 }
208185 } else {
209186 ( command. output ( ) . await ?, false )
@@ -240,6 +217,36 @@ async fn execute_bash_async(
240217 } )
241218}
242219
220+ fn timeout_output (
221+ input : & BashCommandInput ,
222+ timeout_ms : u64 ,
223+ sandbox_status : SandboxStatus ,
224+ ) -> BashCommandOutput {
225+ let is_test = is_test_command ( & input. command ) ;
226+ let return_code_interpretation = if is_test { "test.hung" } else { "timeout" } ;
227+ BashCommandOutput {
228+ stdout : String :: new ( ) ,
229+ stderr : format ! ( "Command exceeded timeout of {timeout_ms} ms" ) ,
230+ raw_output_path : None ,
231+ interrupted : true ,
232+ is_image : None ,
233+ background_task_id : None ,
234+ backgrounded_by_user : None ,
235+ assistant_auto_backgrounded : None ,
236+ dangerously_disable_sandbox : input. dangerously_disable_sandbox ,
237+ return_code_interpretation : Some ( String :: from ( return_code_interpretation) ) ,
238+ no_output_expected : Some ( true ) ,
239+ structured_content : Some ( vec ! [ test_timeout_provenance(
240+ & input. command,
241+ timeout_ms,
242+ is_test,
243+ ) ] ) ,
244+ persisted_output_path : None ,
245+ persisted_output_size : None ,
246+ sandbox_status : Some ( sandbox_status) ,
247+ }
248+ }
249+
243250fn is_test_command ( command : & str ) -> bool {
244251 let normalized = command
245252 . split_whitespace ( )
0 commit comments