davila7/claude-code-templates · warning

Could not analyze subagents:

Error message

Could not analyze subagents:

What it means

YearInReview2025 subagent analysis caught an error and returns empty subagent usage ({subagents: [], total: 0, events: []}); the subagent section of the year-in-review shows nothing.

Source

Thrown at cli-tool/src/analytics/core/YearInReview2025.js:977

            type: type,
            count: dayData.count // How many times used that day
          });
        });
      });

      subagentEvents.sort((a, b) => a.timestamp - b.timestamp);

      return {
        subagents: Object.entries(groupedByType).map(([type, data]) => ({
          type,
          count: data.count
        })),
        total: subagents.length,
        events: subagentEvents,
        grouped: groupedByType // Include grouped data for display
      };
    } catch (error) {
      console.warn('Could not analyze subagents:', error.message);
      return { subagents: [], total: 0, events: [] };
    }
  }
}

module.exports = YearInReview2025;

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Ignore — other report sections still render
  2. Update the CLI/analytics package for current conversation formats
  3. Check conversation file readability under ~/.claude/projects
  4. Re-run — transient file races can cause one-off failures
Defensive patterns

Strategy: try-catch

Validate before calling

// Sample-validate one conversation before the subagent pass
const first = JSON.parse((await fs.readFile(f, 'utf8')).split('\n')[0]);
if (!first.type) skipOrFlag(f);

Type guard

function isToolUse(msg) {
  return !!msg && msg.type === 'assistant' && Array.isArray(msg.message?.content) &&
    msg.message.content.some(c => c.type === 'tool_use' && c.name === 'Task');
}

Try / catch

try { return analyzeSubagents(...); }
catch (error) { console.warn('Could not analyze subagents:', error.message); return { subagents: [], total: 0, events: [] }; }

Prevention

When it happens

Trigger: Scanning conversation logs for subagent (Task tool) usage throws — unexpected message structure, unreadable conversation files, or a missing groupedByType intermediate key.

Common situations: Conversation format drift between Claude Code versions; large logs with unusual tool_use payloads; permissions on conversation files.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/c43a3f011f39eff6. Report an issue: GitHub.