langchain-ai/langchain · error · ValueError
Tool/function already has a 'strict' key with value {oai_fun
Error message
Tool/function already has a 'strict' key with value {oai_function['strict']} which is different from the explicit `strict` arg received {strict=}. What it means
Error "Tool/function already has a 'strict' key with value {oai_function['strict']} which is different from the explicit `strict` arg received {strict=}." thrown in langchain-ai/langchain.
Source
Thrown at libs/core/langchain_core/utils/function_calling.py:477
"function name."
)
raise ValueError(msg)
msg = (
f"Unsupported function\n\n{function}\n\nFunctions must be passed in"
" as Dict, pydantic.BaseModel, or Callable. If they're a dict they must"
" either be in OpenAI function format or valid JSON schema with top-level"
" 'title' key."
)
raise ValueError(msg)
if strict is not None:
if "strict" in oai_function and oai_function["strict"] != strict:
msg = (
f"Tool/function already has a 'strict' key with value "
f"{oai_function['strict']} which is different from the explicit "
f"`strict` arg received {strict=}."
)
raise ValueError(msg)
oai_function["strict"] = strict
if strict:
# All fields must be `required`
parameters = oai_function.get("parameters")
if isinstance(parameters, dict):
fields = parameters.get("properties")
if isinstance(fields, dict) and fields:
parameters = dict(parameters)
parameters["required"] = list(fields.keys())
oai_function["parameters"] = parameters
# As of 08/06/24, OpenAI requires that additionalProperties be supplied and
# set to False if strict is True.
# All properties layer needs 'additionalProperties=False'
oai_function["parameters"] = _recursive_set_additional_properties_false(
oai_function["parameters"]
)
return oai_functionView on GitHub (pinned to e32fa9a52e)
Solutions
- Set 'strict' in exactly one place: either inside the function dict or via the explicit strict argument, not both with different values.
- Make the two values agree, or drop the embedded 'strict' key and use the strict= keyword.
Example fix
convert_to_openai_tool(schema, strict=True) # remove 'strict' from schema dict
When it happens
Trigger: Raised when the function dict already contains a 'strict' key and an explicit strict argument with a conflicting value is also passed.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/420c017939a4f23e.
Report an issue: GitHub.