feat: add database-backed verified models for dynamic model managemen…#12833
feat: add database-backed verified models for dynamic model managemen…#12833tofarr merged 19 commits intoOpenHands:mainfrom
Conversation
…t in SaaS without code deployments
all-hands-bot
left a comment
There was a problem hiding this comment.
Summary: This PR introduces useful functionality for dynamic model management, but has critical security and data integrity issues that must be addressed before merging.
Key Issues:
- 🔴 Critical: No admin authorization on admin API endpoints
- 🔴 Critical: Model names contain unrealistic future dates
- 🟠 Important: Type safety issues with conditional imports
- 🟠 Important: Missing input validation and transaction handling
See inline comments for details.
all-hands-bot
left a comment
There was a problem hiding this comment.
Solid implementation overall! The database-backed model management is well-architected with good test coverage. I found several important issues around session management, consistency, and error handling that should be addressed before merging.
…/database-backed-verified-models
…nd unique constraints, input validation, and proper timestamp handling
…mpliance" This reverts commit 636fc83.
|
@neubig Could you please review this PR? |
|
@OpenHands: check if the review comments have been reflected, and if so mark them as "resolved" using graphql. If not, note them here. |
|
I'm on it! neubig can track my progress at all-hands.dev |
|
I reviewed all 19 review comment threads on PR #12833 and verified that all of them have been addressed in the current code. I then marked all threads as "resolved" using the GitHub GraphQL API. Summary of Review Comments and Their Resolution StatusCritical Issues (All Addressed ✅)
Important Issues (All Addressed ✅)
Suggestions (All Addressed ✅)
All 19 review threads have been marked as resolved via the GitHub GraphQL API. No code changes were needed as all comments had already been addressed in the current branch. |
|
Hi @bittoby , will do, I'll take a look |
…/database-backed-verified-models
16d149e to
6da3555
Compare
|
I think it'd probably be better for someone more familiar with the code than me to take a look at this one! |
…/database-backed-verified-models
…/database-backed-verified-models
…models can be updated without cutting a release
|
@tofarr @malhotra5 Sorry for tagging several people. If possible, could you please review this PR? I’d really appreciate your feedback. |
|
@hieptl please review the PR. thanks |
tofarr
left a comment
There was a problem hiding this comment.
Great work! One nit mentioned - it's more worry about maintaining established patterns than this PR.
…/database-backed-verified-models
35a3ab4 to
add68a6
Compare
|
@tofarr Thanks for your feedback. I updated. could you please review again when you get a time? |
tofarr
left a comment
There was a problem hiding this comment.
🍰 - I'll create a follow up PR for database level filtering
Add check for whether models are available in the SaaS verified_models database (app.all-hands.dev). This is separate from frontend code support since SaaS uses a database-backed system since PR OpenHands/OpenHands#12833. Changes: - Add check_saas_verified_model() function that queries the live API - Add frontend_saas_available boolean field to track output - Update all_models.json with the new field - Add tests for the new functionality This helps identify models like claude-opus-4-6 that have frontend code support but are not yet in the SaaS dropdown because they haven't been added to the verified_models database. Co-authored-by: openhands <openhands@all-hands.dev>
…ity (#39) * feat: add frontend_saas_available field to track SaaS model availability Add check for whether models are available in the SaaS verified_models database (app.all-hands.dev). This is separate from frontend code support since SaaS uses a database-backed system since PR OpenHands/OpenHands#12833. Changes: - Add check_saas_verified_model() function that queries the live API - Add frontend_saas_available boolean field to track output - Update all_models.json with the new field - Add tests for the new functionality This helps identify models like claude-opus-4-6 that have frontend code support but are not yet in the SaaS dropdown because they haven't been added to the verified_models database. Co-authored-by: openhands <openhands@all-hands.dev> * refactor: frontend_support_timestamp requires both code AND SaaS availability Change frontend_support_timestamp to only be set when a model is in BOTH: 1. verified-models.ts (for self-hosted deployments) 2. SaaS verified_models database (for app.all-hands.dev) This removes the separate frontend_saas_available field and makes the logic simpler - frontend_support_timestamp represents full frontend availability for all users. Co-authored-by: openhands <openhands@all-hands.dev> * fix: correctly mock subprocess calls in test_search_index_results_success The function calls subprocess.run twice (git log + git show), so the test needs to mock both calls using side_effect. Co-authored-by: openhands <openhands@all-hands.dev> * fix: add frontend_saas_available field to result dictionary Co-authored-by: openhands <openhands@all-hands.dev> * chore: regenerate all_models.json with updated logic Models without SaaS availability now correctly show null frontend_support_timestamp. Co-authored-by: openhands <openhands@all-hands.dev> * docs: add SaaS Admin API documentation to add-new-model skill Document the verified_models Admin API endpoints for adding models to the SaaS database (app.all-hands.dev). This is required for models to appear in the frontend dropdown on the hosted platform. Includes: - POST /api/admin/verified-models (create) - GET /api/admin/verified-models (list) - PUT /api/admin/verified-models/{provider}/{model_name} (update) - DELETE /api/admin/verified-models/{provider}/{model_name} (delete) - Authentication requirements (@all-hands.dev email domain) - Explanation of frontend_saas_available field Co-authored-by: openhands <openhands@all-hands.dev> * Change 'SaaS Database' to 'Cloud Database' in SKILL.md Updated references from 'SaaS Database' to 'Cloud Database' in SKILL.md. --------- Co-authored-by: openhands <openhands@all-hands.dev>
Summary
Store the list of supported models in a database (when used on SaaS) so it can be updated without cutting a release.
Problem
Adding new models to the OpenHands Cloud model selector requires a code release, which is slow and heavyweight for what should be a simple configuration change.
Solution
In SaaS mode, load verified models from a
verified_modelsdatabase table instead of the hardcoded list. Self-hosted deployments are unaffected and continue using the hardcoded model arrays.Changes
New files (enterprise):
storage/verified_model.py— SQLAlchemy model with composite unique key(model_name, provider)storage/verified_model_store.py— static-method store for CRUD operations (followsUserStore/OrgMemberStoreconventions)server/routes/verified_models.py— admin CRUD API at/api/admin/verified-modelsmigrations/versions/097_create_verified_models_table.py— creates table and seeds current 11 openhands provider modelstests/unit/storage/test_verified_model_store.py— 14 unit testsModified files (core):
openhands/utils/llm.py—get_supported_llm_models()accepts optionalverified_modelslist that replaces hardcoded models when providedopenhands/server/routes/public.py—/api/options/modelsendpoint loads models from DB in SaaS mode, falls back to hardcoded list on error or in self-hosted modeenterprise/saas_server.py— registers the admin routerenterprise/tests/unit/conftest.py— importsVerifiedModelso shared test DB includes the tableChange Type
Checklist
Fixes
Resolves #12807
Release Notes
Added database-backed verified models for SaaS deployments, allowing administrators to dynamically manage supported LLM models without code deployments.