{"record":{"id":"2a9cdc6b23a9c143","repo":"Mintplex-Labs/anything-llm","slug":"no-model-router-found-for-this-workspace","errorCode":null,"errorMessage":"No model router found for this workspace.","messagePattern":"No model router found for this workspace\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/modelRouter/index.js","lineNumber":38,"sourceCode":"  /**\n   * Resolve the route and instantiate the delegate LLM provider.\n   * Must be called before any chat methods.\n   *\n   * Flow:\n   * 1. Evaluate calculated rules (always — they're free)\n   * 2. Evaluate LLM rules (uses cache to avoid expensive calls)\n   * 3. If nothing matched, use the sticky route (previous model stays)\n   * 4. If sticky expired, fall back to the default model\n   *\n   * @param {Object} context - { prompt, conversationHistory, conversationTokenCount }\n   * @param {Object} opts - { user, thread }\n   */\n  async resolve(context = {}, { user = null, thread = null } = {}) {\n    this.router = await this.routerService.resolveRouterForWorkspace(\n      this.workspace\n    );\n    if (!this.router)\n      throw new Error(\"No model router found for this workspace.\");\n\n    const rules = this.router.rules || [];\n    const stickyMs = (this.router.cooldown_seconds ?? 300) * 1000;\n    this._routeKey = this.routerService.routeCacheKey(\n      user?.id,\n      this.workspace.slug,\n      thread?.slug\n    );\n\n    this.routerService.logRoutingContext(this.router, rules, context);\n\n    // Step 1: Calculated rules (always re-evaluated, they're instant)\n    const calcResult = this.routerService.evaluateCalculatedRules(\n      rules,\n      context\n    );\n    if (calcResult) {\n      this.resolvedRoute = calcResult;","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/modelRouter/index.js#L20-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: no router for workspace -> resolve() throws\n\n// after: guard before resolving, fall back to default model\nconst router = await this.routerService.resolveRouterForWorkspace(this.workspace);\nif (!router) {\n  return { model: this.defaultModel, reason: 'no-router' };\n}","handlingStrategy":"validation","validationCode":"// Before calling router.resolve()\nconst router = await routerService.resolveRouterForWorkspace(workspace);\nif (!router) {\n  // fall back to the workspace default model instead of throwing\n  return { model: workspace.defaultModel, reason: 'no-router' };\n}","typeGuard":"function hasRouter(r) {\n  return r != null && typeof r === 'object' && Array.isArray(r.rules);\n}","tryCatchPattern":"try {\n  await router.resolve(context, { user, thread });\n} catch (e) {\n  if (/No model router found for this workspace/i.test(e.message)) {\n    // configure a router or fall back to the default model\n  }\n}","preventionTips":["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."],"tags":["model-router","workspace","configuration","routing"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}