{"record":{"id":"80588349138d77f6","repo":"eyaltoledano/claude-task-master","slug":"lastcleanerrormessage","errorCode":null,"errorMessage":"${lastCleanErrorMessage}","messagePattern":"\\$\\{lastCleanErrorMessage\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/ai-services-unified.js","lineNumber":778,"sourceCode":"\t\t\t\t\tlowerCaseMessage.includes(\n\t\t\t\t\t\t'no endpoints found that support tool use'\n\t\t\t\t\t) ||\n\t\t\t\t\tlowerCaseMessage.includes('does not support tool_use') ||\n\t\t\t\t\tlowerCaseMessage.includes('tool use is not supported') ||\n\t\t\t\t\tlowerCaseMessage.includes('tools are not supported') ||\n\t\t\t\t\tlowerCaseMessage.includes('function calling is not supported') ||\n\t\t\t\t\tlowerCaseMessage.includes('tool use is not supported')\n\t\t\t\t) {\n\t\t\t\t\tconst specificErrorMsg = `Model '${modelId || 'unknown'}' via provider '${providerName || 'unknown'}' does not support the 'tool use' required by generateObjectService. Please configure a model that supports tool/function calling for the '${currentRole}' role, or use generateTextService if structured output is not strictly required.`;\n\t\t\t\t\tlog('error', `[Tool Support Error] ${specificErrorMsg}`);\n\t\t\t\t\tthrow new Error(specificErrorMsg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlog('error', `All roles in the sequence [${sequence.join(', ')}] failed.`);\n\tthrow new Error(lastCleanErrorMessage);\n}\n\n/**\n * Unified service function for generating text.\n * Handles client retrieval, retries, and fallback sequence.\n *\n * @param {object} params - Parameters for the service call.\n * @param {string} params.role - The initial client role ('main', 'research', 'fallback').\n * @param {object} [params.session=null] - Optional MCP session object.\n * @param {string} [params.projectRoot=null] - Optional project root path for .env fallback.\n * @param {string} params.prompt - The prompt for the AI.\n * @param {string} [params.systemPrompt] - Optional system prompt.\n * @param {string} params.commandName - Name of the command invoking the service.\n * @param {string} [params.outputType='cli'] - 'cli' or 'mcp'.\n * @returns {Promise<object>} Result object containing generated text and usage data.\n */\nasync function generateTextService(params) {\n\t// Ensure default outputType if not provided","sourceCodeStart":760,"sourceCodeEnd":796,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/ai-services-unified.js#L760-L796","documentation":"The terminal error thrown by _unifiedServiceRunner after every role in the fallback sequence (main, research, fallback) failed. It rethrows the last cleaned-up error message (provider-specific noise stripped) so the caller sees the root cause of the final attempt rather than a generic 'all roles failed' message.","triggerScenarios":"Any generateTextService/streamTextService/generateObjectService call where all configured roles fail — e.g. invalid API keys on every provider, network outages, exhausted retries, or rate limits across main, research, and fallback models.","commonSituations":"Missing/expired API keys for all configured providers, no fallback role configured so one provider failure ends the sequence, network/firewall blocking api endpoints, or a hard provider outage during long batch operations like task expansion.","solutions":["Read the interpolated message — it is the real underlying error from the last role attempted — and fix that root cause.","Verify API keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.) are set and valid for every configured role.","Configure distinct fallback roles with a different provider so a single-provider outage doesn't kill the call.","Check connectivity/proxy settings; rerun after confirming `task-master models` shows reachable providers."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const requiredKeys = ['ANTHROPIC_API_KEY','OPENAI_API_KEY'];\nfor (const k of requiredKeys) if (!process.env[k]) console.warn(`${k} missing — all-roles failure likely`);","typeGuard":null,"tryCatchPattern":"try {\n  await generateTextService({ role: 'main', prompt });\n} catch (e) {\n  // e.message is the cleaned last-role error; log it with full context\n  logger.error('AI service exhausted all roles', { cause: e.message });\n  // retry later or surface to user with actionable guidance\n  throw new OperationalError(`AI generation unavailable: ${e.message}`);\n}","preventionTips":["Keep API keys valid and present for at least two providers/roles.","Configure a fallback role on a different provider than main.","Monitor provider status pages for outages during batch runs.","Log the underlying message; it identifies which role/provider ultimately failed."],"tags":["ai-provider","fallback-exhausted","api-key","network"],"backgroundTag":"all-retries-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}