Commit Graph
2 Commits
Author SHA1 Message Date
yetone 7c2f27ccdf gateway: a strict conversation keeps its member past a reply that broke off
imwhatiam123 on Discord: a routing group of Qoder CN and WorkBuddy AI
set to Stays: Strict moved a session to WorkBuddy AI. A reply that
broke off after its 200 (#733, common from a plugin-served provider)
called unanswered, which forgot the stick, so the agent's retry was
routed as a new conversation (why "first", kept null) from the top of
the order. Strict promises the conversation never moves to another
account, member or key, its failure going to the agent: the stick is
now kept under strict, so the retry goes back to the same member,
fails there while it fails, and goes on there once it answers. The
member still rests for new conversations as before. Every other mode
forgets the stick as before.

TestStrictGroupKeepsItsMemberPastABrokenReply: red on the old code (the
retry went to second), green with this change.

Run at this head (on origin/main a1174674d):
- go test ./internal/gateway -count=1 -timeout 45m, both
  commits together: ok (391s)
- gofmt -l internal/gateway: clean; go vet ./internal/gateway, also
  GOOS=linux and GOOS=windows: ok

Earlier run at e5dd86965 (this change alone): one red,
TestStreamingRequestsLetTheirSentBodyGo (#3503, heap read), 5 of 5 alone.
Not tried: a real Qoder CN / WorkBuddy AI group; the break is the
test's fake upstream's SSE error after some text.
2026-10-26 15:42:59 +08:00
yetone 908c910931 gateway, gui: Stays: Strict keeps a conversation on the account or key that answered it, even past its cap, and passes its error on rather than moving it (#1797)
miniers asked that a conversation never move to another account: a
move changes the account a vendor sees mid-conversation and loses its
prompt cache. Session affinity keeps the account while it can answer,
then moves on.

The new affinity mode "strict" (Stays: Strict) does what session does
for a new conversation. Once one has an account, strictKeep asks that
account alone (its other models too) and no other account, key or
provider:
- one resting or spent is still asked, and its error (429, 402, 5xx)
  goes to the agent rather than to the next candidate;
- one over a user cap is asked past it (plan's capped candidates,
  capHeldOnly);
- one held for credits answers 429 naming Stays: Strict rather than
  moving;
- one removed, turned off, barred or not allowed for the key counts as
  gone, and the conversation is routed as usual.
A last try that fails verification is not rested for a strict
conversation that had nowhere else to go.

Set in the provider editor and the Routing page's pool row (GUI, all
five languages), `magpie groups ... stays=strict` (strict-session,
never-move), and the TUI ("stays strictly"). Documented in
gateway-routing.md, reference.md and the site's start pages (en, zh,
ja).

Run:
- go test -tags nogui ./internal/gateway (-timeout 30m under load ~150),
  ./internal/provider ./internal/tui ./internal/cli: ok. The three
  TestStrictAffinity* tests fail on the code before this commit (200
  where 429 was expected, acct-2 answering).
- GUI: stays-strict.test.cjs, chromium and webkit, 900 and 560px, en,
  zh, zh-TW, ja, de: 30 of 30. On the assets before this commit it
  fails 15 of 15 in chromium. routing-*.test.cjs pass but for
  routing-steady's webkit 1.69px shift, which fails on the old assets
  too: filed as #1804.
- gofmt -l, go vet (darwin, linux, windows), full go test ./... before
  the push.

Not tried: a real agent conversation held on a real rate-limited
account.

Known and left: planLevel doesn't merge a nested group's sub.held, as
before this commit.
2026-10-12 23:16:54 +08:00