Mintplex-Labs/anything-llm · error · Error
No model router found for this workspace.
Error message
No model router found for this workspace.
What it means
ModelRouter.resolve() asks routerService.resolveRouterForWorkspace(this.workspace) for the workspace's configured router. If no router is configured/active for that workspace it returns null and resolve() throws — routing cannot proceed. The router carries rules, cooldown_seconds, and the default/sticky model fallback chain.
Source
Thrown at server/utils/AiProviders/modelRouter/index.js:38
/**
* Resolve the route and instantiate the delegate LLM provider.
* Must be called before any chat methods.
*
* Flow:
* 1. Evaluate calculated rules (always — they're free)
* 2. Evaluate LLM rules (uses cache to avoid expensive calls)
* 3. If nothing matched, use the sticky route (previous model stays)
* 4. If sticky expired, fall back to the default model
*
* @param {Object} context - { prompt, conversationHistory, conversationTokenCount }
* @param {Object} opts - { user, thread }
*/
async resolve(context = {}, { user = null, thread = null } = {}) {
this.router = await this.routerService.resolveRouterForWorkspace(
this.workspace
);
if (!this.router)
throw new Error("No model router found for this workspace.");
const rules = this.router.rules || [];
const stickyMs = (this.router.cooldown_seconds ?? 300) * 1000;
this._routeKey = this.routerService.routeCacheKey(
user?.id,
this.workspace.slug,
thread?.slug
);
this.routerService.logRoutingContext(this.router, rules, context);
// Step 1: Calculated rules (always re-evaluated, they're instant)
const calcResult = this.routerService.evaluateCalculatedRules(
rules,
context
);
if (calcResult) {
this.resolvedRoute = calcResult;View on GitHub (pinned to 526360e320)
Solutions
- In the admin UI, create and enable a model router for the affected workspace.
- Confirm this.workspace.slug matches the router's workspace binding.
- Verify the router record exists and is active in the data store.
- As a stopgap, set a default LLM for the workspace so routing is not required.
Example fix
// before: no router for workspace -> resolve() throws
// after: guard before resolving, fall back to default model
const router = await this.routerService.resolveRouterForWorkspace(this.workspace);
if (!router) {
return { model: this.defaultModel, reason: 'no-router' };
} Defensive patterns
Strategy: validation
Validate before calling
// Before calling router.resolve()
const router = await routerService.resolveRouterForWorkspace(workspace);
if (!router) {
// fall back to the workspace default model instead of throwing
return { model: workspace.defaultModel, reason: 'no-router' };
} Type guard
function hasRouter(r) {
return r != null && typeof r === 'object' && Array.isArray(r.rules);
} Try / catch
try {
await router.resolve(context, { user, thread });
} catch (e) {
if (/No model router found for this workspace/i.test(e.message)) {
// configure a router or fall back to the default model
}
} Prevention
- Ensure every workspace that uses routing has a router assigned at creation.
- Provide a default-model fallback so a missing router degrades gracefully.
- Alert admins when a workspace's router is deleted/disabled.
When it happens
Trigger: Invoking router.resolve() for a workspace that has no model router configured, whose router was deleted/disabled, or whose workspace slug does not match any router assignment.
Common situations: Model-router feature enabled but no router created for the workspace; admin removed the workspace's router; new workspace never assigned a router; DB row for the router missing/corrupted; workspace.slug mismatch.
Related errors
- res.statusText || "Error setting watch status for document."
- Error setting suggested messages.
- HTTP ${resp.status}: ${(await resp.text()).slice(0, 200)}
- Community Hub connection key not found
- Failed to create workspace
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/2a9cdc6b23a9c143.
Report an issue: GitHub.