Skip to content

Commit df2fabc

Browse files
committed
truncate
1 parent a4f61d2 commit df2fabc

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

codex-rs/core/src/codex.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,9 +2340,6 @@ mod tests {
23402340
assert_eq!(expected, got);
23412341
}
23422342

2343-
// Truncation tests have moved to conversation_history where
2344-
// the model-facing formatting now lives.
2345-
23462343
#[test]
23472344
fn includes_timed_out_message() {
23482345
let exec = ExecToolCallOutput {

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod runtimes;
99
pub mod sandboxing;
1010
pub mod spec;
1111

12+
use crate::conversation_history::format_exec_output;
1213
use crate::exec::ExecToolCallOutput;
1314
pub use router::ToolRouter;
1415
use serde::Serialize;
@@ -64,13 +65,15 @@ pub fn format_exec_output_str(exec_output: &ExecToolCallOutput) -> String {
6465

6566
let content = aggregated_output.text.as_str();
6667

67-
if exec_output.timed_out {
68-
let prefixed = format!(
68+
let body = if exec_output.timed_out {
69+
format!(
6970
"command timed out after {} milliseconds\n{content}",
7071
exec_output.duration.as_millis()
71-
);
72-
return prefixed;
73-
}
72+
)
73+
} else {
74+
content.to_string()
75+
};
7476

75-
content.to_string()
77+
// Truncate for model consumption before serialization.
78+
format_exec_output(&body)
7679
}

0 commit comments

Comments
 (0)