can1357/oh-my-pi · error
Model "${options.model}" not found
Error message
Model "${options.model}" not found What it means
`createCompressSession()` resolves the user-supplied model selector through `resolveCliModel` against a freshly built `ModelRegistry`; when resolution returns an error or no model, this Error is thrown naming the selector. The compress run cannot start without a concrete model because token metrics and generation both depend on it.
Source
Thrown at packages/coding-agent/src/compress/session.ts:39
}
/** Resolve the requested model and open a session restricted to the two protocol tools. */
export async function createCompressSession(options: {
cwd?: string;
model?: string;
protocol: CompressProtocol;
/** Distinct per concurrent session; agent ids must be unique within a process. */
agentId?: string;
}): Promise<CompressSession> {
const cwd = options.cwd ?? getProjectDir();
const [settings, authStorage] = await Promise.all([Settings.init({ cwd }), discoverAuthStorage()]);
const modelRegistry = new ModelRegistry(authStorage);
await modelRegistry.refresh();
// An absent selector means "whatever the session is configured to use", which
// resolveCliModel reports as a model-less, error-less result.
const resolved = options.model ? resolveCliModel({ cliModel: options.model, modelRegistry, settings }) : undefined;
if (resolved && (resolved.error || !resolved.model)) {
throw new Error(resolved.error ?? `Model "${options.model}" not found`);
}
const { session } = await createAgentSession({
cwd,
settings,
authStorage,
modelRegistry,
...(resolved?.model ? { model: resolved.model } : {}),
customTools: [options.protocol.rewriteTool(), options.protocol.approveTool()],
toolNames: ["rewrite", "approve"],
restrictToolNames: true,
allowRestrictedCustomTools: true,
// Replace the default blocks outright: a compressor needs its own contract, not
// the coding-agent workflow. Every discovery source below defaults to ON when
// omitted, and each one would inject instruction-shaped project text into a
// session whose only legitimate input is the source document.
systemPrompt: [systemPrompt.trim()],
skills: [],
rules: [],View on GitHub (pinned to 9690622007)
Solutions
- Run with a valid selector — check available ids (e.g. `omp models` / the model registry listing) and fix the spelling
- Omit `options.model` entirely so the session uses whatever model the settings configure by default
- Verify provider auth is configured so the intended model appears in the refreshed registry
Example fix
// before
await createCompressSession({ model: "claude-4-sonnet", ... }); // not found
// after
await createCompressSession({ model: "anthropic:claude-sonnet-4", ... }); // or omit model Defensive patterns
Strategy: try-catch
Validate before calling
const registry = new ModelRegistry(authStorage);
await registry.refresh();
const resolved = options.model ? resolveCliModel({ cliModel: options.model, modelRegistry: registry, settings }) : undefined;
if (resolved?.error || resolved?.model === undefined) {
// surface resolved?.error and stop before creating the session
} Type guard
function isResolvableModel(r: { error?: string; model?: unknown }): r is { error?: undefined; model: NonNullable<typeof r.model> } {
return !r.error && r.model != null;
} Try / catch
try {
await createCompressSession(options);
} catch (err) {
if (err instanceof Error && /^Model ".*" not found$/.test(err.message)) {
// fall back to settings default (omit options.model) or prompt the user for a valid id
} else throw err;
} Prevention
- Validate the `--model` selector against the registry listing before launching
- Prefer omitting `options.model` to inherit the configured default
- Keep provider auth configured so intended models survive registry refresh
- Update pinned model ids after upstream renames/deprecations
When it happens
Trigger: Passing `options.model` as a selector string that matches no model in the registry — e.g. a misspelled id (`"claude-4-sonnet"`), a deprecated/removed model id, or a provider whose auth/catalog entries are absent after `modelRegistry.refresh()`.
Common situations: Typo in a CLI `--model` flag or config file; model renamed upstream so an old pinned id no longer resolves; missing provider API keys so the model is filtered out of the registry; offline catalog refresh.
Related errors
- Model "${options.model}" not found
- resolved.error (model resolution failure)
- No models available. Use --model to select a model or config
- 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/59a58975d46b47a4.
Report an issue: GitHub.