{"record":{"id":"21533572b763ced5","repo":"HKUDS/DeepTutor","slug":"no-active-llm-model-is-configured-please-set-it-i","errorCode":null,"errorMessage":"No active LLM model is configured. Please set it in Settings > Catalog.","messagePattern":"No active LLM model is configured\\. Please set it in Settings > Catalog\\.","errorType":"error_code","errorClass":"LLMConfigError","httpStatus":null,"severity":"critical","filePath":"deeptutor/services/llm/config.py","lineNumber":174,"sourceCode":"    Explicitly initialize environment variables for compatibility.\n\n    This should be called during application startup to keep OPENAI_* env vars\n    aligned with current config values.\n    \"\"\"\n    resolved = resolve_llm_runtime_config()\n    if _is_openai_compatible_binding(resolved.binding):\n        _set_openai_env_vars(\n            resolved.api_key,\n            resolved.effective_url,\n            source=\"initialize_environment\",\n        )\n\n\ndef _get_llm_config_from_resolver() -> LLMConfig:\n    \"\"\"Resolve LLM config from the TutorBot-style runtime adapter.\"\"\"\n    resolved = resolve_llm_runtime_config()\n    if not resolved.model:\n        raise LLMConfigError(\n            \"No active LLM model is configured. Please set it in Settings > Catalog.\"\n        )\n    if not resolved.effective_url and resolved.provider_mode != \"oauth\":\n        raise LLMConfigError(\n            \"No effective LLM endpoint resolved. Please configure base_url or provider defaults.\"\n        )\n    is_placeholder_key = resolved.api_key in {\"\", \"no-key\", \"sk-no-key-required\"}\n    if (\n        resolved.provider_name == \"openai\"\n        and resolved.provider_mode == \"standard\"\n        and is_placeholder_key\n    ):\n        raise LLMConfigError(\n            \"OpenAI API key is not configured. Set it in Settings > Catalog, \"\n            \"or select a local provider such as Ollama.\"\n        )\n    return LLMConfig(\n        model=resolved.model,","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/llm/config.py#L156-L192","documentation":"The runtime config resolver (resolve_llm_runtime_config) returned a profile with an empty model, so _get_llm_config_from_resolver cannot construct an LLMConfig and raises LLMConfigError pointing the user at Settings > Catalog. This is the earliest and most common startup/first-call failure for cloud providers.","triggerScenarios":"Fresh install with no model selected; settings JSON exists but the active profile's model field is empty; a provider was chosen but its model sub-selection was never made; programmatic use before any catalog setup.","commonSituations":"New users running their first chat before configuring anything; settings reset or migration wiping the model; CI/smoke tests instantiating the app without seeding settings.","solutions":["Open Settings > Catalog in the app and select an active model (or set it in data/user/settings/*.json).","Programmatically: seed the settings file or set the model before calling get_llm_config().","Verify by calling resolve_llm_runtime_config() and checking .model is non-empty.","For local dev, select an Ollama model to avoid needing cloud credentials."],"exampleFix":"// before\ncfg = get_llm_config()  # raises on fresh install\n\n# after\nresolved = resolve_llm_runtime_config()\nif not resolved.model:\n    # seed settings: select e.g. gpt-4o-mini or an Ollama model\ncfg = get_llm_config()","handlingStrategy":"validation","validationCode":"from deeptutor.services.llm.config import resolve_llm_runtime_config  # or equivalent\nresolved = resolve_llm_runtime_config()\nif not resolved.model:\n    raise RuntimeError(\"Select a model in Settings > Catalog before starting\")\ncfg = get_llm_config()","typeGuard":"def has_active_model(resolved) -> bool:\n    return bool(getattr(resolved, \"model\", None) and resolved.model.strip())","tryCatchPattern":"try:\n    cfg = get_llm_config()\nexcept LLMConfigError as e:\n    if \"No active LLM model\" in str(e):\n        run_first_time_setup()  # seed settings, then retry\n    raise","preventionTips":["Include a first-run wizard that forces model selection.","Seed a default (e.g. local Ollama model) in fresh installs.","Smoke-test get_llm_config() in CI with a fixture profile."],"tags":["llm","configuration","model-required","bootstrap"],"backgroundTag":"missing-configuration-value","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}