mirror of
https://github.com/hwchase17/langchain.git
synced 2026-01-25 22:49:59 +00:00
Scheduled testing started failing today because the Responses API stopped raising `BadRequestError` for a schema that was previously invalid when `strict=True`. Although docs still say that [some type-specific keywords are not yet supported](https://platform.openai.com/docs/guides/structured-outputs#some-type-specific-keywords-are-not-yet-supported) (including `minimum` and `maximum` for numbers), the below appears to run and correctly respect the constraints: ```python import json import openai maximums = list(range(1, 11)) arg_values = [] for maximum in maximums: tool = { "type": "function", "name": "magic_function", "description": "Applies a magic function to an input.", "parameters": { "properties": { "input": {"maximum": maximum, "minimum": 0, "type": "integer"} }, "required": ["input"], "type": "object", "additionalProperties": False }, "strict": True } client = openai.OpenAI() response = client.responses.create( model="gpt-4.1", input=[{"role": "user", "content": "What is the value of magic_function(3)? Use the tool."}], tools=[tool], ) function_call = next(item for item in response.output if item.type == "function_call") args = json.loads(function_call.arguments) arg_values.append(args["input"]) print(maximums) print(arg_values) # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # [1, 2, 3, 3, 3, 3, 3, 3, 3, 3] ``` Until yesterday this raised BadRequestError. The same is not true of Chat Completions, which appears to still raise BadRequestError ```python tool = { "type": "function", "function": { "name": "magic_function", "description": "Applies a magic function to an input.", "parameters": { "properties": { "input": {"maximum": 5, "minimum": 0, "type": "integer"} }, "required": ["input"], "type": "object", "additionalProperties": False }, "strict": True } } response = client.chat.completions.create( model="gpt-4.1", messages=[{"role": "user", "content": "What is the value of magic_function(3)? Use the tool."}], tools=[tool], ) response # raises BadRequestError ``` Here we update tests accordingly.