Problem
The ModelConfiguration table has no user_id column — it stores model configurations globally. When a user's Bud Foundry models are synced via update_bud_foundry_model_configurations() in backend/onyx/db/llm.py, it performs a DELETE ALL + INSERT with the current user's available models. This means the last user to trigger a sync overwrites the model list for everyone.
Reproduction
- User A logs in with OAuth — has access to 3 Bud Foundry models
_sync_bud_foundry_models_to_db() runs → DB now has 3 ModelConfiguration rows
- User B logs in — has access to 0 Bud Foundry models (or different ones)
_sync_bud_foundry_models_to_db() runs → DB now has 0 rows (User A's models deleted)
- User A's agent tries to use a model → falls back to default list or fails
Observed Behavior
- When a user has no Bud Foundry models available, they see the full model list from another user who synced previously
- Error message: "No models available from Bud Foundry for this user" triggers fallback to stale global list
Root Cause
ModelConfiguration table lacks a user_id foreign key
update_bud_foundry_model_configurations() (backend/onyx/db/llm.py ~line 350) deletes ALL rows then inserts current user's models
_sync_bud_foundry_models_to_db() (backend/onyx/llm/factory.py ~line 106) calls the above without user scoping
Proposed Fix
- Add
user_id FK column to ModelConfiguration (alembic migration)
- Scope
update_bud_foundry_model_configurations() to delete/insert only for the current user
- Scope model queries in
_resolve_bud_foundry_model() to filter by user_id
- Update
get_default_llms() to pass user context through the model resolution chain
Key Files
backend/onyx/db/llm.py — update_bud_foundry_model_configurations()
backend/onyx/llm/factory.py — _sync_bud_foundry_models_to_db(), _resolve_bud_foundry_model(), get_default_llms()
backend/onyx/db/models.py — ModelConfiguration model
Problem
The
ModelConfigurationtable has nouser_idcolumn — it stores model configurations globally. When a user's Bud Foundry models are synced viaupdate_bud_foundry_model_configurations()inbackend/onyx/db/llm.py, it performs a DELETE ALL + INSERT with the current user's available models. This means the last user to trigger a sync overwrites the model list for everyone.Reproduction
_sync_bud_foundry_models_to_db()runs → DB now has 3ModelConfigurationrows_sync_bud_foundry_models_to_db()runs → DB now has 0 rows (User A's models deleted)Observed Behavior
Root Cause
ModelConfigurationtable lacks auser_idforeign keyupdate_bud_foundry_model_configurations()(backend/onyx/db/llm.py~line 350) deletes ALL rows then inserts current user's models_sync_bud_foundry_models_to_db()(backend/onyx/llm/factory.py~line 106) calls the above without user scopingProposed Fix
user_idFK column toModelConfiguration(alembic migration)update_bud_foundry_model_configurations()to delete/insert only for the current user_resolve_bud_foundry_model()to filter byuser_idget_default_llms()to pass user context through the model resolution chainKey Files
backend/onyx/db/llm.py—update_bud_foundry_model_configurations()backend/onyx/llm/factory.py—_sync_bud_foundry_models_to_db(),_resolve_bud_foundry_model(),get_default_llms()backend/onyx/db/models.py—ModelConfigurationmodel