feat: add automated model discovery with feature-flag-gated availability#692
feat: add automated model discovery with feature-flag-gated availability#692maskarb wants to merge 5 commits intoambient-code:mainfrom
Conversation
Replace hardcoded model arrays across backend, frontend, operator, and runner with a single model manifest (models.json) deployed as a ConfigMap. Backend serves models via a new API endpoint filtered by Unleash feature flags. Operator resolves Vertex AI model IDs from the manifest and injects them as env vars for runners. A daily GitHub Action probes Vertex AI endpoints and auto-creates PRs for manifest updates with corresponding disabled Unleash flags. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add missing Next.js API route handler for /projects/[name]/models that proxies to the backend, fixing 404 in the UI. Defer the models query until the create-session dialog is opened and invalidate the cache on each open to ensure fresh data after feature flag changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Claude Code ReviewSummaryPR #692 adds automated model discovery via a scheduled GHA workflow, a backend Issues by Severity🚫 Blocker IssuesNone (PR is in DRAFT). 🔴 Critical Issues1. Non-existent GitHub Actions versions — workflow will fail immediately
uses: actions/checkout@v6 # ❌ latest is @v4
uses: actions/setup-python@v6 # ❌ latest is @v5These produce an uses: actions/checkout@v4
uses: actions/setup-python@v5🟡 Major Issues2. Form In If the manifest's useEffect(() => {
if (modelsData?.defaultModel) {
form.setValue("model", modelsData.defaultModel, { shouldDirty: false });
}
}, [modelsData?.defaultModel, form]);3.
4.
// Fix: add Available guard
if m.ID == modelID && m.Available {
return m.VertexID
}5. Both 🔵 Minor Issues6. const handleTriggerClick = () => {
queryClient.invalidateQueries({ queryKey: modelKeys.all }); // ⚠️ unconditional
setOpen(true);
};This triggers a network request every time the dialog opens, even when data is 2 seconds old. Remove the invalidation — 7. No UI error feedback when models API fails The component checks 8. Python In 9. The handler ignores 10. The discovery script will add it when the Vertex endpoint responds, but keep the frontend fallback list and Go Positive Highlights
RecommendationsPrioritised action items before promoting from DRAFT:
🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
…l discovery Remove the unused `default` boolean from ModelEntry (defaultModel string is the source of truth). Fix a pre-existing Go slice aliasing bug in models_test.go where mutating a shallow-copied struct's slice corrupted the shared test fixture. Rewrite model-discovery.py to use a curated KNOWN_MODELS list with automatic Vertex AI version resolution via the Model Garden get API, falling back gracefully to the manifest's existing vertexId or @default. Fix model_id_to_label() capitalization bug. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Code ReviewSummaryPR #692 introduces automated model discovery with feature-flag-gated availability. The implementation spans all five components (backend, frontend, operator, runner, CI) and is architecturally coherent. The fail-open fallback strategy for model availability is well thought out. A few security pattern violations, a reactive form bug, and some missing safeguards need attention before this is ready to merge. Issues by Severity🚫 Blocker IssuesNone — the feature is functional, but the critical issues below should be resolved before marking ready for review. 🔴 Critical Issues1.
func loadManifest() (*types.ModelManifest, error) {
if K8sClient == nil { ... }
cm, err := K8sClient.CoreV1().ConfigMaps(Namespace).Get(...) // ← service accountThe documented security rule is unambiguous: "ALWAYS use user-scoped clients for API operations." Even though models.json is global config with no user-specific data, the handler never calls Fix: Either (a) call 2. Form default model is not reactive — API default can be silently ignored
const defaultModel = modelsData?.defaultModel ?? "claude-sonnet-4-5";
const form = useForm({
defaultValues: {
model: defaultModel, // ← evaluated once at mount, before API responds
},
})
Fix: useEffect(() => {
if (modelsData?.defaultModel) {
form.setValue('model', modelsData.defaultModel, { shouldValidate: false });
}
}, [modelsData?.defaultModel]);🟡 Major Issues3. Cache invalidation is too broad — invalidates all projects' model caches
const handleTriggerClick = () => {
queryClient.invalidateQueries({ queryKey: modelKeys.all }); // ← invalidates every project
setOpen(true);
};
Fix: Invalidate only the current project: queryClient.invalidateQueries({ queryKey: modelKeys.list(projectName) });4.
// Model not found in manifest — allow it (may be an older model still in use)
return trueThis means any arbitrary string (e.g. Fix: Return 5.
At moderate load this will produce measurable latency on session creation. A simple TTL cache (30–60 s) would eliminate the cost in the happy path: var (
manifestCache *types.ModelManifest
manifestCacheAt time.Time
manifestTTL = 60 * time.Second
)This is not blocking but will become a problem at scale. 6. GitHub Actions uses action versions that likely do not exist
uses: actions/checkout@v6
uses: actions/setup-python@v6As of the last stable release cycle, uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2🔵 Minor Issues7.
8. Leftover
// Suppress unused import warning for context package
var _ = context.BackgroundThis indicates 9. The function has multiple branches (empty ID, default model, available=false, flag disabled, not found) but is not directly exercised. The 10. The script performs non-trivial logic ( Positive Highlights
RecommendationsPriority order:
🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
No description provided.