Skip to content

Bud Foundry model list is global, not per-user — last sync overwrites for everyone #1

@dittops

Description

@dittops

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

  1. User A logs in with OAuth — has access to 3 Bud Foundry models
  2. _sync_bud_foundry_models_to_db() runs → DB now has 3 ModelConfiguration rows
  3. User B logs in — has access to 0 Bud Foundry models (or different ones)
  4. _sync_bud_foundry_models_to_db() runs → DB now has 0 rows (User A's models deleted)
  5. 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

  1. Add user_id FK column to ModelConfiguration (alembic migration)
  2. Scope update_bud_foundry_model_configurations() to delete/insert only for the current user
  3. Scope model queries in _resolve_bud_foundry_model() to filter by user_id
  4. Update get_default_llms() to pass user context through the model resolution chain

Key Files

  • backend/onyx/db/llm.pyupdate_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.pyModelConfiguration model

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