tim's first "who are you" to gemini-3.8 through the third-party plugin
magpie-gemini-web 0.8.0 took minutes in dsh and ended in 499 ("the agent
canceled the request"). dsh hung up: llm-pi-ai gives a turn up after 5
minutes with no pi-ai event (DEFAULT_STREAM_IDLE_TIMEOUT_MS, every
dsh-llm-pi-ai from 0.1.5 to 0.2.2), and the gateway's ": keepalive"
comments (keepQueued, keepQuiet) are not events. The plugin serves one
request at a time (maxConcurrency 1), dsh's own session title goes to the
same route model in parallel, and the plugin's backend sends no byte
before its first token, so the turn's 5 minutes ran out in magpie's queue
and the backend while the gateway (10 minutes for headers) and the plugin
(240s per wait, then its own 504) were still waiting.
Every one of magpie's dsh routes (patch lists and deepseek-acp's
settings.yaml, all through dshPutProviders) now has streamIdleTimeoutMs:
600000 (dshIdleWait), the gateway's upstreamHeaderWait. A value already on
the route, set in dsh's Models page or by hand, stays. Codex's
comment-blind limit is still met in the gateway (agentQuietMost); dsh's is
a route setting. The plugin's own slowness is its maintainer's and is not
changed here.
Verified:
- New tests TestDshRoutesWaitAsLongAsTheGateway and
TestDshRouteKeepsTheUsersIdleWait (internal/agent/dsh_idle_test.go),
green on mote. Broken by hand: without the field the first fails
("route magpie waits 0ms for the next event, want 600000"); without the
keep the second fails ("sync 1: the user's 120000 became 600000").
- Real dsh 0.2.1-rc.2 (headless, sandbox HOME/DSH_HOME, the route as
magpie writes it, a fake Chat server on 127.0.0.1:3561 that answers
after 8s): streamIdleTimeoutMs 3000 -> "TIMEOUT: pi-ai stream idle
timeout after 3000ms"; 600000 -> "hello there", exit 0. With headers
sent at once and ": keepalive" every second it still timed out at 3000,
so comments don't feed the watchdog. dsh-llm-pi-ai 0.1.5-rc.3,
0.1.7-rc.2, 0.2.0-rc.2 and 0.2.1-rc.5 (npm pack, read) all take the
field per provider, max MAX_TIMER_DELAY_MS.
- gofmt -l clean. On mote: go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./..., go build, GOOS=linux go build -tags
nogui, GOOS=windows go build: all ok.
- Full suite, go test -tags nogui -count=1 -timeout 45m ./..., on the
Linux box (wsl-run, magpie-desktop; mote had two full suites running)
at d714c4216 + this change: 83 packages ok; internal/agent red on
TestInstalledVersion, TestGrokInstalled,
TestCursorFolderFromTheEditorIsNotTheCLI, TestOmpDetectedWithPiDir
(#4033, #3548) and internal/gui on TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestColdTurnsTaken (#4510). The first five fail the same
on origin/main 15066f84f run alone there; TestColdTurnsTaken passed
alone on main and failed alone with this change (5 counts, gui only,
which this change doesn't touch), as #4510 describes.
- After rebasing on 2597c9636, internal/agent again on the Linux box: the
new tests pass; reds TestInstalledVersion, TestGrokInstalled,
TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI/qoder-cn,
TestOmpDetectedWithPiDir, all the #4033 class (Qoder noted there).
Not tried: tim's own setup (the plugin is not run against a Google
account); a real 5-to-10-minute wait in dsh; Windows.
110 lines
3.4 KiB
Go
110 lines
3.4 KiB
Go
package agent
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
// dshRouteIdle is streamIdleTimeoutMs of each of magpie's routes in a
|
|
// llm-pi-ai providers mapping at path (a patch list's entry, or
|
|
// settings.yaml's section), 0 for a route without one.
|
|
func dshRouteIdle(t *testing.T, path string, list bool) map[string]int {
|
|
t.Helper()
|
|
b, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
type route struct {
|
|
Idle int `yaml:"streamIdleTimeoutMs"`
|
|
}
|
|
var providers map[string]route
|
|
if list {
|
|
var items []struct {
|
|
ID string `yaml:"id"`
|
|
Config struct {
|
|
Providers map[string]route `yaml:"providers"`
|
|
} `yaml:"config"`
|
|
}
|
|
if err := yaml.Unmarshal(b, &items); err != nil {
|
|
t.Fatalf("%v:\n%s", err, b)
|
|
}
|
|
for _, it := range items {
|
|
if it.ID == dshPiRow {
|
|
providers = it.Config.Providers
|
|
}
|
|
}
|
|
} else {
|
|
var doc map[string]struct {
|
|
Providers map[string]route `yaml:"providers"`
|
|
}
|
|
if err := yaml.Unmarshal(b, &doc); err != nil {
|
|
t.Fatalf("%v:\n%s", err, b)
|
|
}
|
|
providers = doc[dshPiRow].Providers
|
|
}
|
|
out := map[string]int{}
|
|
for k, r := range providers {
|
|
if isDshRoute(k) {
|
|
out[k] = r.Idle
|
|
}
|
|
}
|
|
if len(out) == 0 {
|
|
t.Fatalf("no route of magpie's in %s:\n%s", path, b)
|
|
}
|
|
return out
|
|
}
|
|
|
|
// tim on Discord: a first "who are you" to Gemini through the
|
|
// magpie-gemini-web plugin took minutes in dsh and ended in 499.
|
|
// llm-pi-ai gives a turn up after 5 minutes with no pi-ai event, and the
|
|
// gateway's keepalive comments aren't events: a turn queued behind dsh's
|
|
// own title request on a plugin serving one request at a time was cut
|
|
// while the gateway (10 minutes for headers) and the plugin still waited.
|
|
// magpie's routes, in every profile and in deepseek-acp's settings.yaml,
|
|
// now wait as long as the gateway does.
|
|
func TestDshRoutesWaitAsLongAsTheGateway(t *testing.T) {
|
|
home, dir, web := dshRouteHome(t)
|
|
os.WriteFile(web, []byte("# Your patch layer for this dsh profile.\n"), 0o644)
|
|
a := dsh(home)
|
|
if err := a.Pick("model", "magpie/deepseek/pro"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, f := range []struct {
|
|
path string
|
|
list bool
|
|
}{{web, true}, {filepath.Join(dir, "settings.yaml"), false}} {
|
|
for k, ms := range dshRouteIdle(t, f.path, f.list) {
|
|
if ms != dshIdleWait {
|
|
t.Fatalf("%s: route %s waits %dms for the next event, want %d", f.path, k, ms, dshIdleWait)
|
|
}
|
|
}
|
|
}
|
|
if dshIdleWait != 10*60*1000 {
|
|
t.Fatalf("dshIdleWait %d is not the gateway's 10 minutes for a reply's headers", dshIdleWait)
|
|
}
|
|
}
|
|
|
|
// A wait set on magpie's route in dsh (or by hand), shorter or longer, is
|
|
// the user's: a sync keeps it.
|
|
func TestDshRouteKeepsTheUsersIdleWait(t *testing.T) {
|
|
home, dir, web := dshRouteHome(t)
|
|
dshKeyFixture(dir)
|
|
os.WriteFile(web, []byte("# Your patch layer for this dsh profile.\n"+
|
|
"- id: llm-pi-ai\n name: \"@deepseek-ai/dsh-llm-pi-ai\"\n config:\n providers:\n"+
|
|
" magpie:\n displayName: Magpie\n apiKeyEnv: "+dshKeyRef+"\n api: openai-completions\n baseURL: "+gatewayV1()+"\n streamIdleTimeoutMs: 120000\n models:\n - id: deepseek/pro\n"+
|
|
"- id: agent-default-model\n config:\n provider: magpie\n model: deepseek/pro\n"), 0o644)
|
|
a := dsh(home)
|
|
for i := 0; i < 2; i++ {
|
|
if err := a.Sync(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := dshRouteIdle(t, web, true)[dshRoute]; got != 120000 {
|
|
b, _ := os.ReadFile(web)
|
|
t.Fatalf("sync %d: the user's 120000 became %d:\n%s", i+1, got, b)
|
|
}
|
|
}
|
|
}
|