patch-testing-coworker / web /src /agents.test.ts
EnergyVenom's picture
Deploy Patch Testing Co-worker
2effee4 verified
Raw History Blame Contribute Delete
2.88 kB
import { describe, expect, it } from 'vitest';
import { AGENT_BY_NODE, agentEngineOnRun, aiOnRun, type LlmCall } from './agents';
const call = (node: string, route: string, extra: Partial<LlmCall> = {}): LlmCall => ({ node, route, provider: route === 'stub' ? 'stub' : route === 'local' ? 'ollama' : 'mistral', model: route === 'stub' ? 'deterministic' : route === 'local' ? 'llava-phi3' : 'mistral-large', fallback: null, ...extra });
describe('engine on this run (honesty)', () => {
it('says what actually did the work, from the run\'s LLM call records', () => {
expect(agentEngineOnRun('approval_gate', [], AGENT_BY_NODE.approval_gate)).toEqual({ kind: 'you', words: 'You' });
expect(agentEngineOnRun('scout', [], AGENT_BY_NODE.scout)).toEqual({ kind: 'rules', words: 'Built-in rules' });
expect(agentEngineOnRun('synthesizer', [], AGENT_BY_NODE.synthesizer)).toMatchObject({ kind: 'rules', words: 'Built-in rules (no AI model used)' });
expect(agentEngineOnRun('synthesizer', [call('synthesizer', 'stub')], AGENT_BY_NODE.synthesizer))
.toEqual({ kind: 'rules', words: 'Built-in rules (no AI model on)', detail: 'No AI model was connected when this ran. Settings › AI models.' });
expect(agentEngineOnRun('triage', [call('triage', 'stub', { fallback: 'local failed: ConnectError: refused' })], AGENT_BY_NODE.triage))
.toEqual({ kind: 'rules', words: 'Built-in rules (the AI model did not answer)', detail: 'local failed: ConnectError: refused' });
expect(agentEngineOnRun('triage', [call('triage', 'local'), call('triage', 'local')], AGENT_BY_NODE.triage))
.toEqual({ kind: 'local', words: 'Local AI model · llava-phi3', detail: '2 calls to ollama llava-phi3. Your data stayed in your environment.' });
expect(agentEngineOnRun('reporter', [call('reporter', 'frontier')], AGENT_BY_NODE.reporter))
.toEqual({ kind: 'frontier', words: 'External AI model · mistral-large', detail: '1 call to mistral mistral-large. Only public or redacted content was sent.' });
expect(agentEngineOnRun('research_module', [call('research_module', 'local'), call('research_module', 'frontier')], AGENT_BY_NODE.research_module))
.toMatchObject({ kind: 'mixed', words: 'Local and external AI models' });
expect(agentEngineOnRun('triage', [call('reporter', 'frontier')], AGENT_BY_NODE.triage).words).toBe('Built-in rules (no AI model used)'); // other nodes' calls do not count
});
it('sums the run up for the Coordinator', () => {
expect(aiOnRun([])).toBe('AI on this run: none');
expect(aiOnRun([call('synthesizer', 'stub')])).toBe('AI on this run: none, built-in rules only.');
expect(aiOnRun([call('triage', 'local'), call('reporter', 'frontier'), call('x', 'stub')])).toBe('AI on this run: local model llava-phi3 and external model mistral-large (2 calls).');
});
});