Skip to content

feat: Better support for tools_strict=True when using the OpenAIChatGenerator #9411

Open
@sjrl

Description

@sjrl

Is your feature request related to a problem? Please describe.
Currently when a user specifies tools_strict=True when using the OpenAIChatGenerator we only update the provided tool_schema in a basic way. Namely setting strict=True and additionalProperties=False at the top-level of the tools schema.

This puts the majority of the effort on providing a strict compliant tool schema on the user when creating their tools. This isn't great if our users are relying on the automatic tool schema generation we provide in create_tool_from_function and in ComponentTool.

A prominent example is when ChatMessage ends up in the tool parameter schema. It's by default not strict compliant so would cause an OpenAI error if tools_strict=True is passed at run time.

Describe the solution you'd like
Update our tools_strict=True functionality to do a best effort at making the user-provided schema strict compliant. I don't expect we will be able to cover every scenario but at least being able to cover some common examples of types in our component run methods would be nice if they are ever converted into a tool using ComponentTool.

I've started work in this PR #9382 but it's become more involved than I thought to support something like ChatMessage and I don't currently have the time to finish it.

Additional context
A prominent example of this will be when users create Agent tools using ComponentTool + Agent. Agent has List[ChatMessage] in its run method so if users also want to use tools_strict=True they would have to manually create the parameters schema of this tool or they would get an OpenAI error if they tried to use our auto generated schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority, add to the next sprint if no P1 available

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions