mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-27 13:23:57 +02:00
fix: mark handoff triage-to-specialist edges as loop edges
The forward edges from triage to specialists participate in cycles (triage→specialist + specialist→triage), so they must be marked with isLoop, condition, and maxIterations to pass validation. Fixes the Handoff Support Flow template and scaffoldGraphForMode() for handoff mode. Updates the corresponding test expectation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -883,7 +883,11 @@ export function scaffoldGraphForMode(
|
|||||||
edges: [
|
edges: [
|
||||||
createWorkflowEdge(`edge-start-to-${triage.id}`, 'start', triage.id),
|
createWorkflowEdge(`edge-start-to-${triage.id}`, 'start', triage.id),
|
||||||
createWorkflowEdge(`edge-${triage.id}-to-end`, triage.id, 'end'),
|
createWorkflowEdge(`edge-${triage.id}-to-end`, triage.id, 'end'),
|
||||||
...specialists.map((specialist) => createWorkflowEdge(`edge-${triage.id}-to-${specialist.id}`, triage.id, specialist.id)),
|
...specialists.map((specialist) => createWorkflowEdge(`edge-${triage.id}-to-${specialist.id}`, triage.id, specialist.id, 'direct', {
|
||||||
|
isLoop: true,
|
||||||
|
maxIterations: 4,
|
||||||
|
condition: { type: 'always' },
|
||||||
|
})),
|
||||||
...specialists.map((specialist) => createWorkflowEdge(`edge-${specialist.id}-to-${triage.id}`, specialist.id, triage.id, 'direct', {
|
...specialists.map((specialist) => createWorkflowEdge(`edge-${specialist.id}-to-${triage.id}`, specialist.id, triage.id, 'direct', {
|
||||||
isLoop: true,
|
isLoop: true,
|
||||||
maxIterations: 4,
|
maxIterations: 4,
|
||||||
@@ -1147,8 +1151,16 @@ export function createBuiltinWorkflows(timestamp: string): WorkflowDefinition[]
|
|||||||
edges: [
|
edges: [
|
||||||
createWorkflowEdge('edge-start-to-agent-handoff-triage', 'start', 'agent-handoff-triage'),
|
createWorkflowEdge('edge-start-to-agent-handoff-triage', 'start', 'agent-handoff-triage'),
|
||||||
createWorkflowEdge('edge-agent-handoff-triage-to-end', 'agent-handoff-triage', 'end'),
|
createWorkflowEdge('edge-agent-handoff-triage-to-end', 'agent-handoff-triage', 'end'),
|
||||||
createWorkflowEdge('edge-agent-handoff-triage-to-agent-handoff-ux', 'agent-handoff-triage', 'agent-handoff-ux'),
|
createWorkflowEdge('edge-agent-handoff-triage-to-agent-handoff-ux', 'agent-handoff-triage', 'agent-handoff-ux', 'direct', {
|
||||||
createWorkflowEdge('edge-agent-handoff-triage-to-agent-handoff-runtime', 'agent-handoff-triage', 'agent-handoff-runtime'),
|
isLoop: true,
|
||||||
|
maxIterations: 4,
|
||||||
|
condition: { type: 'always' },
|
||||||
|
}),
|
||||||
|
createWorkflowEdge('edge-agent-handoff-triage-to-agent-handoff-runtime', 'agent-handoff-triage', 'agent-handoff-runtime', 'direct', {
|
||||||
|
isLoop: true,
|
||||||
|
maxIterations: 4,
|
||||||
|
condition: { type: 'always' },
|
||||||
|
}),
|
||||||
createWorkflowEdge('edge-agent-handoff-ux-to-agent-handoff-triage', 'agent-handoff-ux', 'agent-handoff-triage', 'direct', {
|
createWorkflowEdge('edge-agent-handoff-ux-to-agent-handoff-triage', 'agent-handoff-ux', 'agent-handoff-triage', 'direct', {
|
||||||
isLoop: true,
|
isLoop: true,
|
||||||
maxIterations: 4,
|
maxIterations: 4,
|
||||||
|
|||||||
@@ -430,12 +430,10 @@ describe('workflow validation', () => {
|
|||||||
const loopEdges = graph.edges.filter((edge) => edge.isLoop);
|
const loopEdges = graph.edges.filter((edge) => edge.isLoop);
|
||||||
|
|
||||||
expect(graph.nodes.map((node) => node.id)).toContain('agent-handoff-triage');
|
expect(graph.nodes.map((node) => node.id)).toContain('agent-handoff-triage');
|
||||||
expect(loopEdges).toHaveLength(1);
|
// Both forward (triage→specialist) and return (specialist→triage) edges are loops
|
||||||
expect(loopEdges[0]).toMatchObject({
|
expect(loopEdges).toHaveLength(2);
|
||||||
source: 'agent-handoff-specialist-1',
|
expect(loopEdges.every((edge) => edge.maxIterations === 4)).toBe(true);
|
||||||
target: 'agent-handoff-triage',
|
expect(loopEdges.every((edge) => edge.condition?.type === 'always')).toBe(true);
|
||||||
maxIterations: 4,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('scaffolds group-chat mode with loop edges between agent nodes', () => {
|
test('scaffolds group-chat mode with loop edges between agent nodes', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user