It seems like Structured Output does not allow objects of arbitrary types. For example, if I have the following Pydantic model:
class ToolCall(pydantic.BaseModel):
"""Represents a single tool call with its arguments.
This model is used to structure and validate tool calls made by the agent.
"""
tool: str = pydantic.Field(..., description="The name of the tool to be called")
tool_running_message: str = pydantic.Field(
default="", description="The message to be displayed when the tool is running"
)
tool_completed_message: str = pydantic.Field(
default="", description="The message to be displayed when the tool is completed"
)
tool_failed_message: str = pydantic.Field(
default="", description="The message to be displayed when the tool fails"
)
args: Dict[str, Any] = pydantic.Field(
default_factory=dict,
description="The arguments to be passed to the tool. Can be left empty if the tool does not require any arguments.",
)
class ResponseFormat(pydantic.BaseModel):
reasoning: str = pydantic.Field(
...,
description="Analyse the conversation history and the current user query to provide a detailed reasoning process.",
)
tool_calls: typing.List[ToolCall] = pydantic.Field(
..., description="The tool calls to be made", min_length=1
)
I get a 400 Bad Request Error:
BadRequestError: Error code: 400 - {'error': {'message': "Invalid schema for response_format 'ResponseFormat': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Extra required key 'args' supplied.", 'type': 'invalid_request_error', 'param': 'response_format', 'code': None}}
Am I doing something wrong here?