cline: the Upstream tick holds Pass DeepSeek on DeepSeek with has, and leaves the plugin's to it

hy125245 (X, 10-23) found that providerOptions.gateway.only ["deepseek"]
alone does nothing on ClinePass: a fake upstream still succeeded. Adding
has ["vision","implicit-caching"] beside it routed the request to
DeepSeek (finalProvider deepseek, ~200-246 tok/s, creditsUsed 0) and made
a fake upstream fail with "no matching upstream".

Changed:
- The built-in ClinePass's Upstream tick now sends, for cline-pass/deepseek*,
  providerOptions.gateway {only:[deepseek], has:[implicit-caching]}, with
  "vision" first when the model takes images (live catalog) or the request
  carries an image part (messages[].content[].type image_url/image/
  input_image; the word in text does not count). GLM, glm-5.3-flash's
  OpenRouter provider.only and the client's own providerOptions/provider are
  as before.
- On the Cline plugin's provider the tick no longer pins cline-pass/deepseek*:
  opencode-cline-auth 0.1.11 pins them itself by default, with the has
  filter and one unpinned retry on "no matching upstream" or a 5xx, and it
  keeps a body's own providerOptions, so magpie's only alone would take its
  place. The plugin's GLM pin from the tick is unchanged.

Run at 03951798a (origin/main) plus this change:
- go build ./..., go vet ./internal/... (darwin), GOOS=linux and
  GOOS=windows go vet ./internal/gateway ./internal/provider, gofmt -l: clean.
- go test -count=1 ./internal/provider: ok (112s).
- go test -count=1 -run 'Cline|Plugin' ./internal/gateway: ok (53s).

Broken by hand, each red:
- the plugin provider pinned again: TestClinePluginPinsDeepSeekAndGLM;
- no has: TestClinePinsDeepSeekAndGLM, all three Pass DeepSeek models;
- vision always: the same test, text-only requests;
- an image found by substring: the "image_url in text" case.

Not run: the full go test ./... suite. The box is at load ~256 with about
ten sessions queued on it, so it went out on the touched packages. Not
tried: a real ClinePass request. There is no Cline sign-in on this
machine, so finalProvider, speed and credits are the reporter's numbers,
not measured here.
This commit is contained in:
yetone
2026-10-23 22:28:52 +08:00
parent 34f9686bd2
commit fa22bc6467
4 changed files with 87 additions and 3 deletions
+23 -2
View File
@@ -14,7 +14,9 @@ import (
// gets providerOptions.gateway.only, which that gateway reads to serve the
// model from that host alone, as ClinePass + ProviderPin set it
// (linux.do/t/topic/2918145); one it sends through OpenRouter gets
// provider.only, OpenRouter's own field (sdytman on Discord). A body
// provider.only, OpenRouter's own field (sdytman on Discord). A ClinePass
// DeepSeek model's carries the gateway's has filter beside only, which
// ClinePass needs for the pin to hold (provider.ClinePassHas). A body
// naming provider or providerOptions itself is left as the client sent
// it. The field goes at the end, so the prefix a cache keys on doesn't
// change.
@@ -31,7 +33,11 @@ func clinePin(p provider.Provider, to provider.Protocol, body []byte) []byte {
if end < 0 || start < 0 || start > end {
return body
}
key, opts := "providerOptions", map[string]any{"gateway": map[string]any{"only": []string{up}}}
gw := map[string]any{"only": []string{up}}
if has := p.ClinePassHas(gjson.GetBytes(body, "model").String(), chatImages(body)); has != nil {
gw["has"] = has
}
key, opts := "providerOptions", map[string]any{"gateway": gw}
if openRouter {
key, opts = "provider", map[string]any{"only": []string{up}}
}
@@ -47,3 +53,18 @@ func clinePin(p provider.Provider, to provider.Protocol, body []byte) []byte {
out = append(out, val...)
return append(out, body[end:]...)
}
// chatImages is whether a Chat body carries an image part
func chatImages(body []byte) bool {
found := false
gjson.GetBytes(body, "messages").ForEach(func(_, m gjson.Result) bool {
m.Get("content").ForEach(func(_, part gjson.Result) bool {
if t := part.Get("type").String(); t == "image_url" || t == "image" || t == "input_image" {
found = true
}
return !found
})
return !found
})
return found
}
+12 -1
View File
@@ -65,12 +65,23 @@ func TestClinePinsDeepSeekAndGLM(t *testing.T) {
chat := func(model, extra string) string {
return ask("/v1/chat/completions", `{"model":"`+model+`","messages":[{"role":"user","content":"Say pong"}]`+extra+`}`)
}
const pinned = `{"gateway":{"only":["deepseek"]}}`
// DeepSeek's only alone left ClinePass free to pick another upstream;
// has ["implicit-caching"] beside it is what held a request on
// DeepSeek (hy125245 on X, 10-23), and "vision" joins it when the
// request carries an image
const pinned = `{"gateway":{"has":["implicit-caching"],"only":["deepseek"]}}`
for _, m := range []string{"cline/cline-pass/deepseek-v4-pro", "cline/cline-pass/deepseek-v4.1-flash", "cline/cline-pass/deepseek-v4.1-flash-1017"} {
if got := chat(m, ""); got != pinned || orPin() != "" {
t.Errorf("%s: providerOptions %s provider %s, want providerOptions %s alone (sent %s)", m, got, orPin(), pinned, sent)
}
}
const seeing = `{"gateway":{"has":["vision","implicit-caching"],"only":["deepseek"]}}`
if got := ask("/v1/chat/completions", `{"model":"cline/cline-pass/deepseek-v4.1-flash","messages":[{"role":"user","content":[{"type":"text","text":"What is this?"},{"type":"image_url","image_url":{"url":"data:image/png;base64,iVBORw0KGgo="}}]}]}`); got != seeing {
t.Errorf("an image: providerOptions %s, want %s", got, seeing)
}
if got := ask("/v1/chat/completions", `{"model":"cline/cline-pass/deepseek-v4.1-flash","messages":[{"role":"user","content":[{"type":"text","text":"Say \"image_url\""}]}]}`); got != pinned {
t.Errorf("the word image_url in text: providerOptions %s, want %s", got, pinned)
}
if got := ask("/v1/messages", `{"model":"cline/cline-pass/deepseek-v4-pro","max_tokens":64,"messages":[{"role":"user","content":"Say pong"}]}`); got != pinned {
t.Errorf("messages: providerOptions %s, want %s", got, pinned)
}
+15
View File
@@ -106,6 +106,21 @@ func TestClinePluginPinsDeepSeekAndGLM(t *testing.T) {
if p, err = provider.Find(pid); err != nil || !p.PinUpstream {
t.Fatalf("the tick wasn't kept: %+v, %v", p, err)
}
// ClinePass's own DeepSeek models the plugin pins itself, with the
// has filter that holds them on DeepSeek and a way back (0.1.11), and
// it keeps a body's own providerOptions: magpie's only alone would
// take the plugin's place, so the tick leaves them to it
for _, m := range []string{"cline-pass/deepseek-v4-pro", "cline-pass/deepseek-v4.1-flash", "cline-pass/deepseek-v4.1-flash-1017"} {
if up, _ := p.ClinePin(m); up != "" {
t.Errorf("%s: magpie pinned it to %q ahead of the plugin", m, up)
}
if has := p.ClinePassHas(m, true); has != nil {
t.Errorf("%s: magpie sent has %v ahead of the plugin", m, has)
}
}
if up, _ := p.ClinePin("cline-pass/glm-5.3"); up != "zai" {
t.Errorf("cline-pass/glm-5.3: pinned to %q, want zai", up)
}
got := ask()
for i, q := range got[:4] {
want := `{"gateway":{"only":["deepseek"]}}`
+37
View File
@@ -207,6 +207,13 @@ func (p Provider) ClinePin(model string) (upstream string, openRouter bool) {
if !p.PinUpstream || !p.ClinePinnable() || strings.HasPrefix(model, clineFreePrefix) {
return "", false
}
// the Cline plugin pins ClinePass's DeepSeek models itself, by default,
// with ClinePassHas's filter and a way back when the pin can't be
// served (opencode-cline-auth 0.1.11). It keeps a body's own
// providerOptions, so magpie's only alone would stand in its place.
if p.PluginProvider() == "cline" && clinePassDeepSeek(model) {
return "", false
}
name := strings.ToLower(model[strings.LastIndex(model, "/")+1:])
for _, m := range clineMakers {
if m.exact && name == m.name || !m.exact && strings.HasPrefix(name, m.name) {
@@ -215,3 +222,33 @@ func (p Provider) ClinePin(model string) (upstream string, openRouter bool) {
}
return "", false
}
// clinePassDeepSeek is a ClinePass DeepSeek model: cline-pass/deepseek-…
func clinePassDeepSeek(model string) bool {
return strings.HasPrefix(strings.ToLower(model), "cline-pass/deepseek")
}
// ClinePassHas is the capability filter (providerOptions.gateway.has) a
// pinned request for model carries beside only, or nil. On ClinePass the
// server's own routing for a DeepSeek model wins over only alone, and a
// fake upstream in only was served all the same; with has beside it the
// request went to DeepSeek and a fake upstream was refused "no matching
// upstream" (hy125245 on X, 10-23). The upstream must cache a repeated
// prefix by itself, and, for a model that takes images (images: the
// fetched list says so, or the request carries one), take them: a
// text-only model asked "vision" (deepseek-v4-pro) would have no upstream
// left. The Cline plugin's provider has none here: the plugin writes it.
func (p Provider) ClinePassHas(model string, images bool) []string {
if up, _ := p.ClinePin(model); up == "" || !clinePassDeepSeek(model) {
return nil
}
if !images {
if ms := p.liveByID(model); len(ms) > 0 {
images = ms[0].Images
}
}
if images {
return []string{"vision", "implicit-caching"}
}
return []string{"implicit-caching"}
}