From 7595ee083ec6dce2fdffe8ee89b46a4c2ea7404e Mon Sep 17 00:00:00 2001 From: Dhanji Prasanna Date: Sat, 27 Sep 2025 12:18:27 +1000 Subject: [PATCH] logging optimization --- Cargo.lock | 25 +++++++++++++++++++++++++ crates/g3-core/src/lib.rs | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 78aac68..fa811ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1741,6 +1741,26 @@ dependencies = [ "sha2", ] +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -2486,6 +2506,10 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", "tower-layer", "tower-service", "tracing", @@ -2519,6 +2543,7 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "pin-project-lite", + "tokio", "tower-layer", "tower-service", "tracing", diff --git a/crates/g3-core/src/lib.rs b/crates/g3-core/src/lib.rs index a660860..0d4000f 100644 --- a/crates/g3-core/src/lib.rs +++ b/crates/g3-core/src/lib.rs @@ -959,6 +959,7 @@ The tool will execute immediately and you'll receive the result (success or erro // Check for tool calls - prioritize native tool calls over JSON parsing let mut detected_tool_call = None; + let mut is_text_based_tool_call = false; // First check for native tool calls in the chunk if let Some(ref tool_calls) = chunk.tool_calls { @@ -985,6 +986,7 @@ The tool will execute immediately and you'll receive the result (success or erro detected_tool_call = parser.add_chunk(&chunk.content); if detected_tool_call.is_some() { debug!("Found JSON tool call in text content for native provider"); + is_text_based_tool_call = true; } } @@ -1035,6 +1037,20 @@ The tool will execute immediately and you'll receive the result (success or erro io::stdout().flush()?; } + // Check if this was a JSON tool call detected from text (not native) + // If so, show a brief indicator that we detected a text-based tool call + let provider = self.providers.get(None)?; + if provider.has_native_tool_calling() && is_text_based_tool_call { + // This means we detected a JSON tool call in text for a native provider + // Show a brief indicator instead of the raw JSON + if !response_started { + print!("\ršŸ¤– "); // Clear thinking indicator and show response indicator + response_started = true; + } + print!("šŸ”§ "); // Brief tool call indicator + io::stdout().flush()?; + } + // Execute the tool with formatted output println!(); // New line before tool execution