{"record":{"id":"5264dc07e4ad3043","repo":"Mintplex-Labs/anything-llm","slug":"no-valid-provider-found-for-the-agent-5264dc","errorCode":null,"errorMessage":"No valid provider found for the agent.","messagePattern":"No valid provider found for the agent\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/index.js","lineNumber":459,"sourceCode":"      };\n    }\n\n    return null;\n  }\n\n  /**\n   * Finds or assumes the model preference value to use for API calls.\n   * If multi-model loading is supported, we use their agent model selection of the workspace\n   * If not supported, we attempt to fallback to the system provider value for the LLM preference\n   * and if that fails - we assume a reasonable base model to exist.\n   * @returns {string|null} the model preference value to use in API calls\n   */\n  #fetchModel() {\n    // Provider was not explicitly set for workspace, so we are going to run our fallback logic\n    // that will set a provider and model for us to use.\n    if (!this.provider) {\n      const fallback = this.#getFallbackProvider();\n      if (!fallback) throw new Error(\"No valid provider found for the agent.\");\n      this.provider = fallback.provider; // re-set the provider to the fallback provider so it is not null.\n      return fallback.model; // set its defined model based on fallback logic.\n    }\n\n    // The provider was explicitly set, so check if the workspace has an agent model set.\n    if (this.invocation.workspace.agentModel)\n      return this.invocation.workspace.agentModel;\n\n    // Otherwise, we have no model to use - so guess a default model to use via the provider\n    // and it's system ENV params and if that fails - we return either a base model or null.\n    return this.providerDefault();\n  }\n\n  async #providerSetupAndCheck() {\n    this.provider = this.invocation.workspace.agentProvider ?? null; // set provider to workspace agent provider if it exists\n    this.model = this.#fetchModel();\n\n    // If provider resolved to model router, resolve the actual provider/model","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/utils/agents/index.js#L441-L477","documentation":"Thrown by #fetchModel() when the multi-provider fallback chain fails: the workspace has no explicit provider, the system-level provider lookup fails, and no reasonable default model can be assumed — leaving no valid LLM provider to route the agent invocation to. It signals a routing/configuration dead end, not an API error.","triggerScenarios":"The configured agent provider could not be resolved to a valid provider.","commonSituations":"This error is raised at runtime in server/utils/agents/index.js. It occurs when the required configuration for this provider is missing or invalid (unset environment variables, empty API key or base path), when the external service is unreachable or returns an unexpected response, or when invalid input reaches the call site. To prevent it, validate the relevant provider settings and environment variables at startup and confirm the service is reachable before this code path executes.","solutions":["Set a valid agent provider in the workspace settings.","Verify the provider credentials are configured."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"20f6d3546c1938bfea1ad304f58a592dddcc5948","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}