Skip to content

Self-hosted: chat_advanced overrides all model selection, sidebar picker and chat_default are ignored #1282

@usaloCKLEnTO

Description

@usaloCKLEnTO

Problem

On self-hosted Khoj (v1.42.10, billing disabled), chat_advanced is used for ALL LLM calls — intent classification, code generation, title generation, and chat responses. The sidebar model picker and chat_default server setting have no effect.

Root Cause

In database/adapters/__init__.py, ais_user_subscribed() returns True when state.billing_enabled is False (line 422). This means all self-hosted users are treated as "subscribed."

In aget_default_chat_model(), for subscribed users with fast=True:

  1. think_paid_fast — checked first, but these columns don't exist yet in v1.42.10 schema (migration not shipped), so always None
  2. think_paid_deep — same, always None
  3. chat_advancedthis is what gets returned for every call

chat_default is only reached in the else (non-subscribed) branch at line 1345, which never executes on self-hosted.

Impact

  1. Sidebar model picker is ignoredUserConversationConfig.setting_id is never checked because chat_advanced takes priority
  2. chat_default is dead config — never used on self-hosted
  3. Intent classification uses the same model as chat — no way to use a fast/cheap model for tool selection and a different model for responses
  4. Agent chat_model assignment is ignored for the default agentget_agent_chat_model returns dynamically resolved model which hits the same chat_advanced path

Verified With

  • LangFuse traces showing all 4 steps (intent, code gen, chat, title) use chat_advanced model regardless of sidebar selection
  • Tested changing chat_default, sidebar model picker, agent model — all ignored
  • Only changing chat_advanced in the database affects which model is used

Environment

  • Khoj v1.42.10 (ghcr.io/khoj-ai/khoj:latest)
  • Self-hosted, billing disabled
  • PostgreSQL backend
  • LiteLLM as OpenAI-compatible proxy

Suggested Fix

For self-hosted (billing disabled), either:

  1. Don't treat all users as "subscribed" — or add a separate flag for self-hosted
  2. Make chat_default work as the fast/intent model regardless of subscription status
  3. Respect the sidebar model picker for the chat response step even when server settings are configured

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions