zRain (Discord #feedback, 10-24; magpie 0.1.1377, Windows, Codex CLI 0.164.0) asked clinepass/cline-pass/deepseek-v4.1-flash-1017 from Codex (/backend-api/codex/responses -> /v1/chat/completions, 200). The reply named vmc/deepseek-v4p1-flash-1017-contributor-fallbacks. Routing showed "served vmc/..." titled "likely another model", with no upstream. What was found: - The pin goes out on Codex's Responses path the same as on a Chat client's. The test below checks the sent body on both paths. The built-in ClinePass pins only with "DeepSeek and GLM models only from their makers' own APIs" ticked. The Cline plugin pins Pass DeepSeek by default. zRain's id is the built-in, so with the tick off nothing asked for DeepSeek. - upstreamOf reads finalProvider from choices[].delta/message provider_metadata on every path (Codex streamed, chat streamed, Responses streamed and not). zRain's rows had none, so the reply most likely carried none there. canonicalSlug is not recorded; left alone. - The contributor-fallbacks name is ClinePass's own route. Its name does not mean another model. Change: - provider.ClinePassAsked: the upstream a request asks the Cline API for (ClinePin with the tick, or deepseek on the plugin's provider). - Try.Pin records it on the answering try. - Routing: a cline-pass/ model served as vmc/... is tagged "ClinePass route ...". Its title and story say it is the route's name, not another model's, and then one of: - who answered, when the reply said; - that the asked provider wasn't confirmed; - that nothing was asked, naming the tick for DeepSeek/GLM. - The Usage page's Requests title says the route too, without the pin it doesn't keep. - Strings in zh, zh-TW, ja and de. What was run (rebased on origin/main7edf5b0a3): - TestClinePassAsked (provider) and TestClinePassTryKeepsWhatWasAsked (gateway: chat and responses, tick on/off, sent body and try pin). - Broken by hand: the try literal without Pin, and the tick-on cases go red ("try pin \"\" (want \"deepseek\")"). - go test -count=1 ./internal/provider in a sandbox HOME: ok (280s). - ./internal/gateway -run 'Cline|Upstream|Swap|Served|Try|Trace|Route': ok. - gofmt -l clean; go vet darwin, linux -tags nogui, windows on gateway and provider. - go test -run 'Budget|I18n|Strings|Plugin' ./internal/gui: ok. - GUI: routing-cline-route.test.cjs, new, Chromium+WebKit, en+zh, every string in all 4 languages. Pointed at the old assets (MAGPIE_ROUTE_ASSETS): 4 of 4 red. Now 4 of 4 green. - GUI: every routing-*, usage-* and gui-* file, plus i18n-keys, panel-routing, remote-group-served and session-identity, at concurrency 3, load ~110. Reds: routing-held-dot (WebKit zh 560px, timeout; passes alone at the rebased head) and routing-intent-entry "Add a rule makes a rule by intent" (also red on origin/main117937b8din WebKit alone: #3408). Not tried: - No real ClinePass account. The raw bytes of a contributor-fallbacks reply are unseen, so whether ClinePass puts finalProvider elsewhere for that route is unknown. No parser change was made without them. - Full go test ./... was not run: the machine is at load ~110 with other sessions' suites. - Not run on the Windows box.
69 lines
2.8 KiB
Go
69 lines
2.8 KiB
Go
package gateway
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A ClinePass reply that names a route of its own (vmc/…-contributor-
|
|
// fallbacks) and no provider still leaves its try saying what was asked
|
|
// for, so the Routing page can tell "DeepSeek asked for, not said who
|
|
// answered" from "nothing asked for" (zRain on Discord, 10-24): DeepSeek
|
|
// with the Upstream tick, nothing without it, on a Chat client's path and
|
|
// on the Responses one Codex takes.
|
|
func TestClinePassTryKeepsWhatWasAsked(t *testing.T) {
|
|
for _, path := range []string{"/v1/chat/completions", "/v1/responses"} {
|
|
for _, tick := range []bool{false, true} {
|
|
name := path + "/tick-off"
|
|
want := ""
|
|
if tick {
|
|
name, want = path+"/tick-on", "deepseek"
|
|
}
|
|
t.Run(name, func(t *testing.T) {
|
|
fresh(t)
|
|
var sent string
|
|
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
b, _ := io.ReadAll(r.Body)
|
|
sent = string(b)
|
|
w.Header().Set("Content-Type", "text/event-stream")
|
|
io.WriteString(w, `data: {"id":"g1","object":"chat.completion.chunk","model":"vmc/deepseek-v4p1-flash-1017-contributor-fallbacks","choices":[{"index":0,"delta":{"role":"assistant","content":"hi"}}]}`+"\n\n")
|
|
io.WriteString(w, `data: {"id":"g1","object":"chat.completion.chunk","model":"vmc/deepseek-v4p1-flash-1017-contributor-fallbacks","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":3,"completion_tokens":1,"total_tokens":4}}`+"\n\n")
|
|
io.WriteString(w, "data: [DONE]\n\n")
|
|
}))
|
|
t.Cleanup(up.Close)
|
|
p := provider.Provider{ID: "clinepass", Name: "ClinePass", Preset: "clinepass", Key: "k", Chat: up.URL + "/v1",
|
|
Models: []string{"cline-pass/deepseek-v4.1-flash-1017"}, PinUpstream: tick}
|
|
if err := provider.Save(p); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
body := `{"model":"clinepass/cline-pass/deepseek-v4.1-flash-1017","max_tokens":100,"stream":true,"messages":[{"role":"user","content":"hi"}]}`
|
|
if path == "/v1/responses" {
|
|
body = `{"model":"clinepass/cline-pass/deepseek-v4.1-flash-1017","stream":true,"input":"hi"}`
|
|
}
|
|
s := New()
|
|
rec := httptest.NewRecorder()
|
|
s.Handler().ServeHTTP(rec, httptest.NewRequest("POST", path, strings.NewReader(body)))
|
|
if rec.Code != 200 {
|
|
t.Fatalf("%d %s", rec.Code, rec.Body)
|
|
}
|
|
if pinned := strings.Contains(sent, `"only":["deepseek"]`); pinned != tick {
|
|
t.Errorf("pin sent %v with the tick %v: %s", pinned, tick, sent)
|
|
}
|
|
r := lastRoute(s)
|
|
if len(r.Tries) != 1 {
|
|
t.Fatalf("tries %+v", r.Tries)
|
|
}
|
|
tr := r.Tries[0]
|
|
if tr.Pin != want || tr.Upstream != "" || !strings.HasPrefix(tr.Served, "vmc/") {
|
|
t.Errorf("try pin %q (want %q), upstream %q, served %q", tr.Pin, want, tr.Upstream, tr.Served)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|