{"record":{"id":"471ba160c6a50a1b","repo":"vercel/ai","slug":"model-tried-to-call-unavailable-tool-toolname","errorCode":null,"errorMessage":"Model tried to call unavailable tool '${toolName}'. No tools are available.","messagePattern":"Model tried to call unavailable tool '(.+?)'\\. No tools are available\\.","errorType":"exception","errorClass":"NoSuchToolError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-text/parse-tool-call.ts","lineNumber":44,"sourceCode":"}: {\n  toolCall: LanguageModelV4ToolCall;\n  tools: TOOLS | undefined;\n  repairToolCall: ToolCallRepairFunction<TOOLS> | undefined;\n  refineToolInput?: ToolInputRefinement<TOOLS> | undefined;\n  instructions: Instructions | undefined;\n  messages: ModelMessage[];\n}): Promise<TypedToolCall<TOOLS>> {\n  try {\n    if (tools == null) {\n      // provider-executed dynamic tools are not part of our list of tools:\n      if (toolCall.providerExecuted && toolCall.dynamic) {\n        return await refineParsedToolCallInput({\n          toolCall: await parseProviderExecutedDynamicToolCall(toolCall),\n          refineToolInput,\n        });\n      }\n\n      throw new NoSuchToolError({ toolName: toolCall.toolName });\n    }\n\n    try {\n      return await refineParsedToolCallInput({\n        toolCall: await doParseToolCall({ toolCall, tools }),\n        refineToolInput,\n      });\n    } catch (error) {\n      if (\n        repairToolCall == null ||\n        !(\n          NoSuchToolError.isInstance(error) ||\n          InvalidToolInputError.isInstance(error)\n        )\n      ) {\n        throw error;\n      }\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-text/parse-tool-call.ts#L26-L62","documentation":"NoSuchToolError thrown when the model emitted a tool call for a tool name that is not in the `tools` map passed to generateText/generateObject, and no tools at all were provided. The SDK cannot resolve an input schema or execute the call, so parsing the tool call fails. It guards against hallucinated tool names.","triggerScenarios":"Calling generateText/streamText with no `tools` option while the model (trained or prompted to use tools) returns a tool_call; or the tools map is empty `{}` at the parse site.","commonSituations":"Forgetting to pass tools on one step/agent path while the system prompt still mentions them; using a different model endpoint that injects tool definitions; refactoring so tools are conditionally omitted; model hallucinating tools when tools: undefined.","solutions":["Pass the `tools` object to the generateText/streamText call that receives this response.","If the model should not call tools, remove tool-calling instructions from the system prompt or use a model/endpoint without tool definitions.","Use `experimental_repairToolCall` or catch NoSuchToolError (NoSuchToolError.isInstance) and skip/reprompt the model."],"exampleFix":"// before\nconst { text } = await generateText({ model, prompt });\n// after\nconst { text } = await generateText({ model, prompt, tools: { weather } });","handlingStrategy":"validation","validationCode":"if (!tools || Object.keys(tools).length === 0) {\n  throw new Error('generateText requires a non-empty tools map for this prompt');\n}","typeGuard":"function hasTools<T extends Record<string, unknown>>(t?: T): t is T {\n  return t != null && Object.keys(t).length > 0;\n}","tryCatchPattern":"try {\n  await generateText({ model, prompt, tools });\n} catch (e) {\n  if (NoSuchToolError.isInstance(e)) {\n    // re-prompt with the list of available tools\n  } else throw e;\n}","preventionTips":["Always pass the tools object wherever the system prompt mentions tools.","Centralize tool definitions so every agent step shares them.","Write a test that runs a tool-calling prompt against each call site."],"tags":["tool-calling","configuration","no-such-tool"],"backgroundTag":"unknown-tool-name","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}