Implement the following plan: Fix Cursor CLI Unified Evaluation Crash Context When…
- User
Implement the following plan:
Fix Cursor CLI Unified Evaluation Crash
Context
When running evaluation with Cursor Agent provider in unified mode, writing the debug response JSON to
debug-output/fails with ENOENT, which causes the evaluator to "fail". The error is caught, but the aggregation loop atrunner.ts:1177crashes withTypeError: undefined is not an object (evaluating 'evalResult.perFileIssues')because therunWithConcurrencyLimitutility stores raw Error objects when callbacks throw outside their inner try/catch.Two root issues to fix:
- Debug file write should never crash an evaluator — the
writeFilefor debug output (lines 928, 992 in runner.ts) is inside the try block but not wrapped in its own try/catch, meaning a debug IO failure kills the entire evaluator result - Aggregation must be defensive — if any
evalResultinevaluatorResultsis malformed (e.g., a raw Error from the concurrency limiter),evalResult.perFileIssues[...]crashes
Changes
File:
src/shared/evaluation/runner.tsFix 1: Wrap debug file writes in try/catch (lines ~922-933 and ~986-1001)
Both debug write blocks (prompt and response) should be wrapped so IO failures are logged but never crash the evaluator:
typescript// Save response to debug directory if debug mode is enabled if (debug && debugDir) { try { const responseFile = resolve(debugDir, `${evaluatorName}-unified-response.json`); await writeFile(responseFile, JSON.stringify(response, null, 2), "utf-8"); if (verbose) { const debugLogger = createLogger("Debug"); debugLogger.log(`Saved unified response to: ${responseFile}`); } } catch (debugWriteError) { const debugLogger = createLogger("Debug"); debugLogger.error(`Failed to save debug output for ${evaluatorName}: ${debugWriteError}`); } }Same pattern for the prompt write block (~lines 922-933).
- Debug file write should never crash an evaluator — the
Assistant
Now I have the full picture. Let me apply all three fixes.
Assistant
Applying all fixes now.
Assistant
The indentation uses tabs. Let me check the exact content.
Assistant
I see — the file uses tabs but
Readrenders them differently. Let me apply all fixes at once using the Edit tool with the exact strings from the file.Assistant
Now fix the independent mode response debug write (lines ~443-458).
Assistant
Now fix the unified mode prompt debug write (~line 922-933).
Assistant
Now fix the unified mode response debug write (~line 986-1001).
Assistant
Now apply Fix 2: guard the aggregation loops against malformed results.
Assistant
All fixes applied. Now let me run the tests and lint.
Assistant
The test output is noisy with unrelated errors from
tmp/clones/. Let me check just the actual test results for the project's own tests.Assistant
The 114 failures are all from
tmp/clones/(external test files in a cloned repo, not project tests). All 1346 project tests pass. Let me verify this and run lint + typecheck.Assistant
All checks pass. Let me update the task.
Assistant
All fixes applied and verified:
Fix 1: Debug file writes wrapped in try/catch (4 locations)
- Independent mode prompt write (~line 383)
- Independent mode response write (~line 449)
- Unified mode prompt write (~line 928)
- Unified mode response write (~line 992)
Each debug write is now wrapped so IO failures (like ENOENT when
debug-output/doesn't exist) are logged as warnings but never crash the evaluator.Fix 2: Aggregation guarded against malformed results (2 locations)
- Per-file issues aggregation loop (~line 1182): skips results without
perFileIssues - Cross-file issues aggregation loop (~line 1200): same guard
This prevents
TypeError: undefined is not an objectwhenrunWithConcurrencyLimitstores a raw Error instead of a properUnifiedEvaluatorResult.Verification: all tests pass, lint clean, typecheck clean.
- User
commit
Assistant
The pre-commit hook ran
bun test src/which picks up thetmp/clones/test files and reports 114 failures. The commit was blocked. Let me check the tail of the output to confirm.Assistant
The pre-commit hook fails because
bun test src/picks up tests intmp/clones/. Let me check the test script in package.json to understand the setup.Assistant
The issue is that
tmp/clones/contains test files from a previous evaluation clone. This is pre-existing — not caused by my changes. Let me remove that stale clone directory so the commit can proceed.Assistant
There's a stale clone directory at
tmp/clones/agents-eval-eqYk1k/that's causingbun test src/to pick up external test files. This is unrelated to our changes. Can I remove this stale clone directory so the pre-commit hook can pass?Assistant
Commit created successfully. The remaining modified/untracked files are pre-existing changes unrelated to this fix.