eyaltoledano/claude-task-master · error

Failed to load prompts: systemPrompt=${!!systemPrompt}, user

Error message

Failed to load prompts: systemPrompt=${!!systemPrompt}, userPrompt=${!!userPrompt}

What it means

updateTaskById loads prompt templates to build the systemPrompt and userPrompt sent to the AI service. If either prompt is still falsy after the template loading/override logic completes, it throws with a boolean snapshot of which prompts are missing. This is a guard against sending a malformed request to the AI provider.

Source

Thrown at scripts/modules/task-manager/update-task-by-id.js:347

				`Prompt result type: ${typeof promptResult}, keys: ${promptResult ? Object.keys(promptResult).join(', ') : 'null'}`
			);

			// Extract prompts - loadPrompt returns { systemPrompt, userPrompt, metadata }
			systemPrompt = promptResult.systemPrompt;
			userPrompt = promptResult.userPrompt;

			report(
				'info',
				`Loaded prompts - systemPrompt length: ${systemPrompt?.length}, userPrompt length: ${userPrompt?.length}`
			);
		} catch (error) {
			report('error', `Failed to load prompt template: ${error.message}`);
			throw new Error(`Failed to load prompt template: ${error.message}`);
		}

		// If prompts are still not set, throw an error
		if (!systemPrompt || !userPrompt) {
			throw new Error(
				`Failed to load prompts: systemPrompt=${!!systemPrompt}, userPrompt=${!!userPrompt}`
			);
		}
		// --- End Build Prompts ---

		let loadingIndicator = null;
		let aiServiceResponse = null;

		if (!isMCP && outputFormat === 'text') {
			loadingIndicator = startLoadingIndicator(
				useResearch ? 'Updating task with research...\n' : 'Updating task...\n'
			);
		}

		try {
			const serviceRole = useResearch ? 'research' : 'main';

			if (appendMode) {

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Verify the built-in prompt template files exist and are readable in scripts/modules/ai-prompts (or configured template dir)
  2. Reinstall or repair the package to restore default prompt templates
  3. If overriding prompts via config/env, ensure both system and user prompt overrides are non-empty strings
  4. Check the preceding 'Failed to load prompt template' log/report output for the underlying cause

Example fix

// before
const { systemPrompt, userPrompt } = loadPrompts(customPath); // customPath empty file
// after
const { systemPrompt, userPrompt } = loadPrompts(); // use default templates, or fix custom file content
Defensive patterns

Strategy: try-catch

Validate before calling

const { systemPrompt, userPrompt } = buildPrompts();
if (!systemPrompt || !userPrompt) throw new Error('Prompt templates missing; reinstall or fix template config');

Type guard

const hasPrompts = (p) => typeof p?.systemPrompt === 'string' && p.systemPrompt.length > 0 && typeof p?.userPrompt === 'string' && p.userPrompt.length > 0;

Try / catch

try {
  await updateTaskById(...);
} catch (e) {
  if (String(e.message).startsWith('Failed to load prompts')) {
    // restore/repair prompt templates, then retry
  } else throw e;
}

Prevention

When it happens

Trigger: Calling updateTaskById with --prompt/--research flow where the prompt template file fails to resolve silently, or prompt overrides produce an empty string, so systemPrompt or userPrompt remains unset after the 'Build Prompts' section.

Common situations: Missing or corrupted prompt template files in the installation, a custom .taskmaster template path pointing to an empty file, or an env/config option (e.g. custom template directory) overriding the prompt with undefined.

Related errors


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