From d0c2bef8c397d3e94ec5c09423adf19e02d9fb93 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 5 Mar 2025 14:17:44 -0500 Subject: [PATCH] anthropic: Use an empty object if no tool input is provided (#26144) This PR changes the default value when no input is provided with a tool use from `null` to `{}`. This fixes an issue I was seeing where tools that didn't accept input were not being called correctly. Release Notes: - N/A --- crates/language_models/src/provider/anthropic.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/language_models/src/provider/anthropic.rs b/crates/language_models/src/provider/anthropic.rs index 011224cf1a..ec9fcfeb8f 100644 --- a/crates/language_models/src/provider/anthropic.rs +++ b/crates/language_models/src/provider/anthropic.rs @@ -639,7 +639,9 @@ pub fn map_to_language_model_completion_events( id: tool_use.id.into(), name: tool_use.name.into(), input: if tool_use.input_json.is_empty() { - serde_json::Value::Null + serde_json::Value::Object( + serde_json::Map::default(), + ) } else { serde_json::Value::from_str( &tool_use.input_json,