|
|
@@ -1,7 +1,6 @@
|
|
|
import { beforeEach, describe, expect, mock, test } from 'bun:test';
|
|
|
import { SessionLifecycle } from '../session-lifecycle';
|
|
|
import {
|
|
|
- disableChainsForModelSwitches,
|
|
|
ForegroundFallbackManager,
|
|
|
isFailoverError,
|
|
|
isRateLimitError,
|
|
|
@@ -1328,76 +1327,3 @@ describe('ForegroundFallbackManager disableChain', () => {
|
|
|
expect(call[0].body.model.modelID).toBe('claude-haiku');
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
-// ---------------------------------------------------------------------------
|
|
|
-// disableChainsForModelSwitches
|
|
|
-// ---------------------------------------------------------------------------
|
|
|
-
|
|
|
-describe('disableChainsForModelSwitches', () => {
|
|
|
- function makeMgr(chains: Record<string, string[]>) {
|
|
|
- const { client } = createMockClient();
|
|
|
- return new ForegroundFallbackManager(client, chains, true);
|
|
|
- }
|
|
|
-
|
|
|
- test('disables when model differs from chain[0]', () => {
|
|
|
- const chains = { orchestrator: ['a', 'b'] };
|
|
|
- const mgr = makeMgr(chains);
|
|
|
- const configAgent = { orchestrator: { model: 'c' } };
|
|
|
-
|
|
|
- const result = disableChainsForModelSwitches(mgr, chains, configAgent);
|
|
|
-
|
|
|
- expect((mgr as any).chains.orchestrator).toEqual([]);
|
|
|
- expect(result).toEqual(['orchestrator']);
|
|
|
- });
|
|
|
-
|
|
|
- test('does NOT disable when model equals chain[0]', () => {
|
|
|
- const chains = { orchestrator: ['a', 'b'] };
|
|
|
- const mgr = makeMgr(chains);
|
|
|
- const configAgent = { orchestrator: { model: 'a' } };
|
|
|
-
|
|
|
- const result = disableChainsForModelSwitches(mgr, chains, configAgent);
|
|
|
-
|
|
|
- expect((mgr as any).chains.orchestrator).toEqual(['a', 'b']);
|
|
|
- expect(result).toEqual([]);
|
|
|
- });
|
|
|
-
|
|
|
- test('does NOT disable when agent has no configAgent entry', () => {
|
|
|
- const chains = { orchestrator: ['a', 'b'] };
|
|
|
- const mgr = makeMgr(chains);
|
|
|
-
|
|
|
- const result = disableChainsForModelSwitches(mgr, chains, {});
|
|
|
-
|
|
|
- expect((mgr as any).chains.orchestrator).toEqual(['a', 'b']);
|
|
|
- expect(result).toEqual([]);
|
|
|
- });
|
|
|
-
|
|
|
- test('skips empty chains', () => {
|
|
|
- const chains = { orchestrator: [] };
|
|
|
- const mgr = makeMgr(chains);
|
|
|
- const configAgent = { orchestrator: { model: 'c' } };
|
|
|
-
|
|
|
- expect(() =>
|
|
|
- disableChainsForModelSwitches(mgr, chains, configAgent),
|
|
|
- ).not.toThrow();
|
|
|
- const result = disableChainsForModelSwitches(mgr, chains, configAgent);
|
|
|
- expect(result).toEqual([]);
|
|
|
- });
|
|
|
-
|
|
|
- test('only disables the mismatched agent', () => {
|
|
|
- const chains = {
|
|
|
- orchestrator: ['a', 'b'],
|
|
|
- explorer: ['x', 'y'],
|
|
|
- };
|
|
|
- const mgr = makeMgr(chains);
|
|
|
- const configAgent = {
|
|
|
- orchestrator: { model: 'c' }, // mismatched
|
|
|
- explorer: { model: 'x' }, // matches chain[0]
|
|
|
- };
|
|
|
-
|
|
|
- const result = disableChainsForModelSwitches(mgr, chains, configAgent);
|
|
|
-
|
|
|
- expect((mgr as any).chains.orchestrator).toEqual([]);
|
|
|
- expect((mgr as any).chains.explorer).toEqual(['x', 'y']);
|
|
|
- expect(result).toEqual(['orchestrator']);
|
|
|
- });
|
|
|
-});
|