nanocoder
nanocoder copied to clipboard
[Bug] Any HTTP 400 that mentions "tool" or "function" turns off native tool calling for that model until restart
Description
isToolSupportError treats every 400 containing words like "tool", "function" or "invalid ... function" as "this model does not support tools". The model is then added to a process-wide set and every later request is sent without native tools.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at f92cce9c)
- Provider: Local mock OpenAI-compatible server
- Model: Mock model
Steps to Reproduce
- Run a mock server that answers the first request with HTTP 400
{"error":{"message":"Invalid schema for function 'mcp_broken': 'additionalProperties' is required"}}. - Call the AI client with one tool and watch the second request.
- Call
isToolSupportError(new Error(<message>))with the messages below.
Expected Behavior
A broken tool schema or an invalid tool argument in the history is shown as an error. Native tools stay on for the model.
Actual Behavior
The client retries with tools=false and the model is stored in toolRejectingModels for the rest of the process.
Logs/Screenshots
true <- 400 Bad Request: Invalid schema for function 'mcp_broken': 'additionalProperties' is required
true <- Invalid function call arguments in message history
true <- Invalid tool_choice value
true <- This model does not support tools (correct)
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/ai-sdk-client/error-handling/tool-error-detector.ts:33-62: remove the broad/tool/,/function/and/invalid.*function/patterns and keep the specific "does not support tools" ones.source/ai-sdk-client/chat/chat-handler.ts:88,:161and:631: for ambiguous errors, retry once without tools but do not store the model, or expire the entry.- Add tests for the first three messages above.
hey @addyCooks would like to work on this one will follow the suggested fix