feat(models): add auth profile cooldown for api key pools
This commit is contained in:
@@ -599,6 +599,36 @@ describe('configSchema — models auth_mode', () => {
|
||||
});
|
||||
expect(result.models.default.api_keys).toEqual(['sk-1', 'sk-2']);
|
||||
});
|
||||
|
||||
it('accepts auth_profile_cooldown_ms per model tier', () => {
|
||||
const result = configSchema.parse({
|
||||
...minimalConfig,
|
||||
models: {
|
||||
default: {
|
||||
provider: 'openai',
|
||||
model: 'gpt-4o',
|
||||
api_keys: ['sk-1', 'sk-2'],
|
||||
auth_profile_cooldown_ms: 30000,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(result.models.default.auth_profile_cooldown_ms).toBe(30000);
|
||||
});
|
||||
|
||||
it('rejects invalid auth_profile_cooldown_ms values', () => {
|
||||
expect(() => {
|
||||
configSchema.parse({
|
||||
...minimalConfig,
|
||||
models: {
|
||||
default: {
|
||||
provider: 'openai',
|
||||
model: 'gpt-4o',
|
||||
auth_profile_cooldown_ms: -1,
|
||||
},
|
||||
},
|
||||
});
|
||||
}).toThrow(/auth_profile_cooldown_ms/i);
|
||||
});
|
||||
});
|
||||
|
||||
describe('configSchema — matrix', () => {
|
||||
|
||||
@@ -144,6 +144,8 @@ const modelConfigBaseSchema = z.object({
|
||||
endpoint: z.string().optional(),
|
||||
api_key: z.string().optional(),
|
||||
api_keys: z.array(z.string().min(1)).optional(),
|
||||
/** Cooldown (ms) before retrying a failed key/token profile in rotation pools. */
|
||||
auth_profile_cooldown_ms: z.number().min(0).max(3_600_000).optional(),
|
||||
auth_token: z.string().optional(),
|
||||
/** Credential selection strategy for this tier (provider-specific). */
|
||||
auth_mode: z.enum(['auto', 'api_key', 'oauth']).optional(),
|
||||
|
||||
Reference in New Issue
Block a user