mirror of
https://github.com/openai/codex.git
synced 2026-10-18 17:18:52 +00:00
Limit payload traces in diagnostic logs (#37497)
## Why High-volume request and streamed-response payloads can overwhelm the SQLite log database and diagnostic ring buffer used for reports. ## What changed - Limit HTTP transport, SSE, and WebSocket diagnostics to `DEBUG` in persistent log sinks while leaving unrelated trace diagnostics available. - Log known unhandled response events and delta events at `TRACE`, and surface unexpected event kinds at `DEBUG` without including their payloads. - Report structured parse-error metadata instead of logging an unparseable SSE payload. ## Testing - Cover filtering for transport, SSE, WebSocket, and unrelated trace records in both report and SQLite log sinks. - Cover unknown and unsupported delta response events. GitOrigin-RevId: 6d9121e093ddadf6834da394df544d9c09d8aeb9
This commit is contained in:
@@ -467,9 +467,28 @@ pub fn process_responses_event(
|
||||
}));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
"codex.response.metadata"
|
||||
| "response.content_part.added"
|
||||
| "response.content_part.done"
|
||||
| "response.custom_tool_call_input.done"
|
||||
| "response.function_call_arguments.delta"
|
||||
| "response.function_call_arguments.done"
|
||||
| "response.in_progress"
|
||||
| "response.metadata"
|
||||
| "response.output_text.done"
|
||||
| "response.reasoning_summary_part.done"
|
||||
| "responsesapi.websocket_timing" => {
|
||||
trace!("unhandled responses event: {}", event.kind);
|
||||
}
|
||||
kind if kind.ends_with(".delta") => {
|
||||
trace!("unhandled responses event: {kind}");
|
||||
}
|
||||
_ => {
|
||||
debug!(
|
||||
"unhandled responses event: {:?}",
|
||||
event.kind.chars().take(128).collect::<String>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
@@ -536,7 +555,13 @@ async fn process_sse_with_treatment(
|
||||
let event: ResponsesStreamEvent = match serde_json::from_str(&sse.data) {
|
||||
Ok(event) => event,
|
||||
Err(e) => {
|
||||
debug!("Failed to parse SSE event: {e}, data: {}", &sse.data);
|
||||
debug!(
|
||||
error_category = ?e.classify(),
|
||||
error_line = e.line(),
|
||||
error_column = e.column(),
|
||||
payload_bytes = sse.data.len(),
|
||||
"Failed to parse SSE event"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@@ -1203,7 +1228,27 @@ mod tests {
|
||||
},
|
||||
TestCase {
|
||||
name: "unknown",
|
||||
event: json!({"type": "response.new_tool_event"}),
|
||||
event: json!({"type": "response.new_tool_event", "sequence_number": 1}),
|
||||
expect_first: is_completed,
|
||||
expected_len: 1,
|
||||
},
|
||||
TestCase {
|
||||
name: "refusal_delta",
|
||||
event: json!({
|
||||
"type": "response.refusal.delta",
|
||||
"delta": "no",
|
||||
"sequence_number": 1
|
||||
}),
|
||||
expect_first: is_completed,
|
||||
expected_len: 1,
|
||||
},
|
||||
TestCase {
|
||||
name: "mcp_call_arguments_delta",
|
||||
event: json!({
|
||||
"type": "response.mcp_call_arguments.delta",
|
||||
"delta": "chunk",
|
||||
"sequence_number": 1
|
||||
}),
|
||||
expect_first: is_completed,
|
||||
expected_len: 1,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user