{"record":{"id":"123a7121f2ee2c72","repo":"can1357/oh-my-pi","slug":"model-options-model-not-found","errorCode":null,"errorMessage":"Model \"${options.model}\" not found","messagePattern":"Model \"(.+?)\" not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cleanse/agent.ts","lineNumber":85,"sourceCode":"\t): Promise<CleanseAgentOutcome>;\n\t/** Steer late diagnostics into a running worker's chat; false when undeliverable. */\n\tfollowUp(worker: number, diagnostics: readonly CleanseDiagnostic[]): Promise<boolean>;\n\tclose(result?: CleanseLoopResult): Promise<void>;\n}\n\n/** Resolve the requested model and create a fresh persisted cleanse session. */\nexport async function createCleanseAgentRuntime(options: {\n\tcwd?: string;\n\tmodel: string;\n\thooks?: CleanseAgentHooks;\n}): Promise<CleanseAgentRuntime> {\n\tconst cwd = options.cwd ?? getProjectDir();\n\tconst [settings, authStorage] = await Promise.all([Settings.init({ cwd }), discoverAuthStorage()]);\n\tconst modelRegistry = new ModelRegistry(authStorage);\n\tawait modelRegistry.refresh();\n\tconst resolved = resolveCliModel({ cliModel: options.model, modelRegistry, settings });\n\tif (resolved.error || !resolved.model) {\n\t\tthrow new Error(resolved.error ?? `Model \"${options.model}\" not found`);\n\t}\n\tconst modelSelector = resolved.selector ?? formatModelString(resolved.model);\n\tconst modelDisplay = formatModelString(resolved.model);\n\tconst sessionManager = SessionManager.create(cwd);\n\tawait sessionManager.setSessionName(\"Cleanse\", \"auto\");\n\tsessionManager.appendCustomEntry(\"cleanse\", {\n\t\tstatus: \"running\",\n\t\tmodel: modelDisplay,\n\t\tselector: options.model,\n\t});\n\tawait sessionManager.ensureOnDisk();\n\tconst sessionFile = sessionManager.getSessionFile();\n\tif (!sessionFile) throw new Error(\"Cleanse session could not be persisted\");\n\tconst eventBus = new EventBus();\n\tconst toolSession: ToolSession = {\n\t\tcwd,\n\t\thasUI: false,\n\t\tsuppressSpawnAdvisory: true,","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cleanse/agent.ts#L67-L103","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\ncreateCleanseAgentRuntime({ model: \"claude-sonnet\" });\n// after\ncreateCleanseAgentRuntime({ model: \"anthropic/claude-sonnet-4-5\" });","handlingStrategy":"validation","validationCode":"const registry = new ModelRegistry(await discoverAuthStorage());\nawait registry.refresh();\nconst available = registry.getModels().some(m => formatModelString(m) === options.model || m.id === options.model);\nif (!available) throw new Error(`model \"${options.model}\" unavailable; pick from registry`);","typeGuard":null,"tryCatchPattern":"try {\n  runtime = await createCleanseAgentRuntime({ model: userSelectedModel });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('not found') && err.message.includes('Model')) {\n    runtime = await createCleanseAgentRuntime({}); // fall back to default model\n  } else throw err;\n}","preventionTips":["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"],"tags":["model-resolution","configuration","cli"],"backgroundTag":"model-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}