feat: add sticky round-robin routing strategy

Implements a "sticky" round-robin strategy that uses the same provider
account for a configurable number of consecutive calls (default 3)
before switching to the next one. This optimizes for prompt caching
by reducing organization/account rotation. Adds a configuration input
to the Profile settings page.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Catalin Stanciu
2026-01-09 17:45:32 +07:00
committed by decolua
co-authored by Claude Sonnet 4.5
parent f2abcc6585
commit 4f292aae63
3 changed files with 84 additions and 14 deletions
+6 -3
View File
@@ -39,7 +39,8 @@ const defaultData = {
combos: [],
apiKeys: [],
settings: {
cloudEnabled: false
cloudEnabled: false,
stickyRoundRobinLimit: 3
}
};
@@ -178,7 +179,8 @@ export async function createProviderConnection(data) {
"displayName", "email", "globalPriority", "defaultModel",
"accessToken", "refreshToken", "expiresAt", "tokenType",
"scope", "idToken", "projectId", "apiKey", "testStatus",
"lastTested", "lastError", "lastErrorAt", "rateLimitedUntil", "expiresIn", "errorCode"
"lastTested", "lastError", "lastErrorAt", "rateLimitedUntil", "expiresIn", "errorCode",
"consecutiveUseCount"
];
for (const field of optionalFields) {
@@ -470,7 +472,8 @@ export async function cleanupProviderConnections() {
"displayName", "email", "globalPriority", "defaultModel",
"accessToken", "refreshToken", "expiresAt", "tokenType",
"scope", "idToken", "projectId", "apiKey", "testStatus",
"lastTested", "lastError", "lastErrorAt", "rateLimitedUntil", "expiresIn"
"lastTested", "lastError", "lastErrorAt", "rateLimitedUntil", "expiresIn",
"consecutiveUseCount"
];
let cleaned = 0;