Skip to content

Tool failed in OpenAI structured-outputs strict mode #113

@zhongyu09

Description

@zhongyu09

I am creating a custom graph with ChatOpenAI llm bind_tools in strict mode.

manage_memory_tool = tools.create_manage_memory_tool(namespace=("memories", "{user_id}"))
tools = [manage_memory_tool]
llm_with_tools = llm.bind_tools(tools, strict=True)

When the llm are called, 400 error occured:

openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid schema for function 'manage_memory': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Missing 'content'.", 'type': 'invalid_request_error', 'param': 'tools[4].function.parameters', 'code': 'invalid_function_parameters'}}

I check the tool definiation, 'required' is an empty list ('required': []), which violates https://platform.openai.com/docs/guides/structured-outputs/supported-schemas?api-mode=responses#all-fields-must-be-required.

Can we have a parameter when creating the tool to be compatible with the strict mode?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions