janhq/jan · error

model-errors:noRunningSession

model-errors:noRunningSession

Error message

model-errors:noRunningSession

What it means

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.

Solutions

  1. Start the model's local server session (load the model) before sending requests.
  2. Verify the modelId matches a currently running session; re-select the model in the UI.
  3. Handle the failure by launching findSessionByModel's counterpart start/load flow and retrying.

Example fix

// before
const client = await createModelClient(modelId) // throws if not running
// after
let info = await findSessionByModel(modelId)
if (!info) info = await startModelSession(modelId)
const client = await createModelClient(modelId)
Defensive patterns

Strategy: try-catch

Validate before calling

const info = await findSessionByModel(modelId)
if (!info) await startModelSession(modelId)

Type guard

const isSessionInfo = (s) => !!s && typeof s.port === 'number' && typeof s.api_key === 'string'

Try / catch

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 }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17). Data as JSON: /api/errors/df18198f414f34cf. Report an issue: GitHub.

Appendix: source

Thrown at web-app/src/lib/model-factory.ts:1022

        if (serviceHub) {
          await serviceHub.models().startModel(provider, modelId)
        }
      } catch (error) {
        console.error('Failed to start llamacpp model:', error)
        // A serialized engine error is a plain object, so the previous
        // `instanceof Error` path stringified it into raw JSON for the user.
        // It rides along as `cause` so an outer layer describes the failure
        // once from its code instead of nesting this sentence inside its own.
        throw engineFailure('model-errors:startModelFailed', error)
      }
    }

    // Get session info which includes port and api_key
    const sessionInfo = await findSessionByModel(modelId)

    if (!sessionInfo) {
      throw new Error(
        i18n.t('model-errors:noRunningSession', { model: modelId })
      )
    }

    const onLlamacppServerError = provider
      ? () => {
          void (async () => {
            try {
              const { useServiceStore } = await import('@/hooks/useServiceHub')
              const hub = useServiceStore.getState().serviceHub
              await hub?.models().reloadModel(provider, modelId)
            } catch (e) {
              console.warn('[llamacpp] reload after crash failed:', e)
            }
          })()
        }
      : undefined
    // The global toggle can strip reasoning_content from resent assistant turns,

View on GitHub (pinned to 7205d770c1)