Boss build seeds one Fire Pass key for every agent. Three concurrent agents -> three concurrent streamSimple calls against the Kimi K2.6 Turbo router -> three HTTP 429s on the overview dashboard. Add an in-memory async semaphore keyed by (provider, sha1(apiKey)) and acquire a slot inside `createSafePiStream` before invoking the source. The slot is released when the stream finishes, errors, or aborts. `fireworks-firepass` is capped at 1 concurrent call; every other provider stays uncapped (no fallback layer, no 429 retry — flow control prevents the burst at the source instead of recovering after). Same code path applies to public and boss builds: only the seeded key differs, the gate behaviour is identical.
20 lines
771 B
TypeScript
20 lines
771 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
PROVIDER_CONCURRENCY_LIMITS,
|
|
getProviderConcurrencyLimit,
|
|
} from "../../src/main/worker/runtime/provider-rate-limits";
|
|
|
|
describe("provider rate limits", () => {
|
|
it("caps fireworks-firepass at one concurrent call", () => {
|
|
expect(PROVIDER_CONCURRENCY_LIMITS["fireworks-firepass"]).toBe(1);
|
|
expect(getProviderConcurrencyLimit("fireworks-firepass")).toBe(1);
|
|
});
|
|
|
|
it("returns null for providers without an explicit cap", () => {
|
|
expect(getProviderConcurrencyLimit("anthropic")).toBeNull();
|
|
expect(getProviderConcurrencyLimit("openai")).toBeNull();
|
|
expect(getProviderConcurrencyLimit("ollama")).toBeNull();
|
|
expect(getProviderConcurrencyLimit("unknown-provider")).toBeNull();
|
|
});
|
|
});
|