feat: auto-route research-prefixed prompts to research agent
This commit is contained in:
@@ -510,6 +510,84 @@ describe('daemon command fast-path integration', () => {
|
||||
expect(keys.some(key => key.includes(':coder'))).toBe(true);
|
||||
});
|
||||
|
||||
it('auto-routes research-prefixed messages to research agent when configured', async () => {
|
||||
const processSpy = vi.spyOn(AgentOrchestrator.prototype, 'process').mockResolvedValue('ok');
|
||||
const session = {
|
||||
id: 'telegram:user-research',
|
||||
addMessage: vi.fn(),
|
||||
getHistory: vi.fn(() => []),
|
||||
clear: vi.fn(),
|
||||
replaceHistory: vi.fn(),
|
||||
getConfig: vi.fn(() => undefined),
|
||||
setConfig: vi.fn(),
|
||||
deleteConfig: vi.fn(),
|
||||
};
|
||||
|
||||
const commandRegistry = new CommandRegistry();
|
||||
registerBuiltinCommands(commandRegistry);
|
||||
|
||||
const agentConfigRegistry = new AgentConfigRegistry();
|
||||
agentConfigRegistry.loadFromConfig({
|
||||
assistant: { model_tier: 'default', sandbox: false },
|
||||
research: { model_tier: 'complex', sandbox: false },
|
||||
});
|
||||
|
||||
const agentRouter = new AgentRouter({
|
||||
default_agent: 'assistant',
|
||||
channels: {},
|
||||
senders: {},
|
||||
});
|
||||
|
||||
const router = createMessageRouter({
|
||||
sessionManager: {
|
||||
getSession: vi.fn(() => session),
|
||||
} as unknown as MessageRouterDeps['sessionManager'],
|
||||
modelRouter: {
|
||||
getAvailableTiers: () => ['fast', 'default', 'complex', 'local'],
|
||||
getAllLabels: () => ({ fast: 'fast', default: 'default', complex: 'complex', local: 'local' }),
|
||||
getLabel: (tier: string) => tier,
|
||||
} as unknown as MessageRouterDeps['modelRouter'],
|
||||
systemPrompt: 'test prompt',
|
||||
toolRegistry: {
|
||||
clone() { return this; },
|
||||
register: vi.fn(),
|
||||
} as unknown as MessageRouterDeps['toolRegistry'],
|
||||
toolExecutor: {} as unknown as MessageRouterDeps['toolExecutor'],
|
||||
config: {
|
||||
intents: { enabled: false },
|
||||
agents: {
|
||||
primary_tier: 'default',
|
||||
delegation: {
|
||||
compaction: 'fast',
|
||||
memory_extraction: 'fast',
|
||||
classification: 'fast',
|
||||
tool_summarisation: 'fast',
|
||||
complex_reasoning: 'complex',
|
||||
},
|
||||
max_delegation_depth: 3,
|
||||
max_iterations: 10,
|
||||
},
|
||||
compaction: { enabled: false },
|
||||
models: { default: { provider: 'anthropic', model: 'claude' } },
|
||||
} as unknown as MessageRouterDeps['config'],
|
||||
commandRegistry,
|
||||
agentConfigRegistry,
|
||||
agentRouter,
|
||||
});
|
||||
|
||||
await router.handler({
|
||||
id: 'm-research',
|
||||
channel: 'telegram',
|
||||
senderId: 'user-research',
|
||||
text: 'research compare k0s vs k3s for a homelab',
|
||||
timestamp: Date.now(),
|
||||
} as MessageRouterInput, vi.fn(async () => {}));
|
||||
|
||||
const keys = Array.from(router.agents.keys());
|
||||
expect(keys.some(key => key.includes(':research'))).toBe(true);
|
||||
expect(processSpy).toHaveBeenCalledWith('compare k0s vs k3s for a homelab', undefined);
|
||||
});
|
||||
|
||||
it('falls back to llm path when confidence is below fast threshold', async () => {
|
||||
const session = {
|
||||
id: 'telegram:user-3',
|
||||
|
||||
Reference in New Issue
Block a user