eyaltoledano/claude-task-master · error

${lastCleanErrorMessage}

Error message

${lastCleanErrorMessage}

What it means

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.

Source

Thrown at scripts/modules/ai-services-unified.js:778

					lowerCaseMessage.includes(
						'no endpoints found that support tool use'
					) ||
					lowerCaseMessage.includes('does not support tool_use') ||
					lowerCaseMessage.includes('tool use is not supported') ||
					lowerCaseMessage.includes('tools are not supported') ||
					lowerCaseMessage.includes('function calling is not supported') ||
					lowerCaseMessage.includes('tool use is not supported')
				) {
					const 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.`;
					log('error', `[Tool Support Error] ${specificErrorMsg}`);
					throw new Error(specificErrorMsg);
				}
			}
		}
	}

	log('error', `All roles in the sequence [${sequence.join(', ')}] failed.`);
	throw new Error(lastCleanErrorMessage);
}

/**
 * Unified service function for generating text.
 * Handles client retrieval, retries, and fallback sequence.
 *
 * @param {object} params - Parameters for the service call.
 * @param {string} params.role - The initial client role ('main', 'research', 'fallback').
 * @param {object} [params.session=null] - Optional MCP session object.
 * @param {string} [params.projectRoot=null] - Optional project root path for .env fallback.
 * @param {string} params.prompt - The prompt for the AI.
 * @param {string} [params.systemPrompt] - Optional system prompt.
 * @param {string} params.commandName - Name of the command invoking the service.
 * @param {string} [params.outputType='cli'] - 'cli' or 'mcp'.
 * @returns {Promise<object>} Result object containing generated text and usage data.
 */
async function generateTextService(params) {
	// Ensure default outputType if not provided

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Read the interpolated message — it is the real underlying error from the last role attempted — and fix that root cause.
  2. Verify API keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.) are set and valid for every configured role.
  3. Configure distinct fallback roles with a different provider so a single-provider outage doesn't kill the call.
  4. Check connectivity/proxy settings; rerun after confirming `task-master models` shows reachable providers.
Defensive patterns

Strategy: try-catch

Validate before calling

const requiredKeys = ['ANTHROPIC_API_KEY','OPENAI_API_KEY'];
for (const k of requiredKeys) if (!process.env[k]) console.warn(`${k} missing — all-roles failure likely`);

Try / catch

try {
  await generateTextService({ role: 'main', prompt });
} catch (e) {
  // e.message is the cleaned last-role error; log it with full context
  logger.error('AI service exhausted all roles', { cause: e.message });
  // retry later or surface to user with actionable guidance
  throw new OperationalError(`AI generation unavailable: ${e.message}`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/80588349138d77f6. Report an issue: GitHub.