earendil-works/pi · error · PiServerError
busy
busy
Error message
A prompt is already running
What it means
The test session runtime's prompt() was called while its phase is not 'idle', meaning another prompt is already in flight (pendingPrompt set). Raised as PiServerError code 'busy'; test sessions serialize prompts, so callers must wait for completion or abort before issuing a new prompt.
Solutions
- Wait for the running prompt to finish or abort it before starting another.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at packages/server/src/testing/service.ts:75 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/4508fcbd2cd102ec.
Report an issue: GitHub.
Appendix: source
Thrown at packages/server/src/testing/service.ts:75
private readonly onDispose: () => void;
private readonly listeners = new Set<(event: PiSessionRuntimeEvent) => void>();
private pendingPrompt?: { input: PromptInput; done: Deferred<"complete" | "aborted"> };
constructor(stored: StoredSession, onDispose: () => void) {
this.stored = stored;
this.onDispose = onDispose;
}
snapshot(): SessionSnapshot {
return structuredClone(this.stored.snapshot);
}
getPhase(): SessionPhase {
return this.stored.snapshot.phase;
}
async prompt(input: PromptInput): Promise<void> {
if (this.getPhase() !== "idle") throw new PiServerError("busy", "A prompt is already running");
const done = new Deferred<"complete" | "aborted">();
this.pendingPrompt = { input, done };
this.update({
phase: "turn",
transcript: [
...this.stored.snapshot.transcript,
{
id: `user-${this.stored.snapshot.revision + 1}`,
role: "user",
content: [{ type: "text", text: input.text }],
timestamp: this.stored.snapshot.revision + 1,
},
],
});
const outcome = await done.promise;
const assistant =
outcome === "complete"
? {View on GitHub (pinned to 4af9d21d3b)