AI Assistant, malformed function arguments if "parameters" property in function schema

If you have a “parameters” property within your function schema, it will cause the function arguments submitted to wrap additional properties within the “parameters” property.

Example Assistant Function:

{
  "name": "QuerySales",
  "parameters": {
    "additionalProperties": false,
    "properties": {
      "parameters": {
        "type": "object",
        "additionalProperties": false,
        "description": "The query parameters.",
        "properties": {
          "type": {
            "type": "object",
            "additionalProperties": false,
            "description": "The type of query to be performed, with possible date interval.",
            "properties": {
              "name": {
                "description": "The type name of the query to be performed.",
                "type": "string",
                "examples": [
                  "metric"
                ],
                "enum": [
                  "metric",
                  "timeline",
                  "grouped"
                ]
              }
            },
            "required": [
              "name"
            ]
          },
          "analytic": {
            "description": "The specified column and aggregate to be performed.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "column": {
                  "description": "The column to select for performing the aggregate function on.",
                  "type": "string",
                  "examples": [
                    "amount"
                  ],
                  "enum": [
                    "amount"
                  ]
                },
                "aggregate": {
                  "description": "The aggregate function to perform on the column.",
                  "type": "string",
                  "examples": [
                    "sum"
                  ],
                  "enum": [
                    "count",
                    "sum"
                  ]
                }
              },
              "required": [
                "column",
                "aggregate"
              ]
            }
          }
        },
        "required": [
          "type",
          "analytic"
        ]
      },
      "filters": {
        "type": "object",
        "additionalProperties": false,
        "description": "Filters to apply to the query.",
        "properties": {
          "date_start": {
            "description": "The start date for the query date range.",
            "type": "string",
            "format": "date-time",
            "examples": [
              "2021-08-03T00:00:00-04:00"
            ]
          },
          "date_end": {
            "description": "The end date for the query date range.",
            "type": "string",
            "format": "date-time",
            "examples": [
              "2021-10-03T23:59:59-04:00"
            ]
          }
        },
        "required": [
          "date_start",
          "date_end"
        ]
      }
    },
    "type": "object",
    "required": [
      "parameters",
      "filters"
    ]
  },
  "description": "Perform a sales query."
}

OpenAI outputs Function arguments. Notice how “filters” was placed in “parameters”.

{
  "parameters": {
    "type": {
      "name": "metric"
    },
    "analytic": [
      {
        "column": "amount_gross",
        "aggregate": "sum"
      }
    ],
    "filters": {
      "date_start": "2023-10-01T00:00:00Z",
      "date_end": "2023-10-31T23:59:59Z"
    }
  }
}

If you change “parameters” property to something else, like “settings” it will output properly.

TLDR: The schema parser for assistant functions seems to wrap any “parameters” property within the schema itself as if it were the functions’ parameters. Hope this made sense.

Also, changing to property to “query_parameters” still causes the bug. Seems that any property with “parameters” contained in the property name will cause problems. For now don’t have any schema property that matches /*parameters*/

The AI does not receive some of the schema you attempt to use, like “additional properties”

image

It is a possible parse error by the API that transforms this into the specification. Let’s see:

AI tool dump of receiving this function
# Tools

## functions

namespace functions {

// Perform a sales query.
type QuerySales = (_: {
// The query parameters.
parameters: {
// The type of query to be performed, with possible date interval.
type: {
// The type name of the query to be performed.
// Example: "metric"
name: "metric" | "timeline" | "grouped",
},
// The specified column and aggregate to be performed.
analytic: Array<
{
// The column to select for performing the aggregate function on.
// Example: "amount"
column: "amount",
// The aggregate function to perform on the column.
// Example: "sum"
aggregate: "count" | "sum",
}
>,
},
// Filters to apply to the query.
filters: {
// The start date for the query date range.
// Example: "2021-08-03T00:00:00-04:00"
date_start: string, // format: "date-time"
// The end date for the query date range.
// Example: "2021-10-03T23:59:59-04:00"
date_end: string, // format: "date-time"
},
}) => any;

} // namespace functions
## multi_tool_use

// This tool serves as a wrapper for utilizing multiple tools. Each tool that can be used must be specified in the tool sections. Only tools in the functions namespace are permitted.
// Ensure that the parameters provided to each tool are valid according to that tool's specification.
namespace multi_tool_use {

// Use this function to run multiple tools simultaneously,...

Indented so that you have the benefit of structure the AI doesn’t have. Ponder if the AI has the mental power to conform:

You could try to switch the positions around so that the confusion is less.

I simply renamed it from “parameters” to “settings” and it works as intended. “parameters” seems to be a property name that should be avoided.

Likewise, you can consider “description” a reserved keyword you cannot use in your function…