feat: add per-cron-job model tier selection
Allow cron jobs to specify a `model_tier` field that controls which LLM tier handles the job, without needing separate agent configs. Precedence: cron job model_tier > agent config > global primary_tier > 'default'. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { AgentRouter } from '../agents/router.js';
|
||||
import { AgentConfigRegistry } from '../agents/registry.js';
|
||||
import type { ModelTier } from '../models/router.js';
|
||||
|
||||
describe('daemon agent routing integration', () => {
|
||||
it('resolves agent config for channel messages', () => {
|
||||
@@ -35,4 +36,28 @@ describe('daemon agent routing integration', () => {
|
||||
const router = new AgentRouter({ channels: {}, senders: {} });
|
||||
expect(router.resolve('telegram', '123')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('model tier precedence: metadata > agent config > global default', () => {
|
||||
// This test documents the tier resolution precedence used by createMessageRouter.
|
||||
// The actual resolution logic: tierFromMetadata ?? agentConfig?.modelTier ?? primary_tier ?? 'default'
|
||||
function resolveTier(
|
||||
metadataTier: ModelTier | undefined,
|
||||
agentTier: ModelTier | undefined,
|
||||
globalTier: ModelTier | undefined,
|
||||
): ModelTier {
|
||||
return metadataTier ?? agentTier ?? globalTier ?? 'default';
|
||||
}
|
||||
|
||||
// With all three set, metadata wins
|
||||
expect(resolveTier('fast', 'complex', 'default')).toBe('fast');
|
||||
|
||||
// Without metadata, agent config wins
|
||||
expect(resolveTier(undefined, 'complex', 'default')).toBe('complex');
|
||||
|
||||
// Without metadata or agent config, global wins
|
||||
expect(resolveTier(undefined, undefined, 'default')).toBe('default');
|
||||
|
||||
// Without anything, falls back to 'default'
|
||||
expect(resolveTier(undefined, undefined, undefined)).toBe('default');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user