From d4eed6dca57fc72298808aed5a4bfe43285bf98f Mon Sep 17 00:00:00 2001 From: Sean Huang Date: Fri, 2 Oct 2026 22:17:09 +0000 Subject: [PATCH] Assert that only direct tool calls emit timing events (#50445) ## What changed Strengthen `tool_call_timing_guard_ignores_code_mode_source` to capture tracing output and assert that direct and nested code-mode calls together emit exactly one `codex.tool_call` event. Disable ANSI formatting and keep callsite interest independent of untraced parallel test threads. GitOrigin-RevId: cbf0c9bf6d4e5a72b6a1eb08e6aac43e257f2dcb --- codex-rs/core/src/tools/parallel.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/codex-rs/core/src/tools/parallel.rs b/codex-rs/core/src/tools/parallel.rs index 0a7afc54cc..3daefd3925 100644 --- a/codex-rs/core/src/tools/parallel.rs +++ b/codex-rs/core/src/tools/parallel.rs @@ -477,9 +477,15 @@ mod tests { #[test] fn tool_call_timing_guard_ignores_code_mode_source() { + let buffer: &'static std::sync::Mutex> = + Box::leak(Box::new(std::sync::Mutex::new(Vec::new()))); let subscriber = tracing_subscriber::fmt() + .with_ansi(false) .with_max_level(tracing::Level::INFO) + .with_writer(MockWriter::new(buffer)) .finish(); + // Keep callsite interest independent of untraced parallel test threads. + let _untraced = tracing::Dispatch::new(tracing::subscriber::NoSubscriber::default()); tracing::subscriber::with_default(subscriber, || { let call = ToolCall { tool_name: codex_tools::ToolName::plain("test_tool"), @@ -519,6 +525,15 @@ mod tests { "nested code-mode calls should not create overlapping timing events" ); }); + + let logs = String::from_utf8(buffer.lock().unwrap().clone()).unwrap(); + assert_eq!( + logs.lines() + .filter(|line| line.contains("event.name=\"codex.tool_call\"")) + .count(), + 1, + "only direct tool calls should emit a timing event; logs:\n{logs}" + ); } #[test]