eyaltoledano/claude-task-master · warning
Could not gather context: ${contextError.message}
Error message
Could not gather context: ${contextError.message} What it means
During task expansion, expandTask tries to gather research context (e.g. from Perplexity) to enrich the expansion prompt. If context gathering throws (API error, missing key, network failure), the error is caught and only logged as a warning — expansion continues without the extra context.
Source
Thrown at scripts/modules/task-manager/expand-task.js:144
const searchResults = fuzzySearch.findRelevantTasks(searchQuery, {
maxResults: 5,
includeSelf: true
});
const relevantTaskIds = fuzzySearch.getTaskIds(searchResults);
const finalTaskIds = [
...new Set([taskId.toString(), ...relevantTaskIds])
];
if (finalTaskIds.length > 0) {
const contextResult = await contextGatherer.gather({
tasks: finalTaskIds,
format: 'research'
});
gatheredContext = contextResult.context || '';
}
} catch (contextError) {
logger.warn(`Could not gather context: ${contextError.message}`);
}
// --- End Context Gathering ---
// --- Complexity Report Integration ---
let finalSubtaskCount;
let complexityReasoningContext = '';
let taskAnalysis = null;
logger.info(
`Looking for complexity report at: ${complexityReportPath}${tag !== 'master' ? ` (tag-specific for '${tag}')` : ''}`
);
try {
if (fs.existsSync(complexityReportPath)) {
const complexityReport = readJSON(complexityReportPath);
taskAnalysis = complexityReport?.complexityAnalysis?.find(
(a) => a.taskId === task.id
);View on GitHub (pinned to c0c98d367c)
Solutions
- Ignore if acceptable: expansion proceeds without research context; check earlier warnings for the root cause.
- Set/verify the research provider API key (e.g. PERPLEXITY_API_KEY) in .env or mcp.json.
- Re-run with a working network or switch the research provider via 'task-master models --set-research'.
- Inspect contextError.message in logs to address the underlying provider error.
Example fix
// before: expansion run with research but no key set // .env missing PERPLEXITY_API_KEY // after # .env PERPLEXITY_API_KEY=pplx-xxxxxxxx
Defensive patterns
Strategy: fallback
Validate before calling
const hasKey = !!(process.env.PERPLEXITY_API_KEY || mcpKeyFor('perplexity'));
if (!hasKey) console.warn('Research context will be skipped: no API key'); Try / catch
try {
await expandTask(taskId, { research: true });
} catch (e) {
// expandTask rarely throws for context issues; check warnings instead
console.error('Expansion failed:', e.message);
} Prevention
- Set PERPLEXITY_API_KEY in .env or .cursor/mcp.json before using --research.
- Treat context-gathering warnings as optional: expansion output is valid without it.
- Check network/proxy availability in CI when research mode is enabled.
When it happens
Trigger: expandTask called (directly or via the 'result' path) with research enabled / 'research' format, and the context-gathering call (contextGatherer) rejects — e.g. missing PERPLEXITY_API_KEY, network failure, or API error.
Common situations: No research API key configured; offline or rate-limited; the chosen research provider returns an error; contextGatherer misconfigured for the requested format.
Related errors
- API_ERROR
- API request failed: ${response.status} - ${errorText}
- ${result.message} || Update failed for task ${taskId}. The s
- Task ${taskId} not found
- NOT_IMPLEMENTED
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/48f53c5f020f7bce.
Report an issue: GitHub.