Mintplex-Labs/anything-llm · error · Error

No valid provider found for the agent.

Error message

No valid provider found for the agent.

What it means

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.

Solutions

  1. Set a valid agent provider in the workspace settings.
  2. Verify the provider credentials are configured.
Defensive patterns

Strategy: fallback

When it happens

Trigger: The configured agent provider could not be resolved to a valid provider.

Common situations: 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.


AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18). Data as JSON: /api/errors/5264dc07e4ad3043. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/agents/index.js:459

      };
    }

    return null;
  }

  /**
   * Finds or assumes the model preference value to use for API calls.
   * If multi-model loading is supported, we use their agent model selection of the workspace
   * If not supported, we attempt to fallback to the system provider value for the LLM preference
   * and if that fails - we assume a reasonable base model to exist.
   * @returns {string|null} the model preference value to use in API calls
   */
  #fetchModel() {
    // Provider was not explicitly set for workspace, so we are going to run our fallback logic
    // that will set a provider and model for us to use.
    if (!this.provider) {
      const fallback = this.#getFallbackProvider();
      if (!fallback) throw new Error("No valid provider found for the agent.");
      this.provider = fallback.provider; // re-set the provider to the fallback provider so it is not null.
      return fallback.model; // set its defined model based on fallback logic.
    }

    // The provider was explicitly set, so check if the workspace has an agent model set.
    if (this.invocation.workspace.agentModel)
      return this.invocation.workspace.agentModel;

    // Otherwise, we have no model to use - so guess a default model to use via the provider
    // and it's system ENV params and if that fails - we return either a base model or null.
    return this.providerDefault();
  }

  async #providerSetupAndCheck() {
    this.provider = this.invocation.workspace.agentProvider ?? null; // set provider to workspace agent provider if it exists
    this.model = this.#fetchModel();

    // If provider resolved to model router, resolve the actual provider/model

View on GitHub (pinned to 20f6d3546c)