From 6d8725c9e6c40bc3dab61fcff4720449f3f5a856 Mon Sep 17 00:00:00 2001 From: Edvard Date: Tue, 17 Feb 2026 17:44:31 -0500 Subject: [PATCH] fix(agent): log warning when native tool call arguments fail JSON parsing The NativeToolDispatcher silently defaults to an empty object when tool call arguments from the LLM fail to parse as JSON. The XML dispatcher already logs a warning for the same case (line 68). Add a matching tracing::warn with tool name and parse error for observability parity. Co-Authored-By: Claude Opus 4.6 --- src/agent/dispatcher.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/agent/dispatcher.rs b/src/agent/dispatcher.rs index 673ec8c..bf3c4ac 100644 --- a/src/agent/dispatcher.rs +++ b/src/agent/dispatcher.rs @@ -166,8 +166,14 @@ impl ToolDispatcher for NativeToolDispatcher { .iter() .map(|tc| ParsedToolCall { name: tc.name.clone(), - arguments: serde_json::from_str(&tc.arguments) - .unwrap_or_else(|_| Value::Object(serde_json::Map::new())), + arguments: serde_json::from_str(&tc.arguments).unwrap_or_else(|e| { + tracing::warn!( + tool = %tc.name, + error = %e, + "Failed to parse native tool call arguments as JSON; defaulting to empty object" + ); + Value::Object(serde_json::Map::new()) + }), tool_call_id: Some(tc.id.clone()), }) .collect();