openai/openai-python · error · ValueError
`{tool['function']['name']}` is not strict. Only `strict` fu
Error message
`{tool['function']['name']}` is not strict. Only `strict` function tools can be auto-parsed What it means
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.
Source
Thrown at src/openai/lib/_parsing/_completions.py:79
return [t for t in tools if is_strict_chat_completion_tool_param(t)]
def validate_input_tools(
tools: Iterable[ChatCompletionToolUnionParam] | Omit = omit,
) -> Iterable[ChatCompletionFunctionToolParam] | Omit:
if not is_given(tools):
return omit
for tool in tools:
if tool["type"] != "function":
raise ValueError(
f"Currently only `function` tool types support auto-parsing; Received `{tool['type']}`",
)
strict = tool["function"].get("strict")
if strict is not True:
raise ValueError(
f"`{tool['function']['name']}` is not strict. Only `strict` function tools can be auto-parsed"
)
return cast(Iterable[ChatCompletionFunctionToolParam], tools)
def parse_chat_completion(
*,
response_format: type[ResponseFormatT] | completion_create_params.ResponseFormat | Omit,
input_tools: Iterable[ChatCompletionToolUnionParam] | Omit,
chat_completion: ChatCompletion | ParsedChatCompletion[object],
) -> ParsedChatCompletion[ResponseFormatT]:
if is_given(input_tools):
input_tools = [t for t in input_tools]
else:
input_tools = []
choices: list[ParsedChoice[ResponseFormatT]] = []View on GitHub (pinned to 9917c6e28e)
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
Example fix
# before
tools = [{"type":"function","function":{"name":"get_weather","parameters":{...}}}]
# after
tools = [{"type":"function","function":{"name":"get_weather","strict":True,"parameters":strict_schema}}] Defensive patterns
Strategy: validation
Validate before calling
for t in tools:
if t["type"] == "function" and t["function"].get("strict") is not True:
raise ValueError(f"tool {t['function']['name']} must be strict") Type guard
def is_strict_function_tool(t: dict) -> bool:
return t.get("type") == "function" and t["function"].get("strict") is True Prevention
- Use pydantic_function_tool(MyModel) to build compliant strict tools
- Add strict: True whenever you intend to auto-parse arguments
When it happens
Trigger: Passing a function tool without strict: true (or strict: false) to client.chat.completions.parse.
Common situations: Copying tool definitions from completions.create where strict is optional; manually building tool dicts and omitting 'strict'; strict set to truthy non-True value.
Related errors
- Currently only `function` tool types support auto-parsing; R
- Unable to automatically parse response format type {response
- Expected Content-Type response header to be `application/jso
- invalid datetime format
- invalid date format
AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28).
Data as JSON: /api/errors/c6a686af62b6fb21.
Report an issue: GitHub.