Self-hosted: chat_advanced overrides all model selection, sidebar picker and chat_default are ignored
Author: usaloCKLEnTOCreated Mar 19, 2026Updated Aug 11, 2026
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:
think_paid_fast— checked first, but these columns don't exist yet in v1.42.10 schema (migration not shipped), so always Nonethink_paid_deep— same, always Nonechat_advanced— this 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
- Sidebar model picker is ignored —
UserConversationConfig.setting_idis never checked becausechat_advancedtakes priority chat_defaultis dead config — never used on self-hosted- 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
- Agent
chat_modelassignment is ignored for the default agent —get_agent_chat_modelreturns dynamically resolved model which hits the samechat_advancedpath
Verified With
- LangFuse traces showing all 4 steps (intent, code gen, chat, title) use
chat_advancedmodel regardless of sidebar selection - Tested changing
chat_default, sidebar model picker, agent model — all ignored - Only changing
chat_advancedin 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:
- Don't treat all users as "subscribed" — or add a separate flag for self-hosted
- Make
chat_defaultwork as the fast/intent model regardless of subscription status - Respect the sidebar model picker for the chat response step even when server settings are configured
Source: khoj-ai/khoj