Tighten panic on double truncation (#6701)

This commit is contained in:
Ahmed Ibrahim
2025-11-14 23:28:59 -08:00
committed by GitHub
parent 0b28e72b66
commit 3f1c4b9add

View File

@@ -2,7 +2,6 @@
//! and suffix on UTF-8 boundaries, and helpers for line/tokenbased truncation
//! used across the core crate.
use crate::util::error_or_panic;
use codex_protocol::models::FunctionCallOutputContentItem;
use codex_utils_string::take_bytes_at_char_boundary;
use codex_utils_string::take_last_bytes_at_char_boundary;
@@ -85,7 +84,7 @@ fn truncate_formatted_exec_output(
limit_bytes: usize,
limit_lines: usize,
) -> String {
debug_panic_on_double_truncation(content);
error_on_double_truncation(content);
let head_lines: usize = limit_lines / 2;
let tail_lines: usize = limit_lines - head_lines; // 128
let head_bytes: usize = limit_bytes / 2;
@@ -148,11 +147,11 @@ fn truncate_formatted_exec_output(
result
}
fn debug_panic_on_double_truncation(content: &str) {
fn error_on_double_truncation(content: &str) {
if content.contains("Total output lines:") && content.contains("omitted") {
error_or_panic(format!(
tracing::error!(
"FunctionCallOutput content was already truncated before ContextManager::record_items; this would cause double truncation {content}"
));
);
}
}