
openai
#10047
input_validation_error
Function name does not conform to the required pattern: Only letters, numbers, underscores, or hyphens are allowed, with a maximum length of 64 characters.
This error has been identified and solved.
Reason
The error you're encountering, 'multi_tool_use.parallel' does not match '^[a-zA-Z0-9_-]{1,64}$' - 'messages.10.tool_calls.0.function.name'
, is due to the OpenAI model occasionally hallucinating or generating invalid tool calls. Here are the key points:
Model Hallucination
The GPT model, particularly the GPT-4 Turbo, sometimes generates tool calls that are not valid, such as multi_tool_use.parallel
, even though these tools are not implemented or recognized by the OpenAI API.
Validation Error
The tool name multi_tool_use.parallel
violates the validation pattern expected by the OpenAI API, which requires tool names to match the pattern ^[a-zA-Z0-9_-]{1,64}$
. This pattern does not allow for dots (.
) in the tool name.
Solution
To fix the 400 status error caused by the invalid tool name multi_tool_use.parallel
, you can take the following steps:
Ignore Invalid Tool Calls: If the model generates an invalid tool call, ignore the response and resend the request.
Avoid Nested Calls: Ensure that the model is not trying to invoke nested calls that could result in invalid tool names.
Validate Tool Names: Before processing tool calls, validate them against the expected pattern (
^[a-zA-Z0-9_-]{1,64}$
) to filter out invalid names.Update API Handling: If possible, suggest to OpenAI that they update their API to handle recursive
multi_tool_use.parallel
calls properly.
By following these steps, you can mitigate the issue caused by the model's hallucination of invalid tool names.
Suggested Links
https://cheatsheet.md/chatgpt-cheatsheet/openai-api-error-axioserror-request-failed-status-code-400
https://community.openai.com/t/the-multi-tool-use-parallel-bug-and-how-to-fix-it/880771
https://github.com/microsoft/semantic-kernel/issues/4447
https://community.openai.com/t/intermittent-error-an-unexpected-error-occurred-error-code-400-error-message-this-model-does-not-support-specifying-dimensions-type-invalid-request-error-param-none-code-none/955807
https://github.com/phdowling/openai_multi_tool_use_parallel_patch
https://github.com/run-llama/llama_index/issues/8853
https://community.openai.com/t/getting-400-response-with-already-working-code/509212
https://learn.microsoft.com/fi-fi/azure/ai-services/openai/reference