Enum error in strict tool calling function
# support
f
Hi, I'm getting this error today. { "message": [ "squad.members.0.assistant.model.each value in tools.function.parameters.properties.dateOfBirthYear.each value in enum must be a string" ], "error": "Bad Request", "statusCode": 400 } 1. I didn't make any changes to my function from last week when it was working. 2. The dateOfBirthYear parameter is an integer, so I don't see why the enum values would need to be strings. My tool call function looks like this (I've removed other parameters and changed descriptions). The intention is to be able to get the date of birth of a customer, so enum with strict tool-calling forces the agent to provide valid dates: { "async": false, "messages": [ { "type": "request-start", "content": "Give me a second to check the system." }, { "type": "request-failed", "content": "Apologies, there was an issue verifying your account." } ], "type": "function", "function": { "name": "GetDateOfBirth", "strict": true, "description": "a description for my function...", "parameters": { "type": "object", "properties": { "dateOfBirthYear": { "type": "integer", "description": "The year of birth.", "enum": [1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015] } }, "required": [ "dateOfBirthYear" ], "additionalProperties": false } } }
v
@flyingemolga It seems like there might be a discrepancy between the expected data types in the
enum
for the
dateOfBirthYear
parameter. Although you've mentioned that the
dateOfBirthYear
is an integer, the error message suggests that the
enum
values are expected to be strings within the system you're interfacing with. To resolve this issue, you could try changing the
enum
values to strings by enclosing the years in quotes. However, since this might not align with your original design, it would be best to check the documentation or system requirements to confirm the expected data type for the
enum
values. If the documentation confirms that integers are the correct type for the
enum
, then there might be a system error or a recent change in the API that is causing this issue. In that case, you should contact the support team for further assistance. Would you like me to assist you with anything else at this moment?
You can continue this conversation by mentioning me in the message.
f
s
@flyingemolga Based on the error message, even though your dateOfBirthYear parameter is defined as type "integer", the API requires the enum values to be strings. To fix this, you'll need to convert all the year values in the enum array to strings by wrapping them in quotes. For example: "enum": ["1916", "1917", "1918", ... "2015"] This is a requirement of the API validation system, even though the actual values will be parsed as integers when used. Simply convert all your enum values to strings while keeping the parameter type as "integer" and the error should be resolved.
Do let me know your thoughts on this.
f
I find that strange, but I'll try it at let you know if it fixes the issue.
Ok, so your suggestion works, but it seems that the tool call it sends to my server is then a string as opposed to an integer. I've made the necessary changes to convert it back to an integer on my tool call server, so I suppose everything's working again... Are you aware of any reason for this change recently? The same request gave no issues last week and this change seems unintuitive. Not exactly the same thing, but following OpenAI's structured output documentation (https://platform.openai.com/docs/guides/structured-outputs), I can provide jsons with integer enums with strict set to true and don't get any issues. Can I report this issue as a bug to be fixed?
s
@flyingemolga thanks for letting us know i will report this issue to the team, and will update once it is resolved.
f
Thanks, appreciate it 👍