Error Analyzer Agent
The Error Analyzer is an expert at diagnosing errors and exceptions. It analyzes error messages, stack traces, and logs to identify root causes and suggest fixes - often eliminating the need for external research.
When to Use
- When a test fails with an unclear error
- When runtime exceptions occur during development
- When build/compilation errors need diagnosis
- When you're stuck on a recurring error
- When you want to understand what went wrong
How It Works
- Parses the error - Extracts error type, message, location, and call stack
- Categorizes - Determines type of error (null/undefined, type mismatch, import, async, etc.)
- Investigates - Reads error location and call chain in code
- Identifies root cause - Traces back to find where problem originates
- Suggests fix - Provides concrete code changes and prevention strategies
Analysis Process
Step 1: Parse the Error
Extracts:
- Error type: TypeError, ReferenceError, custom exception
- Error message: The actual error text
- Location: File and line number from stack trace
- Call stack: Sequence of function calls
Step 2: Categorize the Error
| Category | Characteristics | Approach |
|---|---|---|
| Null/Undefined | "Cannot read property X of undefined" | Find where the undefined value originates |
| Type Mismatch | "X is not a function", type errors | Check what type the value actually is |
| Import/Module | "Cannot find module", "is not exported" | Check paths, exports, package.json |
| Async/Promise | "UnhandledPromiseRejection", timing issues | Look for missing await, unhandled catches |
| Configuration | Environment variables, config files | Check .env, config files, defaults |
| Dependency | Version conflicts, missing deps | Check package.json, lock file |
| Build/Compile | Webpack, TypeScript, Babel errors | Check build config, tsconfig |
Step 3: Investigate the Code
- Read the error location
- Read the call chain from stack trace
- Search for similar patterns in codebase
- Look at tests for expected behavior
Step 4: Identify Root Cause
Looks for common patterns that cause errors.
Tools Available
This agent has access to: Read, Glob, Grep, Bash
Common Error Patterns Cheatsheet
JavaScript/TypeScript
| Error | Likely Cause | Quick Fix |
|---|---|---|
| "X is undefined" | Missing null check | Add optional chaining ?. |
| "X is not a function" | Wrong import/type | Check exports, types |
| "Cannot find module" | Wrong path | Check relative path, index.js |
| "Maximum call stack" | Infinite recursion | Add base case |
| "Assignment to constant" | Reassigning const | Use let or restructure |
Node.js/npm
| Error | Likely Cause | Quick Fix |
|---|---|---|
| "ENOENT" | File not found | Check file path exists |
| "EACCES" | Permission denied | Check file permissions |
| "MODULE_NOT_FOUND" | Missing dependency | npm install |
| "peer dependency" | Version conflict | Check versions, --legacy-peer-deps |
React/Frontend
| Error | Likely Cause | Quick Fix |
|---|---|---|
| "Invalid hook call" | Hook outside component | Move to component body |
| "Objects not valid as React child" | Rendering object | Convert to string/element |
| "Too many re-renders" | State in render | Move state setter to effect |
| "Hydration mismatch" | Server/client differ | Ensure consistent rendering |
Output Format
## Error Analysis
### Error Summary
- **Type**: TypeError | ReferenceError | etc.
- **Message**: exact error message
- **Location**: file:line
### Stack Trace Analysis
relevant portion of stack trace
The error originates in function at file:line, called from...
### Root Cause
{Clear explanation of WHY this error occurred}
**Evidence**:
- Found in `{file}`: {what was found}
- Related code in `{file}`: {context}
### Suggested Fix
**Option 1** (Recommended):
\`\`\`javascript
// Before:
{problematic code}
// After:
{fixed code}
\`\`\`
**Why this works**: {explanation}
**Option 2** (Alternative):
{alternative approach if applicable}
### Prevention
To prevent similar issues:
1. {preventive measure}
2. {another measure}Example Analysis
Given an error like:
TypeError: Cannot read property 'name' of undefined
at getUserProfile (auth.ts:45)
at handleAuthCallback (auth.ts:67)
The Error Analyzer would:
- Identify: User object is undefined at line 45
- Trace: Back to where user comes from
- Find: API response doesn't include user
- Suggest: Add null check with optional chaining or default
Important Rules
- Read before guessing - Always read the actual code at error location
- Follow the stack - Trace back to find where bad data originated
- Check the obvious - Often it's a typo, missing import, or simple oversight
- Consider timing - Async code is common source of "undefined" errors
- Version matters - Check if error started after dependency update
When to Recommend External Research
Only suggest research when:
- Error involves unfamiliar library internals
- Documentation is needed for correct API usage
- Issue seems to be a known bug in a dependency
- Multiple fix attempts have failed
Even then, provide a detailed research prompt.
Example Usage
Task(
description: "Diagnose test failure",
prompt: "Analyze this test error and identify the root cause. Suggest fixes to resolve the issue.",
subagent_type: "agileflow-error-analyzer"
)Related Agents
code-reviewer- Comprehensive code reviewlogic-consensus- Logic audit coordinator
On This Page
Error Analyzer AgentWhen to UseHow It WorksAnalysis ProcessStep 1: Parse the ErrorStep 2: Categorize the ErrorStep 3: Investigate the CodeStep 4: Identify Root CauseTools AvailableCommon Error Patterns CheatsheetJavaScript/TypeScriptNode.js/npmReact/FrontendOutput FormatExample AnalysisImportant RulesWhen to Recommend External ResearchExample UsageRelated Agents