llm config_error ai_generated true

Error: Parallel function calls require distinct function names — duplicate 'get_weather' detected

ID: llm/parallel-function-call-schema-conflict

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
1Evidence
2024-06-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
openai>=1.0.0 active
gpt-4-0125-preview active
gpt-4-turbo-2024-04-09 active

Root Cause

When using parallel function calling, the LLM may attempt to call the same function multiple times concurrently; the API rejects duplicate function names in a single response's tool_calls array.

generic

中文

使用并行函数调用时,LLM 可能尝试同时多次调用同一函数;API 会拒绝单个响应中 tool_calls 数组内的重复函数名称。

Official Documentation

https://platform.openai.com/docs/guides/function-calling/parallel-function-calling

Workarounds

  1. 90% success Allow duplicate function names by design: define the function once in tools, and handle multiple calls to the same function in your application logic by iterating over the tool_calls array.
    Allow duplicate function names by design: define the function once in tools, and handle multiple calls to the same function in your application logic by iterating over the tool_calls array.
  2. 85% success If parallel calls are not required, set parallel_tool_calls=false in the request to force sequential function calling.
    If parallel calls are not required, set parallel_tool_calls=false in the request to force sequential function calling.
  3. 80% success Implement a deduplication layer: before processing tool_calls, merge duplicate function calls with the same name into a single call with combined parameters, or reject duplicates with a clear error message.
    Implement a deduplication layer: before processing tool_calls, merge duplicate function calls with the same name into a single call with combined parameters, or reject duplicates with a clear error message.

中文步骤

  1. 允许重复的函数名称:在 tools 中定义一次函数,并通过遍历 tool_calls 数组在应用逻辑中处理对同一函数的多次调用。
  2. 如果不需要并行调用,在请求中设置 parallel_tool_calls=false 以强制顺序函数调用。
  3. 实现去重层:在处理 tool_calls 之前,将具有相同名称的重复函数调用合并为具有合并参数的单个调用,或用清晰的错误消息拒绝重复。

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Function names are defined in the tools array and must be static; dynamic renaming breaks schema consistency

  2. 50% fail

    Disabling parallel calls reduces throughput and may cause timeouts for workflows requiring multiple tool invocations

  3. 70% fail

    The LLM may consistently generate duplicate calls for certain inputs; retries are unreliable and waste tokens