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
This commit is contained in:
Marshall Bowers 2025-03-05 14:17:44 -05:00 committed by GitHub
parent 87b3fefdd1
commit d0c2bef8c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,