{"record":{"id":"bf40b55828135b51","repo":"BerriAI/litellm","slug":"tool-call-function-name-must-be-a-string","errorCode":null,"errorMessage":"Tool call `function.name` must be a string","messagePattern":"Tool call `function\\.name` must be a string","errorType":"validation","errorClass":"OCIError","httpStatus":400,"severity":"error","filePath":"litellm/llms/oci/chat/generic.py","lineNumber":133,"sourceCode":"    \"\"\"Convert an assistant tool-call message to OCI format.\"\"\"\n    tool_calls_formatted: Final = []\n    for tool_call in tool_calls:\n        if not isinstance(tool_call, dict):\n            raise OCIError(status_code=400, message=\"Each tool call must be a dictionary\")\n        if tool_call.get(\"type\") != \"function\":\n            raise OCIError(status_code=400, message=\"OCI only supports function tool calls\")\n\n        tool_call_id = tool_call.get(\"id\")\n        if not isinstance(tool_call_id, str):\n            raise OCIError(status_code=400, message=\"Tool call `id` must be a string\")\n\n        tool_function = tool_call.get(\"function\")\n        if not isinstance(tool_function, dict):\n            raise OCIError(status_code=400, message=\"Tool call `function` must be a dictionary\")\n\n        function_name = tool_function.get(\"name\")\n        if not isinstance(function_name, str):\n            raise OCIError(status_code=400, message=\"Tool call `function.name` must be a string\")\n\n        arguments = tool_call[\"function\"].get(\"arguments\", \"{}\")\n        if not isinstance(arguments, str):\n            raise OCIError(\n                status_code=400,\n                message=\"Tool call `function.arguments` must be a JSON string\",\n            )\n\n        tool_calls_formatted.append(\n            OCIToolCall(\n                id=tool_call_id,\n                type=\"FUNCTION\",\n                name=function_name,\n                arguments=arguments,\n            )\n        )\n\n    return OCIMessage(","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/chat/generic.py#L115-L151","documentation":"The nested function object of a tool call must have a string 'name'. A missing, None, or non-string name raises OCIError(400) \"Tool call `function.name` must be a string\" before the request leaves the client. The name is required because OCI's OCIToolCall maps it to the FUNCTION tool invocation name.","triggerScenarios":"Sending {'id':'c1','type':'function','function':{'arguments':'{}'}} (name omitted) or with name set to None/numeric in assistant history to an oci/ GENERIC model.","commonSituations":"Synthetic few-shot tool turns built without names; templated history where the name placeholder failed to render; data pipelines that rename/drop the name key.","solutions":["Always set function.name to the exact tool name string that was declared in the tools parameter.","Render-check templates so name is never empty.","Pre-flight assert isinstance(tc['function'].get('name'), str) and it's non-empty."],"exampleFix":"# before\n{'id':'c1','type':'function','function':{'arguments':'{\"city\":\"SF\"}'}}\n\n# after\n{'id':'c1','type':'function','function':{'name':'get_weather','arguments':'{\"city\":\"SF\"}'}}","handlingStrategy":"type-guard","validationCode":"for tc in msg.get('tool_calls') or []:\n    fn = tc.get('function') or {}\n    assert isinstance(fn.get('name'), str) and fn['name'], f'tool call function.name missing: {tc!r}'","typeGuard":"def tool_call_has_string_name(tc: object) -> bool:\n    return (\n        isinstance(tc, dict)\n        and isinstance(tc.get('function'), dict)\n        and isinstance(tc['function'].get('name'), str)\n        and bool(tc['function']['name'])\n    )","tryCatchPattern":null,"preventionTips":["Match function.name exactly to a name declared in the tools parameter of the same conversation.","Template-render history with strict placeholders that fail loudly when a name is missing."],"tags":["oci","tool-calls","input-validation","missing-parameter"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}