Files
magpie/internal/provider/cline_asked_test.go
T
yetone c819e00c4e routing: a ClinePass route reads as its route, with what was asked for (zRain)
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/main 7edf5b0a3):
- 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/main 117937b8d
  in 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.
2026-10-24 19:21:02 +08:00

38 lines
1.3 KiB
Go

package provider
import (
"testing"
"github.com/yetone/magpie/internal/plugin"
)
// ClinePassAsked says what a ClinePass DeepSeek request asks the Cline API
// for (zRain on Discord, 10-24): the built-in ClinePass only with the
// Upstream tick, the Cline plugin's provider by default (the plugin pins
// it itself), and nothing for a model with no maker to pin to.
func TestClinePassAsked(t *testing.T) {
const ds = "cline-pass/deepseek-v4.1-flash-1017"
builtin := Provider{ID: "clinepass", Preset: "clinepass"}
ticked := builtin
ticked.PinUpstream = true
plug := Provider{ID: "cline", Account: &Account{plugin: &plugin.Provider{ID: "cline"}}}
other := Provider{ID: "grok", Account: &Account{plugin: &plugin.Provider{ID: "grok"}}}
for _, c := range []struct {
name string
p Provider
model string
want string
}{
{"built-in, tick off", builtin, ds, ""},
{"built-in, tick on", ticked, ds, "deepseek"},
{"built-in, tick on, GLM", ticked, "cline-pass/glm-5.3", "zai"},
{"plugin by default", plug, ds, "deepseek"},
{"plugin, a model it doesn't pin", plug, "cline-pass/kimi-k3", ""},
{"another plugin", other, ds, ""},
} {
if got := c.p.ClinePassAsked(c.model); got != c.want {
t.Errorf("%s: ClinePassAsked(%s) = %q; want %q", c.name, c.model, got, c.want)
}
}
}