Wade111999 on X tested OpenRouter's thinkingmachines/inkling-2-small:free in magpie and got "403 · … is only available on agentic harnesses". OpenRouter serves that free endpoint only to agent apps it lists at openrouter.ai/apps, judged by the app a request is attributed to (its HTTP-Referer; the 403's routing step is "Gate Free Endpoints by Agentic Harness"). Its docs and other clients' real-key reports (Skales #325, OpenTrading #204) say attribution headers of an unlisted app don't pass it, and the paid thinkingmachines/inkling-2-small has no gate. A model test is magpie's own request, so it is refused; magpie never names an app it isn't. Two things magpie did wrong with it: - restAfterMarked read the 403 as the key's: it rested the whole OpenRouter key (Key "openrouter", by backoff), so one agent request for the gated model set every other OpenRouter model aside. It now rests nothing and counts no failure, as a region refusal; a group's next member is still asked (retryable). A key's own 403 still rests the key. - the test showed a bare 403. APIError now puts HarnessOnlyHint after OpenRouter's words: served only to listed agent apps, a magpie test isn't one, the model without :free is served to any request. Not changed: magpie passes the agent's User-Agent to OpenRouter as before, but agents send OpenRouter's attribution headers (HTTP-Referer, X-OpenRouter-Title) only to openrouter.ai itself, so whether OpenRouter serves an agent's request through magpie is not known. Run (mica, mote over its load): - TestHarnessOnlyTestSaysWhy, TestOpenRouterHarnessOnlyRestsNothing: red on origin/main's routing.go and test.go (the key rested {Key:openrouter By:backoff}; the error had no hint), green after. - go test -timeout 45m -count=1 ./internal/provider ./internal/gateway: ok internal/provider 170.7s, ok internal/gateway 1012.0s (mica, ate513cba54+ this diff) Rebased on51eb1ae4b(main's gemini audio change in both packages): go vet of both packages, and the two tests above with -run Gemini|Audio, ok on mica at the pushed head. - go vet, GOOS=linux and GOOS=windows go vet of both packages, gofmt -l: clean. Not tried: a real OpenRouter request; every OpenRouter key on this machine, mote and mica answers 401 "User not found".
47 lines
1.8 KiB
Go
47 lines
1.8 KiB
Go
package provider
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A model test OpenRouter refuses as not from an agent app says why and
|
|
// what to do, not only the 403 (Wade111999 on X), whatever the words are
|
|
// wrapped in, and once.
|
|
func TestHarnessOnlyTestSaysWhy(t *testing.T) {
|
|
const said = "thinkingmachines/inkling-2-small:free is only available on agentic harnesses. Try plugging it into a coding agent or productivity app listed on https://openrouter.ai/apps"
|
|
for _, b := range []string{
|
|
`{"error":{"message":"` + said + `","code":403}}`,
|
|
said,
|
|
} {
|
|
got := APIError([]byte(b), "403 Forbidden")
|
|
if !strings.Contains(got, said) || !strings.HasSuffix(got, " — "+HarnessOnlyHint) {
|
|
t.Fatalf("%s: %q", b, got)
|
|
}
|
|
if again := APIError([]byte(got), "403 Forbidden"); strings.Count(again, HarnessOnlyHint) > 1 {
|
|
t.Fatalf("hint said twice: %q", again)
|
|
}
|
|
if !HarnessOnly([]byte(b)) {
|
|
t.Fatalf("%s not read as the harness gate", b)
|
|
}
|
|
}
|
|
if HarnessOnly([]byte(`{"error":{"message":"Key disabled","code":403}}`)) || strings.Contains(APIError([]byte(`{"error":{"message":"Key disabled","code":403}}`), ""), HarnessOnlyHint) {
|
|
t.Fatal("another 403 read as the harness gate")
|
|
}
|
|
|
|
// the test itself, as the editor's Test models runs it
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(http.StatusForbidden)
|
|
w.Write([]byte(`{"error":{"message":"` + said + `","code":403}}`))
|
|
}))
|
|
defer srv.Close()
|
|
p := Provider{ID: "openrouter", Chat: srv.URL + "/api/v1", Key: "sk-or-v1-test"}
|
|
r := p.TestModels(t.Context(), []string{"thinkingmachines/inkling-2-small:free"})[0]
|
|
if r.OK || r.Status != http.StatusForbidden || !strings.Contains(r.Error, HarnessOnlyHint) {
|
|
t.Fatalf("test result %+v", r)
|
|
}
|
|
}
|