can1357/oh-my-pi · error · Error
Model "${options.model}" not found
Error message
Model "${options.model}" not found What it means
createCleanseAgentRuntime() resolves the requested model via resolveCliModel against a refreshed ModelRegistry. If resolution fails or yields no model, it throws with the registry's error or a generic 'Model "X" not found'. The model string must match a model known to the registry after auth/refresh.
Source
Thrown at packages/coding-agent/src/cleanse/agent.ts:85
): Promise<CleanseAgentOutcome>;
/** Steer late diagnostics into a running worker's chat; false when undeliverable. */
followUp(worker: number, diagnostics: readonly CleanseDiagnostic[]): Promise<boolean>;
close(result?: CleanseLoopResult): Promise<void>;
}
/** Resolve the requested model and create a fresh persisted cleanse session. */
export async function createCleanseAgentRuntime(options: {
cwd?: string;
model: string;
hooks?: CleanseAgentHooks;
}): Promise<CleanseAgentRuntime> {
const cwd = options.cwd ?? getProjectDir();
const [settings, authStorage] = await Promise.all([Settings.init({ cwd }), discoverAuthStorage()]);
const modelRegistry = new ModelRegistry(authStorage);
await modelRegistry.refresh();
const resolved = resolveCliModel({ cliModel: options.model, modelRegistry, settings });
if (resolved.error || !resolved.model) {
throw new Error(resolved.error ?? `Model "${options.model}" not found`);
}
const modelSelector = resolved.selector ?? formatModelString(resolved.model);
const modelDisplay = formatModelString(resolved.model);
const sessionManager = SessionManager.create(cwd);
await sessionManager.setSessionName("Cleanse", "auto");
sessionManager.appendCustomEntry("cleanse", {
status: "running",
model: modelDisplay,
selector: options.model,
});
await sessionManager.ensureOnDisk();
const sessionFile = sessionManager.getSessionFile();
if (!sessionFile) throw new Error("Cleanse session could not be persisted");
const eventBus = new EventBus();
const toolSession: ToolSession = {
cwd,
hasUI: false,
suppressSpawnAdvisory: true,View on GitHub (pinned to 9690622007)
Solutions
- Run the model list command (or inspect modelRegistry) to see valid model identifiers and correct the string
- Use the full provider-qualified form (e.g. 'anthropic/claude-...') instead of a bare name
- Authenticate the provider so refresh() discovers its models (check auth storage / `omp` auth setup)
- Omit options.model if allowed, so the default model from settings is used
Example fix
// before
createCleanseAgentRuntime({ model: "claude-sonnet" });
// after
createCleanseAgentRuntime({ model: "anthropic/claude-sonnet-4-5" }); Defensive patterns
Strategy: validation
Validate before calling
const registry = new ModelRegistry(await discoverAuthStorage());
await registry.refresh();
const available = registry.getModels().some(m => formatModelString(m) === options.model || m.id === options.model);
if (!available) throw new Error(`model "${options.model}" unavailable; pick from registry`); Try / catch
try {
runtime = await createCleanseAgentRuntime({ model: userSelectedModel });
} catch (err) {
if (err instanceof Error && err.message.includes('not found') && err.message.includes('Model')) {
runtime = await createCleanseAgentRuntime({}); // fall back to default model
} else throw err;
} Prevention
- Always use provider-qualified model strings from the registry's own listing
- Refresh the registry after auth changes before resolving models
- Don't hardcode model names in scripts; read them from config validated against the registry
- Re-check after provider deprecations/renames
When it happens
Trigger: Calling the cleanse runtime (ensureRuntime) with options.model set to a model id/alias the ModelRegistry cannot resolve — unknown id, provider not authenticated, model removed upstream, or wrong format (missing provider prefix).
Common situations: Typo in --model flag or settings; using a model name from another tool's naming scheme; auth for the provider not configured so the model never appears in the registry; upstream renamed/deprecated a model.
Related errors
- resolved.error (model resolution failure)
- No models available. Use --model to select a model or config
- Model "${options.model}" not found
- Model "${parsed.planYoloInto ?? "@smol"}" not found
- No OAuth providers registered
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/123a7121f2ee2c72.
Report an issue: GitHub.