mirror of
https://github.com/openai/codex.git
synced 2026-10-23 18:08:45 +00:00
## What changed - Add `otel.tool_result.max_bytes`, defaulting to 2048 bytes, to control the text included in `codex.tool_result` logs independently of model-visible output limits. - Apply truncation centrally when emitting telemetry, preserve UTF-8 boundaries, and report whether the logged output was truncated. - Record typed tool names and namespaces, agent names, and process-local result sequence numbers while keeping tool arguments and output out of trace events. ## Testing - Cover configuration propagation, UTF-8-safe truncation, raw tool-output logging, and log/trace event routing and fields. GitOrigin-RevId: 89ca76e55f1a09b729e7770ce01f2e4d98f9a22d
75 lines
2.1 KiB
Rust
75 lines
2.1 KiB
Rust
use codex_extension_api::ToolOutput;
|
|
use codex_extension_api::ToolPayload;
|
|
use codex_protocol::models::FunctionCallOutputContentItem;
|
|
use codex_protocol::models::FunctionCallOutputPayload;
|
|
use codex_protocol::models::ResponseInputItem;
|
|
|
|
pub(crate) struct SearchOutput {
|
|
output: String,
|
|
}
|
|
|
|
impl SearchOutput {
|
|
pub(crate) fn new(output: String) -> Self {
|
|
Self { output }
|
|
}
|
|
}
|
|
|
|
impl ToolOutput for SearchOutput {
|
|
fn log_output(&self) -> String {
|
|
"[standalone web search output]".to_string()
|
|
}
|
|
|
|
fn success_for_logging(&self) -> bool {
|
|
true
|
|
}
|
|
|
|
fn contains_external_context(&self) -> bool {
|
|
true
|
|
}
|
|
|
|
fn to_response_item(&self, call_id: &str, _payload: &ToolPayload) -> ResponseInputItem {
|
|
ResponseInputItem::FunctionCallOutput {
|
|
call_id: call_id.to_string(),
|
|
output: FunctionCallOutputPayload::from_content_items(vec![
|
|
FunctionCallOutputContentItem::InputText {
|
|
text: self.output.clone(),
|
|
},
|
|
]),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use codex_extension_api::ToolPayload;
|
|
use codex_protocol::models::FunctionCallOutputContentItem;
|
|
use codex_protocol::models::FunctionCallOutputPayload;
|
|
use codex_protocol::models::ResponseInputItem;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use super::SearchOutput;
|
|
use super::ToolOutput;
|
|
|
|
#[test]
|
|
fn emits_plaintext_function_call_output() {
|
|
let output = SearchOutput::new("search output".to_string());
|
|
|
|
assert_eq!(
|
|
output.to_response_item(
|
|
"call-1",
|
|
&ToolPayload::Function {
|
|
arguments: "{}".to_string(),
|
|
},
|
|
),
|
|
ResponseInputItem::FunctionCallOutput {
|
|
call_id: "call-1".to_string(),
|
|
output: FunctionCallOutputPayload::from_content_items(vec![
|
|
FunctionCallOutputContentItem::InputText {
|
|
text: "search output".to_string(),
|
|
},
|
|
]),
|
|
}
|
|
);
|
|
}
|
|
}
|