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 EphemeralAgentHandler.#fetchModel() (server/utils/agents/ephemeral.js:187) when this.provider is null AND #getFallbackProvider() also returns null. The fallback path tries the system LLM_PROVIDER and calls providerDefault() to find a model; it returns null when LLM_PROVIDER is unset or set to a provider whose default model cannot be resolved. Net effect: neither the workspace nor the system provides a usable agent provider+model pair.
Source
Thrown at server/utils/agents/ephemeral.js:192
};
}
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.#workspace?.agentModel) return this.#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.#workspace?.agentProvider ?? null;
this.model = this.#fetchModel();
// If provider resolved to model router, resolve the actual provider/model
if (this.provider === "anythingllm-router") {View on GitHub (pinned to 526360e320)
Solutions
- Configure a system LLM provider in System Settings -> LLM Preference (sets LLM_PROVIDER) plus its model, then retry.
- Or set the workspace Agent Provider and Agent Model explicitly.
- For providers that need a model-pref env (OPEN_MODEL_PREF, MOONSHOT_AI_MODEL_PREF, etc.), set that env too so providerDefault() returns a value.
Example fix
// before: LLM_PROVIDER unset, workspace has no agentProvider // after (.env) LLM_PROVIDER=openai OPEN_AI_API_KEY=sk-... OPEN_MODEL_PREF=gpt-4o-mini
Defensive patterns
Strategy: validation
Validate before calling
function canResolveEphemeralProvider(workspace) {
if (workspace?.agentProvider) return true;
const sys = process.env.LLM_PROVIDER;
return Boolean(sys); // providerDefault() must also yield a model
}
if (!canResolveEphemeralProvider(workspace)) return showSetupError('Configure a system or workspace agent provider.'); Try / catch
try { await ephemeral.init(); } catch (e) { if (/No valid provider found for the agent/.test(e.message)) return promptProviderSetup(); throw e; } Prevention
- Always configure a system LLM provider so the fallback path succeeds.
- Set workspace-level agentProvider/agentModel for workspaces that use agents.
- Run a boot self-test calling providerDefault() for the configured provider and warn if null.
When it happens
Trigger: Ephemeral agent init runs with #workspace.agentProvider unset/null, and process.env.LLM_PROVIDER is unset OR set to a provider whose providerDefault() yields no model.
Common situations: Fresh install where the system LLM preference was never set; workspace created before any provider configured; LLM_PROVIDER points at a provider that needs a model-pref env (e.g. OPEN_MODEL_PREF) which is also unset; multi-model loading disabled and no system default.
Related errors
- No valid provider found for the agent.
- Foundry base path must be provided to use agents.
- GiteeAI API Key must be provided to use agents.
- Cohere API key must be provided to use agents.
- Docker Model Runner base path must be provided to use agents
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/c73b81d51e49ce35.
Report an issue: GitHub.