Skip to content

fix(llm): Hide private models from Agent Creation#7873

Merged
justin-tahara merged 2 commits intomainfrom
jtahara/hide-private-models-from-agent-creation
Jan 27, 2026
Merged

fix(llm): Hide private models from Agent Creation#7873
justin-tahara merged 2 commits intomainfrom
jtahara/hide-private-models-from-agent-creation

Conversation

@justin-tahara
Copy link
Copy Markdown
Contributor

@justin-tahara justin-tahara commented Jan 27, 2026

Description

Updating the backend api check for LLM management in the Agent Creation page

How Has This Been Tested?

Tested locally by making an LLM config private and setting myself to a basic user.

Also added a proper test

Basic User:
Screenshot 2026-01-27 at 11 01 49 AM

Admin User:
Screenshot 2026-01-27 at 11 02 38 AM

Additional Options

  • [Optional] Override Linear Check

Summary by cubic

Hide private LLM providers from the Agent Creation page by enforcing centralized access control in the listing API. Non-public, unrestricted providers no longer appear for basic users; admins still see all.

  • Bug Fixes
    • Switched /llm/provider listing to use can_user_access_llm_provider(persona=None) for consistent checks.
    • Non-public providers with no groups/personas are now admin-only; persona-restricted providers are hidden without a persona context.
    • Added integration test validating visibility for basic users vs. admins.

Written for commit 10d83fe. Summary will update on new commits.

@justin-tahara justin-tahara requested a review from a team as a code owner January 27, 2026 19:03
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 27, 2026

Greptile Overview

Greptile Summary

Fixed security bug where non-public LLM providers with no group/persona restrictions were incorrectly accessible to all users instead of being admin-only.

Key Changes:

  • Replaced custom access control logic in list_llm_provider_basics with the centralized can_user_access_llm_provider function
  • The old logic incorrectly treated is_public=False providers with empty groups and personas lists as "accessible to everyone"
  • The centralized function correctly implements the admin-only policy for such providers (line 147 in backend/onyx/db/llm.py)

Impact:

  • Basic users can no longer see private LLM models intended only for admins in Agent Creation
  • Maintains correct behavior for public providers, group-restricted providers, and persona-restricted providers
  • Comprehensive test added to prevent regression

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change replaces custom logic with a well-tested centralized function, fixes a clear security bug, includes comprehensive test coverage, and simplifies the codebase by eliminating code duplication
  • No files require special attention

Important Files Changed

Filename Overview
backend/onyx/server/manage/llm/api.py Replaced custom access control logic with centralized can_user_access_llm_provider function, fixing bug where non-public providers with no restrictions were incorrectly shown to all users
backend/tests/integration/tests/llm_provider/test_llm_provider_access_control.py Added comprehensive test verifying non-public providers with no restrictions are admin-only and not visible to basic users

Sequence Diagram

sequenceDiagram
    participant User
    participant API as /llm/provider endpoint
    participant AccessControl as can_user_access_llm_provider
    participant DB as Database
    
    User->>API: GET /llm/provider
    API->>DB: fetch_existing_llm_providers()
    DB-->>API: all_providers[]
    API->>DB: fetch_user_group_ids(user)
    DB-->>API: user_group_ids
    
    loop For each provider
        API->>AccessControl: can_user_access_llm_provider(provider, user_group_ids, persona=None, is_admin)
        
        alt Provider is public
            AccessControl-->>API: True (public override)
        else Provider has groups only
            alt User is admin OR user in group
                AccessControl-->>API: True
            else
                AccessControl-->>API: False
            end
        else Provider has personas only
            AccessControl-->>API: False (persona=None)
        else Provider has both groups and personas
            AccessControl-->>API: False (persona=None)
        else Provider has no restrictions (not public)
            alt User is admin
                AccessControl-->>API: True
            else
                AccessControl-->>API: False (admin-only)
            end
        end
        
        alt Access granted
            API->>API: Add to accessible_providers
        end
    end
    
    API-->>User: accessible_providers[]
Loading

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link
Copy Markdown
Contributor

@yuhongsun96 yuhongsun96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@justin-tahara justin-tahara added this pull request to the merge queue Jan 27, 2026
Merged via the queue into main with commit f6e9928 Jan 27, 2026
78 of 79 checks passed
@justin-tahara justin-tahara deleted the jtahara/hide-private-models-from-agent-creation branch January 27, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants