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 <noreply@anthropic.com>
This commit is contained in:
Edvard 2026-02-17 17:44:31 -05:00 committed by Chummy
parent 7de052c7d2
commit 6d8725c9e6

View file

@ -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();