{"record":{"id":"014f5eb9e8f7d7b8","repo":"paperclipai/paperclip","slug":"configured-opencode-model-is-unavailable-model","errorCode":null,"errorMessage":"Configured OpenCode model is unavailable: ${model}. Available models: ${sample}","messagePattern":"Configured OpenCode model is unavailable: (.+?)\\. Available models: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapters/opencode-local/src/server/models.ts","lineNumber":214,"sourceCode":"  // the configured model. Prefer the explicit run env, then the process env.\n  const env = normalizeEnv(input.env);\n  if (isTruthyEnvFlag(env.OPENCODE_ALLOW_ALL_MODELS ?? process.env.OPENCODE_ALLOW_ALL_MODELS)) {\n    return [{ id: model, label: model }];\n  }\n\n  const models = await discoverOpenCodeModelsCached({\n    command: input.command,\n    cwd: input.cwd,\n    env: input.env,\n  });\n\n  if (models.length === 0) {\n    throw new Error(\"OpenCode returned no models. Run `opencode models` and verify provider auth.\");\n  }\n\n  if (!models.some((entry) => entry.id === model)) {\n    const sample = models.slice(0, 12).map((entry) => entry.id).join(\", \");\n    throw new Error(\n      `Configured OpenCode model is unavailable: ${model}. Available models: ${sample}${models.length > 12 ? \", ...\" : \"\"}`,\n    );\n  }\n\n  return models;\n}\n\nexport async function listOpenCodeModels(): Promise<AdapterModel[]> {\n  try {\n    return await discoverOpenCodeModelsCached();\n  } catch {\n    return [];\n  }\n}\n\nexport function resetOpenCodeModelsCacheForTests() {\n  discoveryCache.clear();\n}","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/adapters/opencode-local/src/server/models.ts#L196-L232","documentation":"Thrown by ensureOpenCodeModelConfiguredAndAvailable (LOCAL) when discovery returned models but adapterConfig.model is not among them. Up to 12 available ids are sampled in the message. This is the local sibling of the remote availability error (391).","triggerScenarios":"models.length > 0 AND !models.some(e => e.id === model) during local discovery; OPENCODE_ALLOW_ALL_MODELS not set.","commonSituations":"Configured model id typo; provider authenticated but the specific model is deprecated/renamed; model belongs to a provider that is not the one authenticated.","solutions":["Change adapterConfig.model to one of the ids in the Available models sample.","Authenticate the provider that serves the configured model.","Set OPENCODE_ALLOW_ALL_MODELS=true if the model is valid but hidden from enumeration."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function modelAvailable(model: string, models: { id: string }[]): boolean {\n  return models.some(m => m.id === model);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await ensureOpenCodeModelConfiguredAndAvailable(input);\n} catch (e) {\n  if (e instanceof Error && /Configured OpenCode model is unavailable/.test(e.message)) {\n    // extract Available models from the message, update adapterConfig.model, retry\n  }\n  throw e;\n}","preventionTips":["Populate model selectors from `opencode models` output so only valid ids are chosen.","Authenticate the provider that serves the configured model.","Set OPENCODE_ALLOW_ALL_MODELS for valid-but-unlisted models."],"tags":["opencode","models","configuration","model-selection"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}