eyaltoledano/claude-task-master · warning

Warning: Could not determine default model for role '${role}

Error message

Warning: Could not determine default model for role '${role}'. Defaulting to 'Cancel'.

What it means

In models/prompts.ts buildPromptChoices, after computing which model choice should be preselected as the default for a role, a bounds check resets defaultIndex to 0 if it is out of range. Since 'Cancel' is typically the last/initial choice at index 0 in this path, it warns that the role's default model could not be determined and falls back to 'Cancel'.

Source

Thrown at apps/cli/src/commands/models/prompts.ts:142

		choices = [
			...systemOptions,
			new Separator('\n── Standard Models ──'),
			...roleChoices,
			new Separator('\n── Custom Providers ──'),
			...customProviderOptions
		];
		defaultIndex =
			currentChoiceIndex !== -1
				? currentChoiceIndex + systemLength + 1
				: noChangeOption
					? 1
					: 0;
	}

	// Ensure defaultIndex is valid
	if (defaultIndex < 0 || defaultIndex >= choices.length) {
		defaultIndex = 0;
		console.warn(
			`Warning: Could not determine default model for role '${role}'. Defaulting to 'Cancel'.`
		);
	}

	return { choices, default: defaultIndex };
}

/**
 * Create search source for inquirer search prompt
 */
export function createSearchSource(
	choices: (ModelChoice | Separator)[],
	_defaultValue: number
) {
	return (searchTerm = '') => {
		const filteredChoices = choices.filter((choice) => {
			// Separators are always included
			if (choice instanceof Separator) return true;

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Reset the role's model in config to a valid current model (task-master models --set-main/--set-research/--set-fallback).
  2. Update task-master and re-check available models (`task-master models` list) since the configured ID may be deprecated.
  3. Verify custom provider configuration so the configured model ID matches a model the provider actually offers.
  4. Accept the fallback: the prompt simply won't preselect a model; pick one interactively.

Example fix

// before (.taskmaster/config.json)
"main": "claude-3-opus-20240229"  // no longer offered
// after
"main": "claude-sonnet-4-5-20250929"
Defensive patterns

Strategy: validation

Validate before calling

const config = JSON.parse(fs.readFileSync('.taskmaster/config.json', 'utf8'));
const available = getAvailableModels(); // from `task-master models` output
for (const role of ['main', 'research', 'fallback']) {
  if (config.models?.[role] && !available.includes(config.models[role])) {
    console.warn(`Configured ${role} model '${config.models[role]}' is not available; reset it.`);
  }
}

Prevention

When it happens

Trigger: Calling buildPromptChoices (via mainPromptData/researchPromptData/fallbackPromptData) when the resolved default model for the role doesn't match any entry in the computed choices — e.g. configured model ID not in the available list, or defaultIndex computed as negative/out-of-bounds.

Common situations: Config references a model ID removed or renamed after an upgrade; a custom provider model set in config but the provider returns no matching model; empty model lists for a role; stale .taskmaster config pointing at deprecated model IDs.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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