earendil-works/pi · error · AggregateError

Agent cleanup failed.

Error message

Agent cleanup failed.

What it means

AggregateError thrown by runPiCodingAgent when the agent run succeeded but multiple cleanup steps (session dispose, temp-dir removal) failed; a single cleanup failure is rethrown directly, multiple ones are aggregated under this message.

Solutions

  1. Inspect the aggregated cleanup errors for root causes (locked files, permissions)
  2. Remove the eval temp directory manually
  3. Check for processes holding session or temp-dir handles
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/evals/src/pi-harness.ts:239 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/bcd30b6f7405c913. Report an issue: GitHub.

Appendix: source

Thrown at packages/evals/src/pi-harness.ts:239

		}
	}
	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",
		run: ({ input, signal, setArtifact }) => runPiCodingAgent(input, signal, setArtifact, options),
	});
}

View on GitHub (pinned to 4af9d21d3b)