Commit Graph
8 Commits
Author SHA1 Message Date
yetone c752082e47 gateway: a turn's thinking goes back to Qoder's plugin; qoder min 0.2.42
uk.jent on Discord: Qoder dropped the model's earlier thinking. Qoder.app's
own client sends reasoning_content on every earlier assistant turn, and the
Qoder plugin left it out from its first version on; 0.2.42 sends it.
An Anthropic- or Responses-speaking agent's thinking reached the plugin
only when chatReplaysReasoning held, so qoder and qoder-cn are added
beside Command Code's plugin; a tool turn with no thinking gets the same
" " DeepSeek gets, which 0.2.42 reads as none. The qoder mover min is
0.2.42 (npm view --prefer-online: 0.2.42).

Run (mote): go build ./..., go vet -tags nogui on gateway and provider,
go test -tags nogui -timeout 45m ./internal/gateway/ (ok, 535s) and
./internal/provider/, which crashes in TestUnreadLoginsWriteErrorsKeepCredentials
on "close of synctest channel from outside bubble", #3632, open and not
this change. TestPluginStreamsPastTheBudgetWait, run alone, was red 2 of
3 with this change and 3 of 4 on clean dc1af8231 (connection reset by
peer, #3946). Real account, plugin side: DeepSeek-V4-Pro on Qoder recalls
a codeword its thinking before a tool call named with 0.2.42, not 0.2.41.

Broken by hand: TestCommandCodePluginReasoning with qoder and qoder-cn
added is red on the old chatReplaysReasoning (no reasoning_content).

Not tried: a Claude Code session through magpie onto Qoder end to end;
Qoder CN.
2026-10-28 04:32:30 +08:00
yetone 3dc25a6168 tests: a plugin fake's vendor counts only its own test's requests (#3357)
Run 39913278700 at 65e80405b (ubuntu, Race): TestClinePluginPinsDeepSeekAndGLM
"the plugin sent 7 requests" for 6 asks, in 0.33s. #3347 was the same
class: TestPluginToldWhereTheAgentWorks got 2 for 1, in 0.66s.

Cause, as far as it is known. The extra request did not come from the
test's own route:
- not a gateway retry: retryPause is 1s, so a retried ask can't finish
  in 0.33s or 0.66s. #3347's "a first try failed with a 5xx and was
  retried" doesn't fit either run's time;
- not the plugin host: the gateway reaches the host over stdio JSON-RPC
  (no HTTP retry), and host.js fetchAs calls the loader's fetch once;
- a never-reset log of every request the cline test's vendor got showed
  exactly 12 (6 asks x 2 runs), all POST /v1/chat/completions from
  magpie/dev, with nothing in the background.
So the seventh came from outside the test. The likely sender is a late
request from another test, in this shard or another of race-shards.sh's
four processes, reaching a port the kernel handed to this test's
httptest server (the class d0ccbbebc met with a freed port). Which test
sent it is still unknown.

Fix the class: testenv.FakeVendor(t, h) serves a fake plugin's vendor
at $FAKE_BASE and sets $FAKE_RUN to a nonce made for the test. The fake,
renew and renewrace plugins send it as X-Fake-Run. A request without it
gets 421 and is logged with its method, URI, remote address, User-Agent,
Authorization and size, so the next one on CI names its sender. Every
gateway and plugin test that served the fake's vendor with
httptest.NewServer plus FAKE_BASE now uses it (10 gateway, 5 plugin
files). The cline test now counts against the asks' recorded tries, as
65e80405b did for the workdir test: it fails on a real duplicate and
logs each retry's status. No exactly-once guarantee was loosened.

Reproduction by injection, at be002aca0:
- a request to FAKE_BASE from outside the route, with the filter off:
  "the plugin sent 7 requests for 6 asks tried 6 times" (the CI shape);
  with it on, the test passes and logs the 421 line;
- the fake plugin fetching twice for glm-5.3 (a real duplicate) still
  fails: "sent 8 ... tried 6". Both breaks were restored.

Ran at be002aca0 (macOS, -tags nogui):
- gofmt -l clean; go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows ok;
- internal/plugin -race -count=20 ok (157.5s);
- the edited gateway files' tests -race -count=20 ok (93.1s);
Rebased on c8c6e7e23 (it brings TestPluginThinkingOff, on besideFake),
and ran there: gofmt -l clean; vet of the three packages for darwin,
linux nogui and windows ok; TestPluginThinkingOff, the cline and the
workdir tests -race -count=20 ok (18.3s); internal/gateway (363.6s),
internal/plugin (83.9s) and internal/testenv -timeout 45m ok, with no
421 line logged;
- a Linux container run of gateway.race in four shards like CI's,
  -test.v: ok, and no stray was seen.

Not tried: the stray was never caught in the act, here or in the
container, so the sender is a hypothesis. The count=20 run over all 142
besideFake tests hit 45m in TestPluginStreamLargeReplies (sizing, no
FAIL) and was narrowed to the edited files. No product code changed, so
the full ./... suite was not run.
2026-10-23 16:57:33 +08:00
yetone 686e8a93ac gateway: a moved subscription's failed tool result reaches its plugin marked
A moved Devin or Qoder got a failed tool result as plain text: the
built-in wrote "Error: " before it (devin.go, qoder.go), and buildChat sent
no mark at all. The chat request to those plugins now says it in the text
(failedAsText), and Cursor's carries is_error, which cursor 0.2.18 reads as
the built-in told Cursor isError. buildHost names a moved subscription by
its plugin, so the request is built for the plugin's protocol, not the
built-in's.

TestPluginToolFailureSaid and TestMovedBuildHostIsPlugin go red without
the change.

Run at 63be47717 with this batch: go test -tags nogui ./... -count=1 -timeout 90m, 66 packages ok, no FAIL (load ~250). gofmt -l clean; GOOS=linux and GOOS=windows go vet of provider, gateway and plugin pass.
2026-10-16 19:37:59 +08:00
yetone 2da8fbe488 tests: every test that runs plugins on the bun on PATH runs it once first, through testenv.Bun, so a bun that has never run here doesn't time out internal/provider's and internal/plugin's plugin tests (#1306)
65dcc573 (ggbdpq's patch 1) warmed the bun on PATH before the root
package's one-minute plugin contexts. The same lookup of the bun on PATH
is in 40 more places in internal/provider (28), internal/gateway (8),
internal/plugin (3) and internal/gui (1), and in the root package's
TestPluginListSaysClash. Many of them then open a one- or two-minute
context (internal/provider's sign-in, fetch and move tests,
internal/plugin's sandbox), and there macOS's first-exec check of a
just-installed or upgraded bun landed inside the deadline. The rest
are covered the same way, so no test has to remember which is which.

testenv.Bun now does what the root package's pathBun did: it finds the
bun on PATH (skipping the test when there is none) and runs
`bun --version` before the test opens its context, once per bun per test
binary. pathBun is gone; every `exec.LookPath("bun")` + skip block in
the tests uses testenv.Bun instead. Three tests reach for the bun some
other way and are left as they were: TestHostRunsAsMagpieBun (7ddea2c2
covers its copy), the plugin_git test's realBun and netproxy's
TestBunThroughBridge, none of which runs the plugin host under a
deadline on the PATH bun. migrate_test.go needed two `err` declarations
that the removed block used to provide.

What was run (macOS arm64, bun 1.4.2), with a wrapper bun first on PATH
whose first exec sleeps 61s (marker-gated, then execs the real bun):
- Red, old code:
  - internal/provider TestPluginSignInTakesAPastedCallback: FAIL at
    61.1s, "pluginsignin_paste_test.go:36: starting plugins: context
    deadline exceeded".
  - internal/plugin TestFakePlugin: FAIL at 62.0s, "plugin_test.go:66:
    Plugins = [], starting plugins: context deadline exceeded".
  - internal/gateway TestPluginFailover passed on the old code too (its
    calls have no deadline that short), so the gateway is not shown red.
- Green, this change, same cold wrapper: the three tests passed (61.1s,
  62.9s, 61.2s).
- go test -tags nogui -count=1 for the root package and for
  internal/testenv, gateway, gui, plugin and provider, under a temp HOME
  with GOMODCACHE, GOCACHE and GOPATH pinned: all ok.
- gofmt -l on the changed files: clean. go vet of those packages for
  darwin (-tags nogui), GOOS=linux and GOOS=windows (-tags nogui), and
  GOOS=windows without the tag: clean.

Not run: a really cold bun on a loaded machine; the sleep stands in for
the check. Not run on Linux or Windows, where the warm-up is one extra
`bun --version` per test binary.
2026-10-10 10:22:59 +08:00
yetone 14e80e3155 gateway: the trace tells a moved provider's account as its provider's — a plugin's account went out with agent "plugin", so a moved Grok's plan read as "signed in" rather than as the built-in's. It now carries the provider's id. TestTraceNamesMovedAccount fails without the change. 2026-10-01 03:42:07 +08:00
yetone db024bcd50 gateway: a Command Code Go conversation moved onto its plugin keeps its reasoning — the built-in replayed each assistant turn's reasoning to /alpha/generate, and the chat request built for the plugin carried reasoning_content only to DeepSeek, so the plugin, which reads it, had none to replay. Command Code's plugin gets it too. TestCommandCodePluginReasoning fails without the change. 2026-10-01 03:41:45 +08:00
yetone 4157b279f9 gateway: Cursor moved onto its plugin is told fast mode, as the built-in told Cursor — the chat request built for a plugin never carried service_tier, and Cursor's plugin reads fast mode there, so a fast request went at the normal tier. A fast chat request to Cursor's plugin says service_tier "priority"; no other chat upstream is told it. TestCursorPluginFast fails without the change. 2026-10-01 03:41:45 +08:00
yetone c1d86e2ed1 gateway: a moved provider counts a prompt's tokens by estimate, as its built-in did — count_tokens estimated for Cursor, Grok, Devin, Kiro, Qoder, Zed, Factory and a Command Code Go key by their agent, which a moved one's is "plugin", so the count went to the vendor through the plugin (Factory's to its API). A plugin's provider moved from one of them estimates; Command Code's whatever its plan, as only the plugin knows a Go key. The fake plugin takes $FAKE_ID to stand as a built-in's. TestMovedCountTokensEstimated fails without the change. 2026-10-01 03:41:45 +08:00