{"record":{"id":"c6a686af62b6fb21","repo":"openai/openai-python","slug":"tool-function-name-is-not-strict-only","errorCode":null,"errorMessage":"`{tool['function']['name']}` is not strict. Only `strict` function tools can be auto-parsed","messagePattern":"`(.+?)` is not strict\\. Only `strict` function tools can be auto-parsed","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/_parsing/_completions.py","lineNumber":79,"sourceCode":"\n    return [t for t in tools if is_strict_chat_completion_tool_param(t)]\n\n\ndef validate_input_tools(\n    tools: Iterable[ChatCompletionToolUnionParam] | Omit = omit,\n) -> Iterable[ChatCompletionFunctionToolParam] | Omit:\n    if not is_given(tools):\n        return omit\n\n    for tool in tools:\n        if tool[\"type\"] != \"function\":\n            raise ValueError(\n                f\"Currently only `function` tool types support auto-parsing; Received `{tool['type']}`\",\n            )\n\n        strict = tool[\"function\"].get(\"strict\")\n        if strict is not True:\n            raise ValueError(\n                f\"`{tool['function']['name']}` is not strict. Only `strict` function tools can be auto-parsed\"\n            )\n\n    return cast(Iterable[ChatCompletionFunctionToolParam], tools)\n\n\ndef parse_chat_completion(\n    *,\n    response_format: type[ResponseFormatT] | completion_create_params.ResponseFormat | Omit,\n    input_tools: Iterable[ChatCompletionToolUnionParam] | Omit,\n    chat_completion: ChatCompletion | ParsedChatCompletion[object],\n) -> ParsedChatCompletion[ResponseFormatT]:\n    if is_given(input_tools):\n        input_tools = [t for t in input_tools]\n    else:\n        input_tools = []\n\n    choices: list[ParsedChoice[ResponseFormatT]] = []","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/_parsing/_completions.py#L61-L97","documentation":"Auto-parsing of tool-call arguments requires strict JSON-schema function tools (function.strict == True) so the arguments are guaranteed valid JSON. The validator rejects any function tool whose 'strict' field is not exactly true.","triggerScenarios":"Passing a function tool without strict: true (or strict: false) to client.chat.completions.parse.","commonSituations":"Copying tool definitions from completions.create where strict is optional; manually building tool dicts and omitting 'strict'; strict set to truthy non-True value.","solutions":["Set \"strict\": True in the function tool definition","Ensure the tool's parameters JSON schema is strict-compatible (additionalProperties: false, all fields required) — to_strict_json_schema can do this from a Pydantic model","Use pydantic_function_tool(MyModel) to generate a compliant strict tool param"],"exampleFix":"# before\ntools = [{\"type\":\"function\",\"function\":{\"name\":\"get_weather\",\"parameters\":{...}}}]\n# after\ntools = [{\"type\":\"function\",\"function\":{\"name\":\"get_weather\",\"strict\":True,\"parameters\":strict_schema}}]","handlingStrategy":"validation","validationCode":"for t in tools:\n    if t[\"type\"] == \"function\" and t[\"function\"].get(\"strict\") is not True:\n        raise ValueError(f\"tool {t['function']['name']} must be strict\")","typeGuard":"def is_strict_function_tool(t: dict) -> bool:\n    return t.get(\"type\") == \"function\" and t[\"function\"].get(\"strict\") is True","tryCatchPattern":null,"preventionTips":["Use pydantic_function_tool(MyModel) to build compliant strict tools","Add strict: True whenever you intend to auto-parse arguments"],"tags":["completions","tools","strict-mode","parsing"],"backgroundTag":"strict-schema-required","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}