Files
aryx/tests/shared/pattern.test.ts
T
David KayaandCopilot 794722673b fix: strengthen group chat collaboration guidance
Audit confirmed that single, sequential, concurrent, and handoff are mapped to distinct workflow builders as intended. Group-chat was also using the correct round-robin manager, but the agents only had one-shot role prompts, so the reviewer could behave like a fresh assistant instead of refining the draft in progress. Add explicit runtime guidance for group-chat participants plus clearer built-in Writer/Reviewer instructions and regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-23 23:22:09 +01:00

105 lines
3.9 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import { createBuiltinPatterns, validatePatternDefinition } from '@shared/domain/pattern';
const BUILTIN_TIMESTAMP = '2026-03-22T00:00:00.000Z';
describe('pattern validation', () => {
test('builtin patterns are valid except explicitly unavailable modes', () => {
const patterns = createBuiltinPatterns(BUILTIN_TIMESTAMP);
const validPatterns = patterns.filter((pattern) => pattern.availability !== 'unavailable');
for (const pattern of validPatterns) {
expect(validatePatternDefinition(pattern)).toEqual([]);
}
});
test('magentic pattern is marked unavailable', () => {
const magentic = createBuiltinPatterns(BUILTIN_TIMESTAMP).find(
(pattern) => pattern.mode === 'magentic',
);
expect(magentic).toBeDefined();
expect(validatePatternDefinition(magentic!)[0]?.message).toContain('unsupported');
});
test('single-agent mode reports agent count, warning, and model issues together', () => {
const singlePattern = createBuiltinPatterns(BUILTIN_TIMESTAMP).find(
(pattern) => pattern.mode === 'single',
);
expect(singlePattern).toBeDefined();
const issues = validatePatternDefinition({
...singlePattern!,
agents: [
{
...singlePattern!.agents[0],
instructions: ' ',
},
{
...singlePattern!.agents[0],
id: 'agent-reviewer',
name: 'Reviewer',
model: '',
},
],
});
expect(issues.find((issue) => issue.field === 'agents')?.message).toBe(
'Single-agent chat requires exactly one agent.',
);
expect(issues.find((issue) => issue.field === 'agents.instructions')?.level).toBe('warning');
expect(issues.find((issue) => issue.field === 'agents.instructions')?.message).toBe(
'Agent "Primary Agent" should have instructions.',
);
expect(issues.find((issue) => issue.field === 'agents.model')?.message).toBe(
'Agent "Reviewer" requires a model identifier.',
);
});
test('multi-agent orchestration modes reject single-agent configurations', () => {
const patterns = createBuiltinPatterns(BUILTIN_TIMESTAMP);
const handoff = patterns.find((pattern) => pattern.mode === 'handoff');
const groupChat = patterns.find((pattern) => pattern.mode === 'group-chat');
expect(handoff).toBeDefined();
expect(groupChat).toBeDefined();
expect(
validatePatternDefinition({
...handoff!,
agents: handoff!.agents.slice(0, 1),
}).find((issue) => issue.field === 'agents')?.message,
).toBe('Handoff orchestration requires at least two agents.');
expect(
validatePatternDefinition({
...groupChat!,
agents: groupChat!.agents.slice(0, 1),
}).find((issue) => issue.field === 'agents')?.message,
).toBe('Group chat requires at least two agents.');
});
test('handoff builtin instructions clearly separate triage and specialist ownership', () => {
const handoff = createBuiltinPatterns(BUILTIN_TIMESTAMP).find((pattern) => pattern.mode === 'handoff');
expect(handoff).toBeDefined();
expect(handoff?.agents[0].instructions).toContain('Do not do the specialist work yourself');
expect(handoff?.agents[1].instructions).toContain('own the substantive answer');
expect(handoff?.agents[2].instructions).toContain('own the substantive answer');
});
test('group chat builtin instructions frame iterative drafting and review', () => {
const groupChat = createBuiltinPatterns(BUILTIN_TIMESTAMP).find(
(pattern) => pattern.mode === 'group-chat',
);
expect(groupChat).toBeDefined();
expect(groupChat?.agents[0].instructions).toContain('refine your earlier draft');
expect(groupChat?.agents[1].instructions).toContain('specific improvements');
expect(groupChat?.agents[1].instructions).toContain('instead of restarting the conversation');
});
});