# 错误：并行函数调用需要不同的函数名称——检测到重复的'get_weather'

- **ID:** `llm/parallel-function-call-schema-conflict`
- **领域:** llm
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| openai>=1.0.0 | active | — | — |
| gpt-4-0125-preview | active | — | — |
| gpt-4-turbo-2024-04-09 | active | — | — |

## 解决方案

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

## 无效尝试

- **** — Function names are defined in the tools array and must be static; dynamic renaming breaks schema consistency (90% 失败率)
- **** — Disabling parallel calls reduces throughput and may cause timeouts for workflows requiring multiple tool invocations (50% 失败率)
- **** — The LLM may consistently generate duplicate calls for certain inputs; retries are unreliable and waste tokens (70% 失败率)
