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 None
think_paid_deep — same, always None
chat_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_id is never checked because chat_advanced takes priority
chat_default is 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_model assignment is ignored for the default agent — get_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:
- Don't treat all users as "subscribed" — or add a separate flag for self-hosted
- Make
chat_default work 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
Problem
On self-hosted Khoj (v1.42.10, billing disabled),
chat_advancedis used for ALL LLM calls — intent classification, code generation, title generation, and chat responses. The sidebar model picker andchat_defaultserver setting have no effect.Root Cause
In
database/adapters/__init__.py,ais_user_subscribed()returnsTruewhenstate.billing_enabledis False (line 422). This means all self-hosted users are treated as "subscribed."In
aget_default_chat_model(), for subscribed users withfast=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 callchat_defaultis only reached in theelse(non-subscribed) branch at line 1345, which never executes on self-hosted.Impact
UserConversationConfig.setting_idis never checked becausechat_advancedtakes prioritychat_defaultis dead config — never used on self-hostedchat_modelassignment is ignored for the default agent —get_agent_chat_modelreturns dynamically resolved model which hits the samechat_advancedpathVerified With
chat_advancedmodel regardless of sidebar selectionchat_default, sidebar model picker, agent model — all ignoredchat_advancedin the database affects which model is usedEnvironment
Suggested Fix
For self-hosted (billing disabled), either:
chat_defaultwork as the fast/intent model regardless of subscription status