can1357/oh-my-pi · error

Unsupported ACP session: ${sessionId}

Error message

Unsupported ACP session: ${sessionId}

What it means

Thrown by #getSessionRecord when an ACP request references a sessionId that is not present in the agent's in-memory session map. The agent only knows sessions it created or loaded in this process; a record lookup is required by most session-scoped requests (prompt, cancel, model set, etc.).

Source

Thrown at packages/coding-agent/src/modes/acp/acp-agent.ts:1379

	async #handleLifetimeEvent(record: ManagedSessionRecord, event: AgentSessionEvent): Promise<void> {
		if (event.type !== "thinking_level_changed" && event.type !== "model_changed") {
			return;
		}
		try {
			await this.#pushConfigOptionUpdate(record);
		} catch (error) {
			logger.warn("Failed to push config_option_update after a lifetime event", {
				sessionId: record.session.sessionId,
				eventType: event.type,
				error,
			});
		}
	}

	#getSessionRecord(sessionId: string): ManagedSessionRecord {
		const record = this.#sessions.get(sessionId);
		if (!record) {
			throw new Error(`Unsupported ACP session: ${sessionId}`);
		}
		return record;
	}

	#assertMatchingCwd(session: AgentSession, cwd: string): void {
		const expected = path.resolve(cwd);
		const actual = path.resolve(session.sessionManager.getCwd());
		if (actual !== expected) {
			throw new Error(`ACP session ${session.sessionId} is already loaded for ${actual}, not ${expected}`);
		}
	}

	async #resolveForkSourceSessionPath(sessionId: string): Promise<string> {
		const loaded = this.#sessions.get(sessionId);
		if (loaded) {
			if (isPromptTurnInFlight(loaded.promptTurn)) {
				throw new Error(`ACP session fork is unavailable while a prompt is in progress: ${sessionId}`);
			}

View on GitHub (pinned to 9690622007)

Solutions

  1. List available sessions (session/list) and use a valid, current sessionId.
  2. Create or load the session first (session/new or session/load) before sending session-scoped requests.
  3. If the client restarted, re-initialize and re-load prior sessions rather than reusing cached ids.

Example fix

// before
await conn.prompt({ sessionId: rememberedId, prompt });
// after
const sessions = await conn.list();
const live = sessions.find(s => s.id === rememberedId);
if (!live) rememberedId = (await conn.new({ cwd })).sessionId;
await conn.prompt({ sessionId: rememberedId, prompt });
Defensive patterns

Strategy: validation

Validate before calling

// verify the session is known before any session-scoped call
const known = typeof listSessions === "function" ? (await listSessions()).some(s => s.id === sessionId) : undefined;
if (!known) throw new Error(`session ${sessionId} not established; call session/new or session/load first`);

Try / catch

try {
  await conn.prompt({ sessionId, prompt });
} catch (err) {
  if (err.message.startsWith("Unsupported ACP session:")) {
    const created = await conn.new({ cwd });
    sessionId = created.sessionId;
  } else throw err;
}

Prevention

When it happens

Trigger: Any session-scoped ACP call (prompt, cancel, set_session_model, set_session_mode, fork, etc.) with an id that was never established in this ACP connection or that has since been disposed/unloaded.

Common situations: Client reconnects and reuses stale session ids from a previous agent process; the session was closed/unloaded server-side; a typo'd or foreign session id from another client; agent restarted between calls.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/bab97fd835b0128d. Report an issue: GitHub.