























@@ -73,6 +73,7 @@ let setLoggerOverride: LoggerModule["setLoggerOverride"];
73737474const makeCfg = makeModelFallbackCfg;
7575let cleanupLogCapture: (() => void) | undefined;
76+const OPENAI_PROBE_CANDIDATE = { provider: "openai", model: "gpt-4.1-mini" } as const;
76777778async function loadModelFallbackProbeModules() {
7879const authProfilesStoreModule = await import("./auth-profiles/store.js");
@@ -209,7 +210,7 @@ describe("runWithModelFallback – probe logic", () => {
209210mockedGetSoonestCooldownExpiry.mockReturnValue(params.soonest);
210211mockedResolveProfilesUnavailableReason.mockReturnValue(params.reason);
211212return modelFallbackTesting.resolveCooldownDecision({
212-candidate: { provider: "openai", model: "gpt-4.1-mini" },
213+candidate: OPENAI_PROBE_CANDIDATE,
213214isPrimary: params.isPrimary ?? true,
214215requestedModel: params.requestedModel ?? true,
215216hasFallbackCandidates: params.hasFallbackCandidates ?? true,
@@ -226,6 +227,17 @@ describe("runWithModelFallback – probe logic", () => {
226227});
227228}
228229230+function expectOpenAiProbeSuspension(
231+decision: ReturnType<ModelFallbackModule["__testing"]["resolveCooldownDecision"]>,
232+reason: "rate_limit" | "billing",
233+) {
234+expect(decision).toEqual({
235+type: "suspend_lanes",
236+ reason,
237+leaderCandidate: OPENAI_PROBE_CANDIDATE,
238+});
239+}
240+229241async function expectPrimarySkippedAfterLongCooldown(reason: "billing" | "rate_limit") {
230242const cfg = makeCfg();
231243const expiresIn30Min = NOW + 30 * 60 * 1000;
@@ -323,13 +335,14 @@ describe("runWithModelFallback – probe logic", () => {
323335).toEqual({ type: "attempt", reason: "rate_limit", markProbe: true });
324336325337_probeThrottleInternals.lastProbeAttempt.set("recent-openai", NOW - 10_000);
326-expect(
338+expectOpenAiProbeSuspension(
327339resolveOpenAiCooldownDecision({
328340reason: "rate_limit",
329341soonest: NOW + 30 * 1000,
330342throttleKey: "recent-openai",
331343}),
332-).toMatchObject({ type: "skip", reason: "rate_limit" });
344+"rate_limit",
345+);
333346});
334347335348it("logs primary metadata on probe success and failure fallback decisions", async () => {
@@ -633,13 +646,14 @@ describe("runWithModelFallback – probe logic", () => {
633646const agentBKey = _probeThrottleInternals.resolveProbeThrottleKey("openai", "/tmp/agent-b");
634647_probeThrottleInternals.lastProbeAttempt.set(agentAKey, NOW - 10_000);
635648636-expect(
649+expectOpenAiProbeSuspension(
637650resolveOpenAiCooldownDecision({
638651reason: "rate_limit",
639652soonest: NOW + 30 * 1000,
640653throttleKey: agentAKey,
641654}),
642-).toMatchObject({ type: "skip", reason: "rate_limit" });
655+"rate_limit",
656+);
643657expect(
644658resolveOpenAiCooldownDecision({
645659reason: "rate_limit",
@@ -666,11 +680,12 @@ describe("runWithModelFallback – probe logic", () => {
666680soonest: NOW + 60 * 1000,
667681}),
668682).toEqual({ type: "attempt", reason: "billing", markProbe: true });
669-expect(
683+expectOpenAiProbeSuspension(
670684resolveOpenAiCooldownDecision({
671685reason: "billing",
672686soonest: NOW + 30 * 60 * 1000,
673687}),
674-).toMatchObject({ type: "skip", reason: "billing" });
688+"billing",
689+);
675690});
676691});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。