can1357/oh-my-pi · error

Unknown ACP model: ${modelId}

Error message

Unknown ACP model: ${modelId}

What it means

Thrown by #setModelById (set_session_model) when the requested modelId does not match any model in the session's available-models list (compared via the agent's #toModelId normalization). Only models offered by the current session/provider configuration can be selected.

Source

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

			})),
		];
	}
	#getConfiguredThinkingLevel(session: AgentSession): string | undefined {
		const configuredThinkingLevel = (session as { configuredThinkingLevel?: () => string | undefined })
			.configuredThinkingLevel;
		return typeof configuredThinkingLevel === "function"
			? configuredThinkingLevel.call(session)
			: session.thinkingLevel;
	}

	#toThinkingConfigValue(value: string | undefined): string {
		return value && value !== "inherit" ? value : THINKING_OFF;
	}

	async #setModelById(session: AgentSession, modelId: string): Promise<void> {
		const model = session.getAvailableModels().find(candidate => this.#toModelId(candidate) === modelId);
		if (!model) {
			throw new Error(`Unknown ACP model: ${modelId}`);
		}
		await session.setModel(model);
	}

	#setThinkingLevelById(session: AgentSession, value: string): void {
		const thinkingLevel = parseConfiguredThinkingLevel(value);
		if (!thinkingLevel) {
			throw new Error(`Unknown ACP thinking level: ${value}`);
		}
		session.setThinkingLevel(thinkingLevel);
	}

	#toModelId(model: Model): string {
		return `${model.provider}/${model.id}`;
	}

	#getAvailableModes(session: AgentSession): Array<{ id: string; name: string; description: string }> {
		const modes = [{ id: ACP_DEFAULT_MODE_ID, name: "Default", description: "Standard ACP headless mode" }];

View on GitHub (pinned to 9690622007)

Solutions

  1. List the session's available models and pick an exact id from that list (use the same #toModelId-style canonical form, provider/model).
  2. Call session/list_modes or the equivalent models listing to refresh cached ids after upgrades.
  3. If the model should exist, fix provider configuration/API keys so it appears in available models.

Example fix

// before
await agent.setModel(sessionId, { modelId: "claude-sonnet-4" });
// after
const models = await getAvailableModels(sessionId);
const id = models.find(m => m.id.includes("sonnet"))?.modelId;
if (!id) throw new Error("sonnet model unavailable");
await agent.setModel(sessionId, { modelId: id });
Defensive patterns

Strategy: validation

Validate before calling

const available = await getAvailableModels(sessionId);
if (!available.some(m => m.modelId === modelId)) {
  throw new Error(`model ${modelId} not offered by this session; pick from: ${available.map(m => m.modelId).join(", ")}`);
}

Try / catch

try {
  await agent.setModel(sessionId, { modelId });
} catch (err) {
  if (err.message.startsWith("Unknown ACP model:")) {
    const fallback = (await getAvailableModels(sessionId))[0];
    await agent.setModel(sessionId, { modelId: fallback.modelId });
  } else throw err;
}

Prevention

When it happens

Trigger: A set_session_model request whose modelId is not among session.getAvailableModels() — e.g. wrong provider prefix, deprecated/renamed model id, or a model unavailable under the configured API keys.

Common situations: Client caches model ids from another session/provider; catalog updates renamed or removed a model; typo in provider/model slug (e.g. missing provider prefix); model excluded by the account's plan.

Related errors


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