Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Truncate input text in protocol debug output (#49415)

Dmitriy Kovalenkod940fb21f35e
diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock
index 56a74c464d..9fd17b06a6 100644
--- a/codex-rs/Cargo.lock
+++ b/codex-rs/Cargo.lock
@@ -4268,6 +4268,7 @@ dependencies = [
"codex-utils-path-uri",
"codex-utils-redacted-string",
"codex-utils-string",
+ "derive_more 2.1.1",
"encoding_rs",
"gix-url",
"globset",
diff --git a/codex-rs/protocol/Cargo.toml b/codex-rs/protocol/Cargo.toml
index 0ca5117c8c..914ed5260c 100644
--- a/codex-rs/protocol/Cargo.toml
+++ b/codex-rs/protocol/Cargo.toml
@@ -25,6 +25,7 @@ codex-utils-image = { workspace = true }
codex-utils-path-uri = { workspace = true }
codex-utils-redacted-string = { workspace = true }
codex-utils-string = { workspace = true }
+derive_more = { workspace = true, features = ["debug"] }
encoding_rs = { workspace = true }
gix-url = { workspace = true }
globset = { workspace = true }
diff --git a/codex-rs/protocol/src/models.rs b/codex-rs/protocol/src/models.rs
index e31b88fdbb..bb29f84985 100644
--- a/codex-rs/protocol/src/models.rs
+++ b/codex-rs/protocol/src/models.rs
@@ -873,10 +873,11 @@ pub enum ResponseInputItem {
},
}
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema, TS)]
+#[derive(derive_more::Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema, TS)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ContentItem {
InputText {
+ #[debug("{:?} <{} bytes>", &text[..text.floor_char_boundary(/*index*/ 512)], text.len())]
text: String,
},
InputImage {
diff --git a/codex-rs/protocol/src/user_input.rs b/codex-rs/protocol/src/user_input.rs
index 8f5f87c00a..9e28c5ec3d 100644
--- a/codex-rs/protocol/src/user_input.rs
+++ b/codex-rs/protocol/src/user_input.rs
@@ -11,10 +11,11 @@ pub const MAX_USER_INPUT_TEXT_CHARS: usize = 1 << 20;
/// User input
#[non_exhaustive]
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, TS, JsonSchema)]
+#[derive(derive_more::Debug, Clone, Deserialize, Serialize, PartialEq, TS, JsonSchema)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum UserInput {
Text {
+ #[debug("{:?} <{} bytes>", &text[..text.floor_char_boundary(/*index*/ 512)], text.len())]
text: String,
/// UI-defined spans within `text` that should be treated as special elements.
/// These are byte ranges into the UTF-8 `text` buffer and are used to render