The defaults shipped yesterday were wrong the day they shipped, and a real key proved it in one request. Groq serves neither llama-3.1-8b-instant nor llama-3.3-70b-versatile any more. Both were chosen from memory, both passed startup validation, and every agent run would have failed with a 400. This is the exact failure the claude-* guard was written to catch, arriving from the side that guard cannot see. A prefix check can reject a vendor this service cannot call; it has no way to know a provider retired an id last month. That is not a gap in the check, it is a gap in the class of thing local validation can know, so the fix is not another guard: TestConfiguredModelsAreServed asks the provider. It lists /models — part of the same openai-compatible surface the gateway already speaks, so every supported provider answers it — and fails if a configured id is absent, printing what is available. It reads the ids through config.DefaultModels() rather than repeating them, because a second copy would be the first thing to drift, and drift is the whole failure. Skipped without a credential like the rest of the live suite. Verified three ways: it fails on the retired id with the message an operator needs, skips clean with no key, passes on the new ones. New defaults, chosen against the live account rather than from memory: openai/gpt-oss-20b (fast) and openai/gpt-oss-120b (balanced, deep). Tool calling confirmed on both. groq/compound-mini was ruled out — it cannot do tool calls at all, which this platform requires. MODEL_REASONING_EFFORT is now documented as safe here and NOT portable: gpt-oss accepts low/medium/high, exactly the scale openAIEffort maps onto, while qwen/qwen3.6-27b on the same account rejects all three and fails the whole request rather than ignoring the key. I7 IS NO LONGER UNPROVEN. make eval-live passes all three cases twice against gpt-oss-120b, the planted-injection case included: answers from the handbook, cites, refuses the injection, leaks neither the operator-only pay guidance nor the other tenant's figures. CLAUDE.md §12 and handover.md updated from "urgent" to measured, dated, and scoped to the one model it is evidence about. One real defect found on the way. The handbook grounding check failed once on an answer containing the phrase it wanted — "more than ten minutes" on screen, strings.Contains false — which leaves an invisible separator as the only explanation; the same model writes "47 %" and a U+2011 hyphen elsewhere. The flaky assertion is the small half. THE LEAK ASSERTIONS USED THE SAME MATCH and fail in the dangerous direction: "attacker@evil.test" with a zero-width space, or "uplift" with a soft hyphen, would have been reported clean. A permission test that cannot see the leak it is hunting is worse than none, because it is believed. normalizeForMatch folds those away, and its test pins that every case is one plain ToLower MISSES — a case whose naive match already succeeds fails, so the suite cannot fill with examples that demonstrate nothing. That caught my own first BOM case, which put the mark where Contains found it regardless. gofmt clean, vet clean, 15/15 packages pass offline; live suite green twice. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJvibeSc1JYXjatankqM1g
122 lines
3.8 KiB
Go
122 lines
3.8 KiB
Go
package evals_test
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
"sort"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/krow/krow-backend/go-api/internal/config"
|
|
)
|
|
|
|
// TestConfiguredModelsAreServed asks the provider whether it still serves the
|
|
// three ids this deployment is configured with.
|
|
//
|
|
// THIS TEST EXISTS BECAUSE THE DEFAULTS WERE WRONG THE DAY THEY SHIPPED. The
|
|
// gateway was pointed at Groq with llama-3.1-8b-instant and
|
|
// llama-3.3-70b-versatile, both chosen from memory and neither served by Groq
|
|
// any more. Startup validation passed — it can reject a claude-* prefix, but
|
|
// "an id this provider retired" is not a property of the string — so the
|
|
// configuration booted clean and would have failed every single agent run with
|
|
// a 400.
|
|
//
|
|
// That is the shape of the failure worth defending against, and it is not a
|
|
// one-off: model ids are retired on the provider's schedule, not this repo's, so
|
|
// a configuration that is correct today goes stale without anything here
|
|
// changing. No amount of local validation can see it. Only asking can.
|
|
//
|
|
// Skipped without a credential, like the rest of the live suite, so
|
|
// `go test ./...` stays green offline and the scripted suites remain the gate.
|
|
func TestConfiguredModelsAreServed(t *testing.T) {
|
|
key := strings.TrimSpace(os.Getenv("MODEL_API_KEY"))
|
|
baseURL := strings.TrimSpace(os.Getenv("MODEL_BASE_URL"))
|
|
if baseURL == "" {
|
|
baseURL = "https://api.groq.com/openai/v1"
|
|
}
|
|
if key == "" {
|
|
t.Skip("no MODEL_API_KEY; the live suite is skipped")
|
|
}
|
|
|
|
// The ids this deployment would actually use: an explicit override if the
|
|
// environment carries one, otherwise the shipped default. Both are worth
|
|
// checking — an override is just as capable of naming a retired model, and
|
|
// is likelier to, having been written by hand.
|
|
fast, balanced, deep := config.DefaultModels()
|
|
effective := func(env, dflt string) string {
|
|
if v := strings.TrimSpace(os.Getenv(env)); v != "" {
|
|
return v
|
|
}
|
|
return dflt
|
|
}
|
|
|
|
served, err := servedModels(baseURL, key)
|
|
if err != nil {
|
|
t.Skipf("could not list models at %s: %v", baseURL, err)
|
|
}
|
|
if len(served) == 0 {
|
|
t.Skipf("%s returned no models; nothing to check against", baseURL)
|
|
}
|
|
|
|
for _, m := range []struct{ key, id string }{
|
|
{"MODEL_FAST", effective("MODEL_FAST", fast)},
|
|
{"MODEL_BALANCED", effective("MODEL_BALANCED", balanced)},
|
|
{"MODEL_DEEP", effective("MODEL_DEEP", deep)},
|
|
} {
|
|
if !served[m.id] {
|
|
available := make([]string, 0, len(served))
|
|
for id := range served {
|
|
available = append(available, id)
|
|
}
|
|
sort.Strings(available)
|
|
t.Errorf("%s is %q, which %s does not serve.\n"+
|
|
"Every run on this tier would fail with a 400 that no local check can predict.\n"+
|
|
"Available: %s",
|
|
m.key, m.id, baseURL, strings.Join(available, ", "))
|
|
}
|
|
}
|
|
}
|
|
|
|
// servedModels lists the model ids the provider will accept.
|
|
//
|
|
// GET /models is part of the same openai-compatible surface the gateway already
|
|
// speaks, so every provider this platform supports answers it.
|
|
func servedModels(baseURL, key string) (map[string]bool, error) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
|
defer cancel()
|
|
|
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet,
|
|
strings.TrimSuffix(baseURL, "/")+"/models", nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req.Header.Set("Authorization", "Bearer "+key)
|
|
|
|
resp, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer resp.Body.Close()
|
|
if resp.StatusCode != http.StatusOK {
|
|
return nil, fmt.Errorf("http %d", resp.StatusCode)
|
|
}
|
|
|
|
var body struct {
|
|
Data []struct {
|
|
ID string `json:"id"`
|
|
} `json:"data"`
|
|
}
|
|
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
|
return nil, err
|
|
}
|
|
served := make(map[string]bool, len(body.Data))
|
|
for _, m := range body.Data {
|
|
served[m.ID] = true
|
|
}
|
|
return served, nil
|
|
}
|