{"record":{"id":"bb076f83dfc2d7ce","repo":"earendil-works/pi","slug":"agent-run-failed-and-cleanup-also-failed","errorCode":null,"errorMessage":"Agent run failed and cleanup also failed.","messagePattern":"Agent run failed and cleanup also failed\\.","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/evals/src/pi-harness.ts","lineNumber":236,"sourceCode":"\t\t\t}\n\t\t} catch (error) {\n\t\t\tcleanupErrors.push(error);\n\t\t}\n\t}\n\ttry {\n\t\tsession?.dispose();\n\t} catch (error) {\n\t\tcleanupErrors.push(error);\n\t}\n\ttry {\n\t\tawait rm(root, { recursive: true, force: true });\n\t} catch (error) {\n\t\tcleanupErrors.push(error);\n\t}\n\n\tif (!outcome.success) {\n\t\tif (cleanupErrors.length === 0) throw outcome.error;\n\t\tthrow new AggregateError([outcome.error, ...cleanupErrors], \"Agent run failed and cleanup also failed.\");\n\t}\n\tif (cleanupErrors.length === 1) throw cleanupErrors[0];\n\tif (cleanupErrors.length > 1) throw new AggregateError(cleanupErrors, \"Agent cleanup failed.\");\n\treturn {\n\t\t...outcome.result,\n\t\ttimings: { totalMs: performance.now() - startedAt },\n\t};\n}\n\nexport function createPiCodingAgentHarness<TOutput extends JsonValue>(\n\toptions: PiCodingAgentHarnessWithOutput<TOutput>,\n): Harness<PiCodingAgentInput, TOutput>;\nexport function createPiCodingAgentHarness(options?: PiCodingAgentHarnessOptions): Harness<PiCodingAgentInput, string>;\nexport function createPiCodingAgentHarness<TOutput extends JsonValue>(\n\toptions: PiCodingAgentHarnessOptions | PiCodingAgentHarnessWithOutput<TOutput> = {},\n) {\n\treturn createHarness<PiCodingAgentInput, string | TOutput>({\n\t\tname: options.name ?? \"pi-coding-agent\",","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/evals/src/pi-harness.ts#L218-L254","documentation":"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.","triggerScenarios":"Thrown at packages/evals/src/pi-harness.ts:236 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}