ac4af582301a4e8a29245dbba767eba31334ddf9
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
be8b0f3816 |
gateway: a decision model's tries share the one classifier wait
Settings says the Classifier timeout is "how long the classifier is given to answer, its provider's failover included". askDecideTries gave each key, account or decision-group member a fresh classifyTimeout of its own (askJev made its own context), so a decision provider whose keys didn't answer held the turn one whole wait per try before its route began: 3 keys at the 60s maximum is 3m, past the 2m unrouted limit that stops a request with a 504. Found while looking for what held Jason's Codex request for 2m (Discord, #general). Whether his setup has a decision model is not known, so this is one possible cause, not the confirmed one. Now askDecideTries makes one context of classifyTimeout for all its tries, and askJev asks within it. Once a try spends the wait, the rest are neither asked nor rested. The chat-model classifier (askChat) already had one wait, failover included, through s.serve. TestDecisionTriesShareTheClassifierWait: a decision provider of three keys that never answer, the 8s default at 25ms a second. It wants the error "no answer in 200ms" with only the first key asked. Broken by hand (a fresh wait per try, the stop removed): red, "asked [w1 w2 w3] in one classifier's wait, want the first key alone". Fixed: green. Run: - mote: go test ./internal/gateway -run 'Decision|Decide|Jev|Classif|SystemOne|Unrouted|Held': ok (63s). - Full suite: go test ./... -timeout 45m -count=1 on the Windows box at this commit (mote was unreachable), still running at push; owner rule: ship at once, any new red filed afterwards. Not tried: a real decision provider with several keys. |
||
|
|
ecaa7e7dd7 |
gateway: a decision provider of several keys asks the next when one is out of quota, at /v1/systemone and as a classifier, in its routing's order (fflake33 on Discord)
A TypeSafe Jev provider with several keys never left its first key when that one's quota ran out. serveSystemOne and the classifier (askClassifier → askJev) always sent to p.Key, with no rest and no rotation. Only a decision group failed over (serveDecisionGroup, askDecisionGroup). Now the single provider goes the same way as a group: - decideKeys plans its keys and accounts with s.plan, so Smart or In order, rests and barred keys apply. probeOne keeps only the resting one back soonest. - serveDecideTries and askDecideTries (the group's loops, pulled out) ask each in turn. A retryable failure that isn't the request's own rests it and the next is asked. - serveSystemOne keeps #905's limits. A gateway key held to some accounts is asked only on those (allowedCandidates), and gets 403 keyAccountsError when none serves the model. - A provider whose every key is set not to serve the model is refused 403 (barredError) instead of being sent on its first key. - decideSeat is gone; the trace lists every key tried. - docs/subsystems/gateway-routing.md says so. Run: go test -p 1 -tags nogui -run 'SystemOne|Decid|Decide|Jev|Classif| KeyAccount|KeyModel|Disabled|RemoteMagpie|Caller|Usage|Plugin.*Decide| Barred|Rest|Probe' ./internal/gateway (ok, 124s). TestDecisionProviderKeysFailOver (Smart and In order) refuses the first key 429 and checks: - /v1/systemone answers 200 from the second, the trace has two tries and the first rests, and one usage row goes to the provider; - the next request asks only the second; - the same holds through askClassifier. Broken by hand: with the old decide.go, decide_group.go and classify.go it fails "systemone: 429 no capacity for k1" in both. The first version of the reordering ran the barred check before the held-key one, and TestGatewayKeyAccountsSystemOne caught the changed 403 message. The held check now runs first. gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./internal/gateway ok. Not tried against the real TypeSafe API. Full suite: SUITE_LINE |
||
|
|
6c9048db51 |
gateway: a request asks only the resting member back soonest, not every resting one, so a failing member isn't hammered by each request (#1799, dbydd)
dbydd: a group's routing still goes over its members in order however they have been failing, and with providers magpie can't read a quota from, that is close to a DDoS of the ones that are down. What was there: a failure rests the member (credit 30m, quota till its reset, rate by Retry-After, anything else 1m doubling to 10m), and one answer clears it. But restLast only moved resting candidates behind the ready ones. Once the ready ones failed, every request went on to ask each resting member in turn, so the rest kept nobody back: in an outage of the whole group each request went to all N members, and the last one again on its retries. Now (probeOne, fallback.go): of the candidates resting, a request asks only the one whose rest ends soonest (the first in order on a tie), at its place. Every ready candidate is still asked in the user's order. A lone candidate is always asked. A group that is down whole takes one upstream request per request, and the backoff grows with each real probe instead of each request. The trace still lists every member, the resting ones with their rest. The same is applied where the other paths go over candidates: count_tokens, embeddings/rerank, image accounts (drawOnAccounts) and a group's System One decision models. Codex autoReset still looks over the whole list (all), so a week used up on every account still spends a reset. Default on, no switch: it only reads rests the user's order already demotes, and only within a rest's cooldown; once a rest ends, the member is back at its place in the user's order. Each request still makes at least one real upstream attempt and returns the vendor's own error. Scoping: only rests are read, and a failure about the request's content or its model rests no member (failShape, prompt, overflow, refused, loop, auth, proxy...; a model refusal rests only restID), so neither leaves a member out. Borrowed from AxonHub's error-aware load balancing (looplj/axonhub, docs/zh/guides/load-balance.md, ErrorAware), which dbydd pointed to: a failed channel's score drops and recovers as its penalty decays, rather than it being sent every request. magpie's rest and backoff already are that decaying penalty; asking the one back soonest is how it recovers. Not taken: a success-rate memory that keeps a member demoted after it answers. One answer means it serves now, a flaky member already rests at least a minute per failure, and holding it down past that would override the user's order beyond a cooldown. Unchanged: the last candidate still isn't rested by its own failure, and the Patience rounds (#1418) and retries on the last one re-ask only candidates already in the trimmed list. Tests (resting_probe_test.go): TestGroupAsksOneRestingMemberNotEach (three resting members, minutes apart: only the soonest is asked; with a ready member, it then the soonest), TestRetrievalGroupAsksOneRestingMember (embeddings), TestLoneRestingMemberStillAsked, TestProbeOne. With probeOne returning its input (the old behaviour), the first two fail: "resting members asked map[a:1 b:1 c:1]". TestSystemOneDecisionGroupFailsOver held the old behaviour (all failing: kb, ka1, ka2 asked, ka2's 503 back); it now wants kb then ka1, the one rested first, and ka1's 429 back. Run: gofmt -l (clean); go vet (darwin, GOOS=linux -tags nogui, GOOS=windows); GOOS=linux -tags nogui and GOOS=windows go build; go test -tags nogui ./... -timeout 40m under a sandbox HOME at load average ~100: every package ok but gateway and agent, which hit the 40m timeout mid-run (TestZenUnsupportedModelLeavesTheListAlone and TestSnowNoProfiles running, a few seconds in), and plugin, where TestNPMInfoDeadline hung on its own failed 2s check (filed #1808). Rerun alone with -timeout 80m: gateway ok (1896s), agent ok (1811s), plugin ok (746s). Not run: a real upstream outage, the Windows box; count_tokens and image accounts have no test of their own. |
||
|
|
b1396d2360 |
gateway, provider, gui: a routing group of decision models answers /v1/systemone, failing over between them (ARNO on Discord)
ARNO asked for decision models to get the group feature too: /v1/systemone
took only "<provider>/<model>" (xxx/jev-latest), so one refusing key or
vendor failed the call with nothing to fall back on.
A routing group may now be of decision models alone (provider.Group.Decides,
provider/decide_group.go). SaveGroup refuses one mixed with models that hold
a conversation, a decision group inside a chat group, and patterns, rules,
classifier, effort, levels, fast mode or a member effort on it. It is kept
out of the agents' catalog (groupEntries), and a chat request to it gets a
400 pointing at /v1/systemone.
POST /v1/systemone with "model":"group/<id>" (or the group's id or name, as
GroupFor reads them) goes to serveDecisionGroup (gateway/decide_group.go):
- the members' keys and accounts are planned with planGroup in the group's
routing order, resting ones last; perKeyBarred no longer drops a
decision-only provider's keys (it speaks no chat protocol), so each key
is a try of its own;
- a gateway key's model and account limits and pause rules hold as for chat;
- a retryable failure that isn't the request's own (shape/prompt/protection)
rests the candidate via restAfter and the next is asked; a transport error
rests it as a 502; the last one's answer and Retry-After are passed on;
- every try is a Try of one route in the routing log; one usage row for the
answer.
A group classifier naming a decision group fails over the same way
(askDecisionGroup; systemOne now returns decideRefused with the vendor's
status, headers and body, and postDecide returns the headers).
The GUI group editor offers a group of decision models only decision models
(groups.deciders), a chat group no decision model or decision group, a new
one both, and a decision model's row has no reasoning picker (groupJSON
.decides). The TUI member picker and `magpie group add` follow the same rule.
#1514's plugin_decide_test and TestMixedDecisionProvider now assert a mixed group is refused and a group
of decision models saves. Docs: reference.md (routing groups),
gateway-routing.md, provider-plugins.md.
Run:
- go test -tags nogui -timeout 40m . ./internal/provider ./internal/gateway
./internal/gui ./internal/tui: ok
- new: TestSystemOneDecisionGroupFailsOver (httptest System One fakes: a
provider with two keys answering 429 and 503, then a second provider
answering 200: tries ka1,ka2,kb, both failures rested and ask by name
goes to kb first; all failing passes the last answer on; chat to the
group is 400), TestDecisionGroupClassifierFailsOver, TestDecisionGroup,
TestGroupAddDecisionModels, TestMemberOptionsDecisionGroup,
group-decide-members.test.cjs (Chromium and WebKit, en and zh; no new
strings)
- each broken by hand and seen red: no dispatch (404), no perKeyBarred
change (ka2 skipped), no classifier failover, no rest, decision group in
the catalog, CLI resolver, TUI and GUI picker filters
- GUI: group-*, routing-effort*, routing-levels, routing-save*,
routing-intent-entry, routing-manual, i18n-keys in both engines: 169 pass
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on the
touched packages
- after rebasing on
|