{"record":{"id":"fd27b3affaf734e4","repo":"moeru-ai/airi","slug":"llm-auto-disabling-tools-for-key-due-to-too","errorCode":null,"errorMessage":"[llm] Auto-disabling tools for \"${key}\" due to tool-related error","messagePattern":"\\[llm\\] Auto-disabling tools for \"(.+?)\" due to tool-related error","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui/src/stores/ai/chat-llm/llm.ts","lineNumber":41,"sourceCode":"\n    const runStream = () => coreStreamFrom({\n      model,\n      chatProvider,\n      messages,\n      options: {\n        ...streamOptions,\n        toolsCompatibility: toolsCompatibility.value,\n        contentArrayCompatibility: contentArrayCompatibility.value,\n      },\n      builtinToolsResolver,\n    })\n\n    try {\n      await runStream()\n    }\n    catch (err) {\n      if (isToolRelatedError(err)) {\n        console.warn(`[llm] Auto-disabling tools for \"${key}\" due to tool-related error`)\n        toolsCompatibility.value.set(key, false)\n      }\n      // NOTICE:\n      // Auto-degrade content-part arrays to plain strings on the next attempt\n      // when the provider returned the Rust/serde-style \"expected a string\"\n      // 400. We retry once inline so the user's failing turn recovers without\n      // requiring them to resend; subsequent calls reuse the cached degrade.\n      // See: https://github.com/moeru-ai/airi/issues/1500\n      if (isContentArrayRelatedError(err) && contentArrayCompatibility.value.get(key) !== false) {\n        console.warn(`[llm] Auto-disabling content-part arrays for \"${key}\" and retrying once`)\n        contentArrayCompatibility.value.set(key, false)\n        await runStream()\n        return\n      }\n      throw err\n    }\n  }\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui/src/stores/ai/chat-llm/llm.ts#L23-L59","documentation":"The chat LLM streaming wrapper caught an error from the provider stream that core-agent's isToolRelatedError() matched (a provider 4xx complaining about the tools/tool_choice parameters, e.g. 'tools is not supported' or an unknown tool-schema error). It then permanently records toolsCompatibility[key] = false for that provider so subsequent requests omit tools, and the failure is not rethrown for this class.","triggerScenarios":"Streaming a chat turn with builtin tools against a provider/endpoint that does not implement the tools API — the provider returns a 400/422 naming 'tools', 'tool_choice', or function-calling; the wrapper downgrades and future calls for that key send no tools.","commonSituations":"OpenAI-compatible servers (llama.cpp, vLLM, LM Studio, Ollama builds) with partial or absent function-calling support; a proxy stripping tool fields then erroring; older model versions without tool support; wrong baseURL pointing at a chat-completions-only shim.","solutions":["Verify the provider/model actually supports function/tool calling; pick a tools-capable model if you need tools.","Update the local OpenAI-compatible server to a build that implements the tools parameter.","Clear the persisted/remembered toolsCompatibility entry after fixing the server so tools are retried.","If tools are optional, accept the degraded mode — chat continues without tool use for that provider."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await runStream()\n}\ncatch (err) {\n  if (isToolRelatedError(err)) {\n    toolsCompatibility.value.set(key, false)\n    // next turn omits tools; current turn must be re-sent or handled by caller\n  }\n}","preventionTips":["Advertise tool support per provider in the registry so tools are never sent to incapable endpoints.","Keep the toolsCompatibility map persisted per provider key to avoid repeat failures after reload.","Test new OpenAI-compatible backends with a minimal tool call before enabling builtin tools."],"tags":["llm","tool-calling","provider-compatibility","auto-degrade"],"backgroundTag":"tool-calling-unsupported","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}