{"record":{"id":"df18198f414f34cf","repo":"janhq/jan","slug":"model-errors-norunningsession","errorCode":"model-errors:noRunningSession","errorMessage":"model-errors:noRunningSession","messagePattern":"model-errors:noRunningSession","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"web-app/src/lib/model-factory.ts","lineNumber":1022,"sourceCode":"\n        if (serviceHub) {\n          await serviceHub.models().startModel(provider, modelId)\n        }\n      } catch (error) {\n        console.error('Failed to start llamacpp model:', error)\n        // A serialized engine error is a plain object, so the previous\n        // `instanceof Error` path stringified it into raw JSON for the user.\n        // It rides along as `cause` so an outer layer describes the failure\n        // once from its code instead of nesting this sentence inside its own.\n        throw engineFailure('model-errors:startModelFailed', error)\n      }\n    }\n\n    // Get session info which includes port and api_key\n    const sessionInfo = await findSessionByModel(modelId)\n\n    if (!sessionInfo) {\n      throw new Error(\n        i18n.t('model-errors:noRunningSession', { model: modelId })\n      )\n    }\n\n    const onLlamacppServerError = provider\n      ? () => {\n          void (async () => {\n            try {\n              const { useServiceStore } = await import('@/hooks/useServiceHub')\n              const hub = useServiceStore.getState().serviceHub\n              await hub?.models().reloadModel(provider, modelId)\n            } catch (e) {\n              console.warn('[llamacpp] reload after crash failed:', e)\n            }\n          })()\n        }\n      : undefined\n    // The global toggle can strip reasoning_content from resent assistant turns,","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/web-app/src/lib/model-factory.ts#L1004-L1040","documentation":"Thrown when building a model client for a llama.cpp-backed model: findSessionByModel(modelId) returned null, meaning no running local server session is registered for that model. The message is an i18n key (model-errors:noRunningSession) interpolated with the model id, so users see a localized 'no running session' error.","triggerScenarios":"Requesting a model whose llama.cpp server session was never started; the session exited/crashed before the request; stale modelId after the session was stopped or the model reloaded; app restarted without restoring sessions.","commonSituations":"Calling chat before pressing start on the local model; app update losing previously running sessions; model id mismatch after renaming or re-downloading a model.","solutions":["Start the model's local server session (load the model) before sending requests.","Verify the modelId matches a currently running session; re-select the model in the UI.","Handle the failure by launching findSessionByModel's counterpart start/load flow and retrying."],"exampleFix":"// before\nconst client = await createModelClient(modelId) // throws if not running\n// after\nlet info = await findSessionByModel(modelId)\nif (!info) info = await startModelSession(modelId)\nconst client = await createModelClient(modelId)","handlingStrategy":"try-catch","validationCode":"const info = await findSessionByModel(modelId)\nif (!info) await startModelSession(modelId)","typeGuard":"const isSessionInfo = (s) => !!s && typeof s.port === 'number' && typeof s.api_key === 'string'","tryCatchPattern":"try { const client = await createModelClient(modelId) } catch (e) { if (e.message.includes('noRunningSession') || e.message.includes('no running')) { await startModelSession(modelId); return createModelClient(modelId) } throw e }","preventionTips":["Start the model session before enabling the chat input.","Subscribe to session lifecycle events and disable UI when a session stops.","Reconcile model ids with running sessions after app restart."],"tags":["session","llamacpp","local-server","state"],"backgroundTag":"resource-not-found","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}