{"record":{"id":"729fd10cac0017a9","repo":"sgl-project/sglang","slug":"kimi-k3-strict-tool-tool-function-name-r-must-de","errorCode":null,"errorMessage":"Kimi K3 strict tool {tool.function.name!r} must define parameters","messagePattern":"Kimi K3 strict tool (.+?) must define parameters","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/function_call/kimik3_structural_tag.py","lineNumber":439,"sourceCode":"        )\n    if not elements:\n        return ConstStringFormat(value=\"\")\n    return SequenceFormat(elements=elements)\n\n\ndef _tool_arguments_format(tool: Tool) -> Format:\n    parameters = tool.function.parameters\n    if not tool.function.strict:\n        root_schema = parameters if isinstance(parameters, dict) else {}\n        return StarFormat(\n            content=_dynamic_argument_format(True, root_schema, loose_strings=True)\n        )\n    if parameters is None:\n        # Server-side strict levels mark tools without parameters strict too;\n        # they take no arguments rather than failing the whole constraint.\n        return ConstStringFormat(value=\"\")\n    if not isinstance(parameters, dict):\n        raise ValueError(\n            f\"Kimi K3 strict tool {tool.function.name!r} must define parameters\"\n        )\n    schema_types = _schema_types(parameters, parameters)\n    if \"object\" not in schema_types:\n        raise ValueError(\n            f\"Kimi K3 tool {tool.function.name!r} parameters must be an object schema\"\n        )\n    return _strict_arguments_format(parameters)\n\n\ndef _tool_call_tag(tool: Tool, arguments_format: Optional[Format] = None) -> TagFormat:\n    name = _escape_attr(tool.function.name)\n    if arguments_format is None:\n        arguments_format = _tool_arguments_format(tool)\n    return TagFormat(\n        begin=f'{CALL_OPEN} tool=\"{name}\" index=\"',\n        content=SequenceFormat(\n            elements=[","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/function_call/kimik3_structural_tag.py#L421-L457","documentation":"_tool_arguments_format requires each strict tool's parameters field to be a dict (JSON object schema). Tools with parameters None are tolerated (no arguments), but a non-dict value such as a string or list cannot be interpreted as an object schema and fails.","triggerScenarios":"A tool whose function.parameters is a JSON-encoded string or a list rather than a parsed object, e.g. \"parameters\": \"{'type': 'object'}\" passed unparsed.","commonSituations":"Passing serialized JSON strings for parameters instead of dicts; converting from OpenAPI specs where the schema stayed a string; LLM-authored tool specs.","solutions":["Parse parameters into a dict before sending (json.loads if it is a JSON string)","Ensure parameters is either omitted/null (no args) or an object schema like {\"type\": \"object\", \"properties\": {...}}","Add a client-side type check on Tool objects before the request"],"exampleFix":"// before\n{\"name\": \"f\", \"parameters\": \"{\\\"type\\\": \\\"object\\\"}\"}\n// after\n{\"name\": \"f\", \"parameters\": {\"type\": \"object\", \"properties\": {}}}","handlingStrategy":"validation","validationCode":"params = tool[\"function\"].get(\"parameters\")\nassert params is None or isinstance(params, dict), \"parameters must be an object schema or omitted\"","typeGuard":"def valid_tool_parameters(tool: dict) -> bool:\n    p = tool.get(\"function\", tool).get(\"parameters\", None)\n    return p is None or isinstance(p, dict)","tryCatchPattern":"try:\n    resp = client.chat(..., tools=tools)\nexcept ValueError as e:\n    if \"must define parameters\" in str(e):\n        tools = parse_parameters_json(tools)  # then retry\n    else:\n        raise","preventionTips":["json.loads any stringified parameter schemas","Type-check Tool objects client-side before requests"],"tags":["kimi-k3","json-schema","tool-calling","validation","parameters"],"backgroundTag":"json-schema-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}