{"record":{"id":"de04d7988ff00964","repo":"sigoden/aichat","slug":"the-call-call-name-has-invalid-arguments","errorCode":null,"errorMessage":"The call '{call_name}' has invalid arguments: {}","messagePattern":"The call '(.+?)' has invalid arguments: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/function.rs","lineNumber":187,"sourceCode":"            id,\n        }\n    }\n\n    pub fn eval(&self, config: &GlobalConfig) -> Result<Value> {\n        let (call_name, cmd_name, mut cmd_args, envs) = match &config.read().agent {\n            Some(agent) => self.extract_call_config_from_agent(config, agent)?,\n            None => self.extract_call_config_from_config(config)?,\n        };\n\n        let json_data = if self.arguments.is_object() {\n            self.arguments.clone()\n        } else if let Some(arguments) = self.arguments.as_str() {\n            let arguments: Value = serde_json::from_str(arguments).map_err(|_| {\n                anyhow!(\"The call '{call_name}' has invalid arguments: {arguments}\")\n            })?;\n            arguments\n        } else {\n            bail!(\n                \"The call '{call_name}' has invalid arguments: {}\",\n                self.arguments\n            );\n        };\n\n        cmd_args.push(json_data.to_string());\n\n        let output = match run_llm_function(cmd_name, cmd_args, envs)? {\n            Some(contents) => serde_json::from_str(&contents)\n                .ok()\n                .unwrap_or_else(|| json!({\"output\": contents})),\n            None => Value::Null,\n        };\n\n        Ok(output)\n    }\n\n    fn extract_call_config_from_agent(","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/function.rs#L169-L205","documentation":"`ToolCall::eval` could not parse the `arguments` field of a tool call as valid JSON. The library expects tool-call arguments to be a JSON object/string containing JSON; anything else is rejected with the raw offending value in the message.","triggerScenarios":"`self.arguments` is a string that fails `serde_json::from_str`, or arguments are neither object nor string (the `bail!` branch), when `eval` runs.","commonSituations":"A model emits truncated or single-quoted pseudo-JSON arguments; a weak/local model emits arguments as plain text; upstream API returns arguments in an unexpected format.","solutions":["Inspect the `{arguments}` value in the message and fix the tool schema/prompt so the model emits valid JSON","Switch to a stronger model that reliably emits JSON tool arguments","Add JSON-repair preprocessing before eval if you control the pipeline"],"exampleFix":"// before (model output)\n{\"arguments\": \"{name: 'foo'}\"}\n// after (valid JSON)\n{\"arguments\": \"{\\\"name\\\": \\\"foo\\\"}\"}","handlingStrategy":"validation","validationCode":"serde_json::from_str::<serde_json::Value>(&call.arguments)\n    .map_err(|e| anyhow!(\"invalid tool arguments: {e}\"))?;","typeGuard":null,"tryCatchPattern":"match tool_call.eval(&config) {\n    Err(e) if e.to_string().contains(\"has invalid arguments\") => {\n        eprintln!(\"Model emitted malformed JSON args; retry with stricter schema\");\n    }\n    other => other?,\n}","preventionTips":["Use models known to emit strict JSON tool arguments","Keep tool parameter schemas simple","Enable the provider's JSON/strict mode for tool calls"],"tags":["json","tool-calls","arguments"],"backgroundTag":"json-parse-error","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}