{"record":{"id":"f4aa721f90875aae","repo":"janhq/jan","slug":"no-supported-context-increase-is-available-check-the-model","errorCode":null,"errorMessage":"No supported context increase is available. Check the model context limit in provider settings.","messagePattern":"No supported context increase is available\\. Check the model context limit in provider settings\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"web-app/src/lib/coworkModelControls.ts","lineNumber":71,"sourceCode":"\nexport async function increaseCoworkContext(\n  models: ModelsService,\n  providerName: string,\n  modelId: string\n): Promise<void> {\n  const provider = useModelProvider.getState().getProviderByName(providerName)\n  let context = coworkModelContext(provider, modelId)\n  if (!context) {\n    const setting = coworkLocalModel(provider, modelId)?.settings?.ctx_len\n    const value = Number(setting?.controller_props?.value)\n    if (setting && Number.isInteger(value) && value > 0) {\n      const max = await models.getModelContextLimit(modelId, providerName)\n      if (max !== undefined && Number.isInteger(max) && max > 0)\n        context = { value, max, next: nextCoworkContextSize(value, max) }\n    }\n  }\n  if (context?.next === undefined)\n    throw new Error(\n      'No supported context increase is available. Check the model context limit in provider settings.'\n    )\n\n  if (providerName === 'llamacpp') {\n    await models.updateModelSettings(modelId, { ctx_len: context.next })\n  } else if ((await models.getActiveModels(providerName)).includes(modelId)) {\n    const result = await models.stopModel(modelId, providerName)\n    if (!result?.success)\n      throw new Error(\n        result?.error ??\n          'Could not unload the model. Stop its active requests and try again.'\n      )\n  }\n\n  // Publish only after application succeeds. Merge into live state without\n  // restoring an old provider snapshot or changing the user's selection.\n  const state = useModelProvider.getState()\n  const latest = state.getProviderByName(providerName)","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/web-app/src/lib/coworkModelControls.ts#L53-L89","documentation":"Thrown by increaseCoworkContext when it cannot compute a `next` context size — either the current context value is unknown or getModelContextLimit returned no usable max, leaving context?.next undefined. The user is told to check the model's context limit in provider settings.","triggerScenarios":"Clicking the context-increase control when the current context value is unavailable, or getModelContextLimit(modelId, providerName) returns undefined / non-positive / non-integer, so nextCoworkContextSize cannot produce a next value.","commonSituations":"Model settings lack a context limit (ctx_len not configured for llamacpp); a remote provider reports no context window; modelId/providerName mismatch causing the limit lookup to miss.","solutions":["Set the model's context limit explicitly in provider settings (e.g. ctx_len for llama.cpp)","Verify modelId and providerName are correct so the limit lookup resolves","Restart the model session to reset the current context value, then retry the increase","If the model genuinely has no larger limit, stop increasing context"],"exampleFix":"// before\nawait increaseCoworkContext(modelId, providerName)\n// after\nconst max = await models.getModelContextLimit(modelId, providerName)\nif (max === undefined || max <= 0) {\n  window.toast?.warning('This model has no configured context limit; set it in provider settings first.')\n  return\n}\nawait increaseCoworkContext(modelId, providerName)","handlingStrategy":"validation","validationCode":"const max = await models.getModelContextLimit(modelId, providerName)\nif (max === undefined || !Number.isInteger(max) || max <= 0) {\n  showToast('No context limit configured for this model. Set it in provider settings.')\n  return\n}","typeGuard":"const hasUsableContextLimit = (max: number | undefined): max is number =>\n  typeof max === 'number' && Number.isInteger(max) && max > 0","tryCatchPattern":"try {\n  await increaseCoworkContext(modelId, providerName)\n} catch (e) {\n  if (e.message.includes('No supported context increase')) {\n    openModelContextSettings(modelId)\n  }\n}","preventionTips":["Set ctx_len / context limit in provider settings for every model","Disable the increase control when no limit is known","Surface the current vs max context in the UI","Validate modelId/providerName before the lookup"],"tags":["configuration","context-window","model-settings"],"backgroundTag":"missing-config-value","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"}