{"record":{"id":"173d81b50e007ccf","repo":"earendil-works/pi","slug":"agent-run-completed-without-an-assistant-message","errorCode":null,"errorMessage":"Agent run completed without an assistant message.","messagePattern":"Agent run completed without an assistant message\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/evals/src/pi-harness.ts","lineNumber":98,"sourceCode":"\t\t\t\ttoolCallId: message.toolCallId,\n\t\t\t\tname: message.toolName,\n\t\t\t\tcontent: message.content.every((part) => part.type === \"text\") ? text : toJsonValue(message.content),\n\t\t\t\t...(message.isError ? { error: { message: text || \"Tool failed\" } } : {}),\n\t\t\t});\n\t\t}\n\t}\n\treturn events;\n}\n\nasync function promptAgent(session: AgentSession, input: string, signal: AbortSignal | undefined): Promise<string> {\n\tsignal?.throwIfAborted();\n\tconst previousMessageCount = session.messages.length;\n\tawait session.prompt(input);\n\tconst assistant = session.messages\n\t\t.slice(previousMessageCount)\n\t\t.reverse()\n\t\t.find((message) => message.role === \"assistant\");\n\tif (!assistant) throw new Error(\"Agent run completed without an assistant message.\");\n\tif (assistant.stopReason !== \"stop\") {\n\t\tthrow new Error(\n\t\t\tassistant.errorMessage ?? `Agent run ended with unexpected stop reason: ${assistant.stopReason}.`,\n\t\t);\n\t}\n\tconst output = session.getLastAssistantText();\n\tif (!output) throw new Error(\"Agent run produced no assistant text.\");\n\treturn output;\n}\n\nasync function runPiCodingAgent<TOutput extends JsonValue>(\n\tinput: PiCodingAgentInput,\n\tsignal: AbortSignal | undefined,\n\tsetArtifact: HarnessContext[\"setArtifact\"],\n\toptions: PiCodingAgentHarnessOptions | PiCodingAgentHarnessWithOutput<TOutput>,\n): Promise<SimpleHarnessResult<string | TOutput>> {\n\tconst startedAt = performance.now();\n\tsignal?.throwIfAborted();","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/evals/src/pi-harness.ts#L80-L116","documentation":"Error \"Agent run completed without an assistant message.\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/evals/src/pi-harness.ts:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}