earendil-works/pi · error · Error

Session cannot accept input during

Error message

Session cannot accept input during ${this.phase ?? "unknown"} phase

What it means

State guard in RemoteSession.submit: input was submitted while the session lifecycle phase is neither 'idle' nor 'turn' (e.g. 'busy' during an in-flight operation); the phase name, or 'unknown' when unset, is interpolated. Blank input is filtered before this check, so only timing causes it.

Solutions

  1. Wait for the current operation to finish and the phase to return to idle/turn before submitting
  2. Queue the input and submit it on a phase-change notification
  3. Avoid concurrent submits from multiple callers
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/client/remote-session.ts:181 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/afa53e087d07119f. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/client/remote-session.ts:181

			await session.create(createOptions);
			return session;
		} catch (error) {
			await session.dispose();
			throw error;
		}
	}

	async create(options: CreateRemoteSessionOptions): Promise<void> {
		await this.#replace("create", () => this.#client.createSession(options));
	}

	async submit(text: string): Promise<void> {
		const normalized = text.trim();
		if (!normalized) return;
		this.#assertAvailable();
		const handle = this.#requireHandle();
		if (this.phase !== "idle" && this.phase !== "turn") {
			throw new Error(`Session cannot accept input during ${this.phase ?? "unknown"} phase`);
		}
		await this.#runOperation("submit", () =>
			(this.phase === "idle" ? handle.prompt(normalized) : handle.steer(normalized)).then(() => undefined),
		);
	}

	async abort(): Promise<void> {
		const preemptingSubmit = this.#lifecycle.status === "busy" && this.#lifecycle.operation === "submit";
		if (preemptingSubmit) this.#assertNotDisposed();
		else this.#assertAvailable();
		const handle = this.#requireHandle();
		if (this.phase === "idle" && !preemptingSubmit) return;
		await this.#runOperation("abort", () => handle.abort().then(() => undefined), preemptingSubmit);
	}

	async setModel(model: ModelRef): Promise<void> {
		await this.#runIdleOperation("setModel", "change model", () =>
			this.#requireHandle()

View on GitHub (pinned to 4af9d21d3b)