{"record":{"id":"6955bbe295fa60f5","repo":"JuliusBrussee/caveman","slug":"caveman-agent-no-supported-provider-credential-fo","errorCode":null,"errorMessage":"caveman agent: no supported provider credential found","messagePattern":"caveman agent: no supported provider credential found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/runtime.ts","lineNumber":3256,"sourceCode":"  const requested = typeof definition.model === \"string\"\n    ? definition.model\n    : process.env.CAVE_MODEL ?? localProviderModel(rootDir);\n  if (requested) {\n    const slash = requested.indexOf(\"/\");\n    if (slash <= 0 || slash === requested.length - 1) {\n      throw new Error(\"caveman agent: pinned model must use provider/model format\");\n    }\n    const model = models.getModel(requested.slice(0, slash), requested.slice(slash + 1));\n    if (!model) throw new Error(`caveman agent: unknown model ${JSON.stringify(requested)}`);\n    return model;\n  }\n\n  const configured: Array<[string, string]> = [];\n  if (process.env.ANTHROPIC_API_KEY) configured.push([\"anthropic\", \"claude-haiku-4-5\"]);\n  if (process.env.OPENAI_API_KEY) configured.push([\"openai\", \"gpt-5.4-mini\"]);\n  if (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY) configured.push([\"google\", \"gemini-2.5-flash\"]);\n  if (configured.length !== 1) {\n    throw new Error(\n      configured.length === 0\n        ? \"caveman agent: no supported provider credential found\"\n        : \"caveman agent: multiple provider credentials found; set CAVE_MODEL once\",\n    );\n  }\n  const [provider, id] = configured[0]!;\n  const model = models.getModel(provider, id);\n  if (!model) throw new Error(`caveman agent: baseline model unavailable: ${provider}/${id}`);\n  return model;\n}\n\nfunction localProviderModel(rootDir: string): string | undefined {\n  try {\n    const parsed = JSON.parse(readFileSync(resolve(rootDir, \".caveman/provider.json\"), \"utf8\")) as { model?: unknown };\n    return typeof parsed.model === \"string\" ? parsed.model : undefined;\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n    throw new Error(\"caveman agent: invalid .caveman/provider.json\");","sourceCodeStart":3238,"sourceCodeEnd":3274,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/runtime.ts#L3238-L3274","documentation":"When no model is pinned, the runtime builds a baseline list from provider credentials: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and `GEMINI_API_KEY`/`GOOGLE_API_KEY`. It throws this error when the list is empty — no supported provider credential is present in the environment — so no default model can be selected.","triggerScenarios":"Running an agent without `definition.model`/`CAVE_MODEL`/valid `.caveman/provider.json` while none of `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `GOOGLE_API_KEY` is exported in the environment the process sees.","commonSituations":"Forgetting to source `.env` before running; exporting keys in a different shell/user than the runner; CI secrets not injected; key names misspelled (`OPENAI_APIKEY`); credentials removed after a machine wipe.","solutions":["Export one supported key, e.g. `export ANTHROPIC_API_KEY=sk-ant-...`, in the shell/process that launches the agent.","Pin a model AND ensure its provider credential exists (`CAVE_MODEL=openai/gpt-5.4-mini` still needs `OPENAI_API_KEY` for the provider call).","Verify the key names exactly (`GEMINI_API_KEY` or `GOOGLE_API_KEY`, `OPENAI_API_KEY`).","In CI, add the secret to the job environment; locally check `printenv | grep API_KEY`."],"exampleFix":"// before\npnpm --dir public/agent test   # no API keys in env\n// after\nexport ANTHROPIC_API_KEY=sk-ant-...\npnpm --dir public/agent test","handlingStrategy":"validation","validationCode":"const keys = [\"ANTHROPIC_API_KEY\", \"OPENAI_API_KEY\", \"GEMINI_API_KEY\", \"GOOGLE_API_KEY\"];\nconst present = keys.filter((k) => !!process.env[k]);\nif (present.length === 0 && !process.env.CAVE_MODEL) {\n  throw new Error(`no provider credentials; set one of ${keys.join(\", \")}`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  await agent.run(task);\n} catch (e) {\n  if ((e as Error).message === \"caveman agent: no supported provider credential found\") {\n    console.error(\"Export ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY before running\");\n  } else throw e;\n}","preventionTips":["Source your .env file or inject CI secrets before launching agent runs in the same process.","Check `printenv | grep API_KEY` in the exact environment the runner uses.","Use exact key names: ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY or GOOGLE_API_KEY."],"tags":["credentials","environment","model-selection"],"backgroundTag":"missing-api-key","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}