mirror of
https://github.com/openai/codex.git
synced 2026-10-20 00:18:49 +00:00
Truncate input text in protocol debug output (#49415)
## What changed Use `derive_more::Debug` for `ContentItem` and `UserInput` to limit debug formatting of `ContentItem::InputText` and `UserInput::Text` to a prefix of at most 512 bytes, ending at a UTF-8 character boundary. Append the full text length in bytes to each preview. GitOrigin-RevId: ca711dde8f0e3ba7047103415dbc1836f6401e61
This commit is contained in:
committed by
copyberry
parent
16a7c0f0eb
commit
d940fb21f3
Generated
+1
@@ -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",
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user