{"record":{"id":"220d53dd28ea4b5e","repo":"janhq/jan","slug":"model-errors-createmodelfailed","errorCode":null,"errorMessage":"model-errors:createModelFailed","messagePattern":"model-errors:createModelFailed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web-app/src/lib/custom-chat-transport.ts","lineNumber":1210,"sourceCode":"        updatedProvider ?? provider,\n        mergedParams,\n        providerId,\n        options.abortSignal\n      )\n      useAppState.getState().updateLoadingModel(false)\n      useAppState.getState().updateThreadLoadingModel(threadId, false)\n      useAppState.getState().updateModelLoadProgress(undefined)\n      useAppState.getState().updateThreadModelLoadProgress(threadId, undefined)\n    } catch (error) {\n      useAppState.getState().updateLoadingModel(false)\n      useAppState.getState().updateThreadLoadingModel(threadId, false)\n      useAppState.getState().updateModelLoadProgress(undefined)\n      useAppState.getState().updateThreadModelLoadProgress(threadId, undefined)\n      console.error('Failed to create model:', error)\n      // Preserve AbortError identity so callers/UI can tell a user-initiated\n      // Stop from an actual model-load failure.\n      if (error instanceof Error && error.name === 'AbortError') throw error\n      throw new Error(\n        i18n.t('model-errors:createModelFailed', {\n          reason: describeEngineError(error),\n        })\n      )\n    }\n\n    await this.refreshTools(options.abortSignal)\n\n    // Split assistant turns that place text after tool calls into separate\n    // messages. Required by the Claude API (tool_use / tool_result pairing) and\n    // it keeps the prompt prefix byte-identical across turns so llama.cpp reuses\n    // the KV cache. See `splitAssistantToolWaves`.\n    const messagesToConvert = splitAssistantToolWaves(options.messages)\n\n    const inferenceParams = this.getActiveInferenceParams()\n\n    const selectedModel = useModelProvider.getState().selectedModel\n","sourceCodeStart":1192,"sourceCodeEnd":1228,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/web-app/src/lib/custom-chat-transport.ts#L1192-L1228","documentation":"Thrown when `this.createModelOrAbort(...)` rejects with a non-AbortError during message send. The catch block preserves AbortError identity (user pressed Stop) but wraps every other failure through i18n key `model-errors:createModelFailed` with `describeEngineError(error)` as the reason. This is the umbrella error for any model-load/creation failure across all providers.","triggerScenarios":"llama.cpp server failed to load the GGUF (corrupt/unsupported file, OOM, missing mmproj); remote provider returned auth failure during model init (401/403); the model binary path is wrong; the engine extension threw during instantiation; context-length or GPU-layer settings exceed hardware.","commonSituations":"Insufficient RAM/VRAM to load the model; wrong API key for an OpenAI-compatible provider; GGUF version unsupported by the installed llama.cpp build; model file truncated/corrupted; engine extension crashed and its IPC bridge is down.","solutions":["Read the `reason` in the surfaced message and the console — `describeEngineError` extracts the underlying engine message.","For local models: reduce context length / GPU layers, free memory, or use a smaller quantization.","For remote providers: verify the API key and base URL in provider settings.","For GGUF: confirm the file's version is supported by the installed llama.cpp build; re-download if corrupt.","Restart the engine extension if its IPC bridge died."],"exampleFix":"// before\nif (error instanceof Error && error.name === 'AbortError') throw error\nthrow new Error(i18n.t('model-errors:createModelFailed', { reason: describeEngineError(error) }))\n\n// after\nif (error instanceof Error && error.name === 'AbortError') throw error\nconst reason = describeEngineError(error)\nconsole.error('[createModel] full error:', error)\nthrow new Error(\n  i18n.t('model-errors:createModelFailed', {\n    reason: reason || 'Unknown error. See console for details.',\n  })\n)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isAbortError(e: unknown): e is Error {\n  return e instanceof Error && e.name === 'AbortError'\n}","tryCatchPattern":"try {\n  this.model = await this.createModelOrAbort(modelId, updatedProvider ?? provider, mergedParams, providerId, options.abortSignal)\n} catch (error) {\n  useAppState.getState().updateLoadingModel(false)\n  useAppState.getState().updateThreadLoadingModel(threadId, false)\n  if (isAbortError(error)) throw error // user pressed Stop — preserve identity\n  console.error('[createModel] underlying error:', error)\n  throw new Error(i18n.t('model-errors:createModelFailed', { reason: describeEngineError(error) }))\n}","preventionTips":["For local models: confirm the GGUF exists and is supported before loading; reduce ctx_len/GPU layers on OOM.","For remote providers: validate API key and base URL in provider settings before sending.","Watch the console for the underlying engine error describeEngineError extracts.","Restart the engine extension if its IPC bridge crashed."],"tags":["transport","model-load","engine","llamacpp","provider"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}