util.rs

 1use std::str::FromStr;
 2
 3/// Parses tool call arguments JSON, treating empty strings as empty objects.
 4///
 5/// Many LLM providers return empty strings for tool calls with no arguments.
 6/// This helper normalizes that behavior by converting empty strings to `{}`.
 7pub fn parse_tool_arguments(arguments: &str) -> Result<serde_json::Value, serde_json::Error> {
 8    if arguments.is_empty() {
 9        Ok(serde_json::Value::Object(Default::default()))
10    } else {
11        serde_json::Value::from_str(arguments)
12    }
13}