Custom ai tool fails

AI-generated summary

erphyx reported an issue with custom AI tools failing when they have at least one parameter. The error message indicates an invalid schema for the function, specifically stating that “False is not of type ‘array’”. They noted that tools created from presets don’t have this problem.

Upon investigation, erphyx found that custom tools have an “enum”:false property in the ai_tools table, while preset tools don’t have this property at all. They suggested that the enum should either be an array or not present, but not a boolean value.

erphyx also mentioned that another user had reported the same issue in a separate thread.

In response, Roman_Rizzi apologized for the delay and confirmed that the issue has been fixed, providing a link to the GitHub pull request that addresses the problem.

Symptom:
Any custom tool having at least one parameter fails with the following:

Job exception: {
  "error": {
    "message": "Invalid schema for function 'custom-geocode': False is not of type 'array'.",
    "type": "invalid_request_error",
    "param": "tools[2].function.parameters",
    "code": "invalid_function_parameters"
  }
}

Tools created from presets do not exhibit this.
I pulled the table contents for ai_tools, and the tools created from scratch have an “enum”:false property while the preset ones do not have this. I think enum is supposed to be either an array or not be present, but not a bool, hence the error.
Someone else also already reported this:
https://meta.discourse.org/t/discourse-ai-bot-custom-tool-guide/314103/2?u=erphyx

Thanks for looking into this :slight_smile:

Apologies for the delay. We just fixed this:

https://github.com/discourse/discourse-ai/pull/718

4 Likes