fix(ai): omit tools field instead of sending empty array (#3650)
DashScope / Aliyun Qwen (OpenAI-compatible) rejects `tools: []` with HTTP 400 `"[] is too short - 'tools'"`. Five providers used a truthy check (`if (context.tools)`) that treated an empty array as "send tools", so `pi --no-tools` produced `tools: []` in the request body. Matching the Google provider's pattern, we now guard on `context.tools.length > 0`: - openai-completions.ts - openai-responses.ts - openai-codex-responses.ts - azure-openai-responses.ts - anthropic.ts The openai-completions fallback that emits `tools: []` when the conversation has tool history (required by LiteLLM / Anthropic proxies) is preserved via the existing `else if (hasToolHistory)` branch. closes #3649 Co-authored-by: 槐聚 <huaiju@zbyte-inc.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Stopped sending `tools: []` on OpenAI-compatible, Anthropic, OpenAI Responses, OpenAI Codex Responses, and Azure OpenAI Responses requests when no tools are active (e.g. `pi --no-tools`). DashScope/Aliyun Qwen (OpenAI-compatible) rejects empty tools arrays with `"[] is too short - 'tools'"` (HTTP 400); the field is now omitted unless the conversation has tool history (the existing LiteLLM/Anthropic-proxy workaround).
|
||||
## [0.70.2] - 2026-04-24
|
||||
|
||||
### Fixed
|
||||
|
||||
Reference in New Issue
Block a user