kiro: the mover installs 0.1.24, which says a too-long conversation as one

ergou0954_54426 on Discord routes by intent across Kiro's Claude and GPT
models and DeepSeek, and sometimes a turn failed with Kiro saying the
context was exceeded. Kiro says a conversation is past the model's window
in three ways, and the plugin up to 0.1.23 turned only the HTTP 400 into
the "input is too long for the model's context" that the gateway reads as
an overflow (tooLong). The same ValidationException as an exception in
Kiro's event stream came out as a 502, so the gateway took it for a
passing vendor fault: it rested the account, asked Kiro again (15 asks
for a lone provider in a probe), and never told the agent
context_length_exceeded, so the agent never compacted. A reply Kiro
stopped with MODEL_CONTEXT_WINDOW_EXCEEDED came out as finished.
plugins e8050e8 (kiro 0.1.24, on npm) answers both as the 400 that says
too long. Routing was already right: roomy skips a member whose known
window the request is past, and withRoom moves an overflow to a member
with room.

The min goes to 0.1.24 so keepMovedCurrent updates every moved user.
TestKiroMoverHasTheTooLongFix holds it there.
TestKiroPluginOverflowGoesToAMemberWithRoom pins what the gateway does with
0.1.24's two wordings: in a group the other member answers, the try is
failOverflow with no rest, and alone the agent gets context_length_exceeded
after a single ask.

Run on mote: go vet ./internal/provider ./internal/gateway; go test
-timeout 45m -count=1 ./internal/provider (ok 150s) ./internal/gateway
(ok 712s). gofmt -l clean. Broken by hand: at origin/main's min 0.1.23,
TestKiroMoverHasTheTooLongFix fails. A probe with 0.1.23's 502 body
showed Fail other, a rest, and a vendor 502 for the lone provider.
Not run: the full ./... suite (another session's full suite held mote),
and a real Kiro account pushed past its window.
This commit is contained in:
yetone
2026-11-01 11:30:12 +08:00
parent 4794767846
commit 0c31638045
3 changed files with 71 additions and 1 deletions
+52
View File
@@ -0,0 +1,52 @@
package gateway
import (
"strings"
"testing"
"github.com/yetone/magpie/internal/provider"
)
// What the Kiro plugin answers from 0.1.24 for a conversation past the
// model's window, each way Kiro says it (an exception in its event stream,
// a reply stopped with MODEL_CONTEXT_WINDOW_EXCEEDED), is read as an
// overflow: another member with room answers, the Kiro account doesn't
// rest and isn't asked again, and with no member left the agent is told
// context_length_exceeded, so it compacts (ergou0954_54426 on Discord:
// Kiro's models beside DeepSeek in intent routing, "kiro 那边报错说超出上下文").
// Before 0.1.24 the stream's exception was a 502 the gateway took for a
// passing vendor fault (TestKiroMoverHasTheTooLongFix holds the min).
// The member ids are neutral: kiro is a retired built-in the gateway hands
// to the plugin host.
func TestKiroPluginOverflowGoesToAMemberWithRoom(t *testing.T) {
for _, msg := range []string{
"input is too long for the model's context: ValidationException: Input is too long. (CONTENT_LENGTH_EXCEEDS_THRESHOLD)",
"input is too long for the model's context: the reply stopped as the model's context window was full (MODEL_CONTEXT_WINDOW_EXCEEDED)",
} {
fresh(t)
over := `{"type":"error","error":{"type":"invalid_request_error","message":"` + msg + `"}}`
kiro := &scripted{replies: []reply{{400, "application/json", over}}}
other := &scripted{replies: []reply{{200, "", chatOK}}}
scriptedOn(t, "k", provider.Chat, kiro)
scriptedOn(t, "d", provider.Chat, other)
if err := provider.SaveGroup(provider.Group{Name: "G", Members: []string{"k/m", "d/m"}, Routing: provider.Ordered}); err != nil {
t.Fatal(err)
}
s := New()
code, body := postAs(t, s, "", `{"model":"group/g","messages":[{"role":"user","content":"hi"}]}`)
if code != 200 || !strings.Contains(body, "hello") || kiro.n != 1 || other.n != 1 {
t.Fatalf("%s\ngroup: %d %s (kiro %d, other %d)", msg, code, body, kiro.n, other.n)
}
r := s.trace.routes[len(s.trace.routes)-1]
if len(r.Tries) != 2 || r.Tries[0].Fail != failOverflow || r.Tries[0].Rest != nil {
t.Fatalf("%s\ntries %+v", msg, r.Tries)
}
// alone, the agent is told it overflowed, asked once
kiro.n = 0
code, body = postAs(t, s, "", `{"model":"k/m","messages":[{"role":"user","content":"hi"}]}`)
if code != 400 || !strings.Contains(body, "context_length_exceeded") || kiro.n != 1 {
t.Fatalf("%s\nalone: %d %s (kiro %d)", msg, code, body, kiro.n)
}
}
}
@@ -0,0 +1,18 @@
package provider
import (
"testing"
"github.com/yetone/magpie/internal/update"
)
// Kiro's plugin before 0.1.24 answered a too-long conversation that Kiro
// said in its event stream with a 502, and a reply Kiro stopped for a
// full window as a finished one, so magpie never read either as an
// overflow (TestKiroPluginOverflowGoesToAMemberWithRoom in the gateway).
// The mover keeps every moved user on a version that says it.
func TestKiroMoverHasTheTooLongFix(t *testing.T) {
if update.Newer("0.1.24", movers["kiro"].min) {
t.Fatalf("the Kiro mover installs opencode-kiro-auth %s, which answers Kiro's too-long stream with a 502", movers["kiro"].min)
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ import (
func init() {
movers["kiro"] = &mover{
pkg: "@magpie-community/opencode-kiro-auth",
min: "0.1.23", // 0.1.23: thinking is asked for only when the request's thinking is enabled or adaptive; an effort with none, or with thinking disabled (Claude Code's title requests, a turn with thinking off), is sent no budget and no adaptive fields at any level (plugins#538, zengxiaosong); 0.1.22: a model whose Kiro catalog lists effort levels with adaptive thinking is sent the level as Kiro IDE sends it (additionalModelRequestFields), so xhigh and max stay apart, and a system message ending the conversation (Claude Code's environment context) goes as a turn before the question, not into it (plugins#538, zengxiaosong); 0.1.21: the browser sign-in asks first for AWS Builder ID, IAM Identity Center (Start URL and region) or Kiro's page; the AWS ways open AWS directly, so a magpie on a server or in Docker takes one pasted callback address instead of two, and a sign-in left behind frees its port when the next starts (plugins#507, SemonCat); 0.1.20: a tool whose input_schema has no root type reaches Kiro as an object, and a client's web_search server tool runs as Kiro's own search, at most 10 a request (plugins#492, SemonCat); 0.1.19: a usage read whose sign-in Kiro refused marks the account signed out, so its rows offer Sign in again, and a clean read takes the mark off (blue12345655 on Discord); 0.1.18: an image over Kiro's 5 MiB Base64 limit (a 4.2 MB view_image PNG is 5.6 MB as Base64) is shrunk on the request, or replaced by a note, so the conversation isn't stuck on IMAGE_SIZE_EXCEEDED (plugins#428); 0.1.17: the Free trial and Credits windows carry their credits used and the limit, so the card's Left shows the credits left (plugins#408); a reply with no token counts says its cache is unknown (magpie_cache_unknown), not 0: Kiro caches but counts no tokens (zeewell on X); 0.1.15: an API key is used as kiro-cli uses it: GetProfile in us-east-1 then eu-central-1, and with no profile found the key goes on in us-east-1; its models are the control plane's ListAvailableModels and no profile is named in its calls (Hollowhere: Auto alone, every request "Kiro didn't take the API key: 400"); 0.1.14: each account is named by its email and the way it was signed in to, "email (Google)", "email (GitHub)", not "email (slot)" (plugins#309); 0.1.13: two sign-ins of one email through different login providers (Google, GitHub, Builder ID) stay two accounts (plugins#309); 0.1.12: a request for JSON output (output_config.format) answers in JSON, its schema in the system prompt as the built-in; 0.1.11: a thinking model offers xhigh as its own level (50k), so Claude Code's xhigh isn't routed as max (plugins#120); 0.1.10: the caller's prompt-cache marks reach Kiro as cachePoints (plugins#110)
min: "0.1.24", // 0.1.24: a conversation past the model's window is a 400 "input is too long for the model's context" however Kiro says it (an exception in its event stream was a 502, a reply stopped with MODEL_CONTEXT_WINDOW_EXCEEDED was finished), so magpie asks a member with room or tells the agent to compact (ergou0954_54426 on Discord); 0.1.23: thinking is asked for only when the request's thinking is enabled or adaptive; an effort with none, or with thinking disabled (Claude Code's title requests, a turn with thinking off), is sent no budget and no adaptive fields at any level (plugins#538, zengxiaosong); 0.1.22: a model whose Kiro catalog lists effort levels with adaptive thinking is sent the level as Kiro IDE sends it (additionalModelRequestFields), so xhigh and max stay apart, and a system message ending the conversation (Claude Code's environment context) goes as a turn before the question, not into it (plugins#538, zengxiaosong); 0.1.21: the browser sign-in asks first for AWS Builder ID, IAM Identity Center (Start URL and region) or Kiro's page; the AWS ways open AWS directly, so a magpie on a server or in Docker takes one pasted callback address instead of two, and a sign-in left behind frees its port when the next starts (plugins#507, SemonCat); 0.1.20: a tool whose input_schema has no root type reaches Kiro as an object, and a client's web_search server tool runs as Kiro's own search, at most 10 a request (plugins#492, SemonCat); 0.1.19: a usage read whose sign-in Kiro refused marks the account signed out, so its rows offer Sign in again, and a clean read takes the mark off (blue12345655 on Discord); 0.1.18: an image over Kiro's 5 MiB Base64 limit (a 4.2 MB view_image PNG is 5.6 MB as Base64) is shrunk on the request, or replaced by a note, so the conversation isn't stuck on IMAGE_SIZE_EXCEEDED (plugins#428); 0.1.17: the Free trial and Credits windows carry their credits used and the limit, so the card's Left shows the credits left (plugins#408); a reply with no token counts says its cache is unknown (magpie_cache_unknown), not 0: Kiro caches but counts no tokens (zeewell on X); 0.1.15: an API key is used as kiro-cli uses it: GetProfile in us-east-1 then eu-central-1, and with no profile found the key goes on in us-east-1; its models are the control plane's ListAvailableModels and no profile is named in its calls (Hollowhere: Auto alone, every request "Kiro didn't take the API key: 400"); 0.1.14: each account is named by its email and the way it was signed in to, "email (Google)", "email (GitHub)", not "email (slot)" (plugins#309); 0.1.13: two sign-ins of one email through different login providers (Google, GitHub, Builder ID) stay two accounts (plugins#309); 0.1.12: a request for JSON output (output_config.format) answers in JSON, its schema in the system prompt as the built-in; 0.1.11: a thinking model offers xhigh as its own level (50k), so Claude Code's xhigh isn't routed as max (plugins#120); 0.1.10: the caller's prompt-cache marks reach Kiro as cachePoints (plugins#110)
agents: []string{"kiro"},
out: func() ([]Moving, error) {
var out []Moving