earendil-works/pi · error · AggregateError
Agent run failed and cleanup also failed.
Error message
Agent run failed and cleanup also failed.
What it means
AggregateError thrown by runPiCodingAgent when the agent run itself failed and one or more cleanup steps (session dispose, temp-dir removal) also failed; the run error and all cleanup errors are aggregated so the primary failure is not hidden.
Solutions
- Inspect the aggregated errors: the first is the run failure, the rest are cleanup failures
- Fix the underlying run error (model/provider/abort) first
- Clean the leftover temp root directory manually if removal failed
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/evals/src/pi-harness.ts:236 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/bb076f83dfc2d7ce.
Report an issue: GitHub.
Appendix: source
Thrown at packages/evals/src/pi-harness.ts:236
}
} catch (error) {
cleanupErrors.push(error);
}
}
try {
session?.dispose();
} catch (error) {
cleanupErrors.push(error);
}
try {
await rm(root, { recursive: true, force: true });
} catch (error) {
cleanupErrors.push(error);
}
if (!outcome.success) {
if (cleanupErrors.length === 0) throw outcome.error;
throw new AggregateError([outcome.error, ...cleanupErrors], "Agent run failed and cleanup also failed.");
}
if (cleanupErrors.length === 1) throw cleanupErrors[0];
if (cleanupErrors.length > 1) throw new AggregateError(cleanupErrors, "Agent cleanup failed.");
return {
...outcome.result,
timings: { totalMs: performance.now() - startedAt },
};
}
export function createPiCodingAgentHarness<TOutput extends JsonValue>(
options: PiCodingAgentHarnessWithOutput<TOutput>,
): Harness<PiCodingAgentInput, TOutput>;
export function createPiCodingAgentHarness(options?: PiCodingAgentHarnessOptions): Harness<PiCodingAgentInput, string>;
export function createPiCodingAgentHarness<TOutput extends JsonValue>(
options: PiCodingAgentHarnessOptions | PiCodingAgentHarnessWithOutput<TOutput> = {},
) {
return createHarness<PiCodingAgentInput, string | TOutput>({
name: options.name ?? "pi-coding-agent",View on GitHub (pinned to 4af9d21d3b)