Skip to content

Commit bd6d4af

Browse files
add timed out message back in to shell output
1 parent c22327b commit bd6d4af

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,19 @@ pub fn format_exec_output_for_model_freeform(
7070
// round to 1 decimal place
7171
let duration_seconds = ((exec_output.duration.as_secs_f32()) * 10.0).round() / 10.0;
7272

73-
let total_lines = exec_output.aggregated_output.text.lines().count();
73+
let content = if exec_output.timed_out {
74+
format!(
75+
"command timed out after {} milliseconds\n{}",
76+
exec_output.duration.as_millis(),
77+
exec_output.aggregated_output.text
78+
)
79+
} else {
80+
exec_output.aggregated_output.text.clone()
81+
};
82+
83+
let total_lines = content.lines().count();
7484

75-
let formatted_output = truncate_text(&exec_output.aggregated_output.text, truncation_policy);
85+
let formatted_output = truncate_text(&content, truncation_policy);
7686

7787
let mut sections = Vec::new();
7888

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ async fn shell_command_times_out_with_timeout_ms() -> anyhow::Result<()> {
219219
.replace('\r', "\n")
220220
.trim_end_matches('\n')
221221
.to_string();
222-
let expected_pattern = r"(?s)^Exit code: 124\nWall time: [0-9]+(?:\.[0-9]+)? seconds\nOutput:(?:\ncommand timed out after [0-9]+ milliseconds)?\n?$";
222+
let expected_pattern = r"(?s)^Exit code: 124\nWall time: [0-9]+(?:\.[0-9]+)? seconds\nOutput:\ncommand timed out after [0-9]+ milliseconds\n?$";
223223
assert_regex_match(expected_pattern, &normalized_output);
224224

225225
Ok(())

0 commit comments

Comments
 (0)