earendil-works/pi · error · Error
Agent run ended with unexpected stop reason: ${assistant.sto
Error message
Agent run ended with unexpected stop reason: ${assistant.stopReason}. What it means
Error "Agent run ended with unexpected stop reason: ${assistant.stopReason}." thrown in earendil-works/pi.
Source
Thrown at packages/evals/src/pi-harness.ts:100
content: message.content.every((part) => part.type === "text") ? text : toJsonValue(message.content),
...(message.isError ? { error: { message: text || "Tool failed" } } : {}),
});
}
}
return events;
}
async function promptAgent(session: AgentSession, input: string, signal: AbortSignal | undefined): Promise<string> {
signal?.throwIfAborted();
const previousMessageCount = session.messages.length;
await session.prompt(input);
const assistant = session.messages
.slice(previousMessageCount)
.reverse()
.find((message) => message.role === "assistant");
if (!assistant) throw new Error("Agent run completed without an assistant message.");
if (assistant.stopReason !== "stop") {
throw new Error(
assistant.errorMessage ?? `Agent run ended with unexpected stop reason: ${assistant.stopReason}.`,
);
}
const output = session.getLastAssistantText();
if (!output) throw new Error("Agent run produced no assistant text.");
return output;
}
async function runPiCodingAgent<TOutput extends JsonValue>(
input: PiCodingAgentInput,
signal: AbortSignal | undefined,
setArtifact: HarnessContext["setArtifact"],
options: PiCodingAgentHarnessOptions | PiCodingAgentHarnessWithOutput<TOutput>,
): Promise<SimpleHarnessResult<string | TOutput>> {
const startedAt = performance.now();
signal?.throwIfAborted();
const selection = resolveModelSelection(options.model);
const modelRuntime = await ModelRuntime.create();View on GitHub (pinned to 4af9d21d3b)
When it happens
Trigger: Thrown at packages/evals/src/pi-harness.ts:100 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/d3c44518ed07ad93.
Report an issue: GitHub.