{"record":{"id":"e49a83d964dea3ba","repo":"Mintplex-Labs/anything-llm","slug":"foundry-base-path-must-be-provided-to-use-agents","errorCode":null,"errorMessage":"Foundry base path must be provided to use agents.","messagePattern":"Foundry base path must be provided to use agents\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/index.js","lineNumber":253,"sourceCode":"      case \"ppio\":\n        if (!process.env.PPIO_API_KEY)\n          throw new Error(\"PPIO API Key must be provided to use agents.\");\n        break;\n      case \"gemini\":\n        if (!process.env.GEMINI_API_KEY)\n          throw new Error(\"Gemini API key must be provided to use agents.\");\n        break;\n      case \"moonshotai\":\n        if (!process.env.MOONSHOT_AI_MODEL_PREF)\n          throw new Error(\"Moonshot AI model must be set to use agents.\");\n        break;\n      case \"cometapi\":\n        if (!process.env.COMETAPI_LLM_API_KEY)\n          throw new Error(\"CometAPI API Key must be provided to use agents.\");\n        break;\n      case \"foundry\":\n        if (!process.env.FOUNDRY_BASE_PATH)\n          throw new Error(\"Foundry base path must be provided to use agents.\");\n        break;\n      case \"giteeai\":\n        if (!process.env.GITEE_AI_API_KEY)\n          throw new Error(\"GiteeAI API Key must be provided to use agents.\");\n        break;\n      case \"cohere\":\n        if (!process.env.COHERE_API_KEY)\n          throw new Error(\"Cohere API key must be provided to use agents.\");\n        break;\n      case \"docker-model-runner\":\n        if (!process.env.DOCKER_MODEL_RUNNER_BASE_PATH)\n          throw new Error(\n            \"Docker Model Runner base path must be provided to use agents.\"\n          );\n        break;\n      case \"privatemode\":\n        if (!process.env.PRIVATEMODE_LLM_BASE_PATH)\n          throw new Error(","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/index.js#L235-L271","documentation":"Thrown by AgentHandlerContext.checkSetup() (server/utils/agents/index.js:128) when the resolved agent provider is 'foundry' but process.env.FOUNDRY_BASE_PATH is unset/empty. checkSetup() is a precondition gate executed during agent.init() -> #providerSetupAndCheck() before any AI provider client is constructed, so every agent turn (workspace agent, @agent mentions, skills) fails fast until the env var exists.","triggerScenarios":"A chat turn calls agent.init(); this.provider resolves to 'foundry' (from workspace.agentProvider or system LLM_PROVIDER fallback); the switch reaches case 'foundry' and process.env.FOUNDRY_BASE_PATH is falsy.","commonSituations":"Foundry selected in Workspace Settings -> Agent Provider but the base path was never saved; .env edited but the server/container not restarted; Docker/k8s run dropped -e FOUNDRY_BASE_PATH; config copied from a deployment that used a different provider.","solutions":["Set FOUNDRY_BASE_PATH to your Foundry endpoint in .env (e.g. FOUNDRY_BASE_PATH=http://foundry-host:5273/v1) and fully restart the server.","If already set, confirm the running process loaded it (log process.env.FOUNDRY_BASE_PATH at boot) - containers often need a recreate, not a restart.","If Foundry is not intended, switch the workspace Agent Provider in the UI or unset LLM_PROVIDER so it no longer falls back to foundry."],"exampleFix":"// before (.env)\nFOUNDRY_BASE_PATH=\nLLM_PROVIDER=foundry\n// after (.env)\nFOUNDRY_BASE_PATH=http://foundry-host:5273/v1\nLLM_PROVIDER=foundry","handlingStrategy":"validation","validationCode":"function assertFoundryReady(workspaceAgentProvider) {\n  const usingFoundry = workspaceAgentProvider === 'foundry' || process.env.LLM_PROVIDER === 'foundry';\n  if (usingFoundry && !process.env.FOUNDRY_BASE_PATH)\n    throw new Error('FOUNDRY_BASE_PATH missing - set it before starting an agent.');\n}","typeGuard":null,"tryCatchPattern":"try { await agent.init(); } catch (e) { if (/Foundry base path must be provided/.test(e.message)) return showProviderConfig('foundry'); throw e; }","preventionTips":["Validate required provider env vars at server boot and fail loudly if a configured provider lacks its credential.","Restart the server after every .env change.","Maintain a startup self-check mapping each provider id to its required env var."],"tags":["config","env","agent-provider","foundry","agents"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}