feat(router): smart routers and per-member rate limits (#9)

Add smart routers: virtual models that score each request and route it to admin-defined model tiers. A retryable failure moves the request to a higher tier. The classifier v2 extracts prose, finds the original ask in long tool loops, adds an uncertainty margin and reads tool-output failures. Sessions, outcome signals, bounded calibration, adaptive selection within a tier, gated saturation downgrade, a first-byte timeout and an opt-in timeout fallback are included. Every new feature is off by default.

Add per-member group limits, a tokensPerMinute window that counts uncached input and output, rate-limit headers in three dialects, soft pacing before the hard limit, and a limitExemptKinds list so embedding and reranking traffic never counts toward or hits a limit.

Fix yaegi named-result state that made smartContentSize grow between calls.
This commit is contained in:
2026-11-25 00:40:30 +00:00
committed by GitHub
parent 6fb048b599
commit 4c61d19a72
154 changed files with 73356 additions and 286 deletions
+6 -1
View File
@@ -3,7 +3,7 @@
# two of them concurrently would corrupt each other's containers.
.NOTPARALLEL:
.PHONY: test lint yaegi-check admin-ui pricing-sync integration integration-keep integration-up integration-wait integration-down build-binary docker-build run-local
.PHONY: test lint yaegi-check yaegi-bench admin-ui pricing-sync integration integration-keep integration-up integration-wait integration-down build-binary docker-build run-local
test:
go test ./... -count=1
@@ -32,6 +32,11 @@ admin-ui:
yaegi-check:
cd tools/yaegi-check && GOWORK=off go run . $(CURDIR)
# yaegi-bench times smart router classification under the interpreter and
# fails below the decisions-per-second gate. Not part of CI: it takes a minute.
yaegi-bench:
cd tools/yaegi-bench && GOWORK=off go run . $(CURDIR)
# pricing-sync regenerates the repo-root pricing_data_gen.go: the
# built-in, LiteLLM-synced per-model context/cost table feature v0.23's
# metadata resolution falls back to (modelmeta.go's resolveModelMeta).