@intentsolutionsio/ai-sdk-agents 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +27 -0
- package/LICENSE +21 -0
- package/README.md +951 -0
- package/agents/multi-agent-orchestrator.md +363 -0
- package/commands/ai-agent-create.md +501 -0
- package/commands/ai-agents-setup.md +429 -0
- package/commands/ai-agents-test.md +529 -0
- package/package.json +49 -0
- package/skills/orchestrating-multi-agent-systems/SKILL.md +81 -0
- package/skills/orchestrating-multi-agent-systems/assets/README.md +7 -0
- package/skills/orchestrating-multi-agent-systems/assets/agent_template.ts +110 -0
- package/skills/orchestrating-multi-agent-systems/assets/example_coordinator.ts +100 -0
- package/skills/orchestrating-multi-agent-systems/assets/example_workflow.json +143 -0
- package/skills/orchestrating-multi-agent-systems/references/README.md +4 -0
- package/skills/orchestrating-multi-agent-systems/references/errors.md +26 -0
- package/skills/orchestrating-multi-agent-systems/references/examples.md +418 -0
- package/skills/orchestrating-multi-agent-systems/references/implementation.md +39 -0
- package/skills/orchestrating-multi-agent-systems/scripts/README.md +11 -0
- package/skills/orchestrating-multi-agent-systems/scripts/agent_setup.sh +94 -0
- package/skills/orchestrating-multi-agent-systems/scripts/dependency_installer.sh +100 -0
- package/skills/orchestrating-multi-agent-systems/scripts/env_setup.sh +94 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ai-agents-test
|
|
3
|
+
description: Test your multi-agent system with a sample task, showing agent handoffs,...
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
You are an expert in multi-agent system testing and observability.
|
|
7
|
+
|
|
8
|
+
# Mission
|
|
9
|
+
Test a multi-agent orchestration system by:
|
|
10
|
+
- Running a sample task through the agent network
|
|
11
|
+
- Showing real-time agent handoffs and routing
|
|
12
|
+
- Displaying performance metrics (time, handoff count)
|
|
13
|
+
- Validating agent coordination and output quality
|
|
14
|
+
- Identifying bottlenecks or issues
|
|
15
|
+
|
|
16
|
+
# Usage
|
|
17
|
+
|
|
18
|
+
User invokes: `/ai-agents-test "Task description"`
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
- `/ai-agents-test "Build a REST API with authentication"`
|
|
22
|
+
- `/ai-agents-test "Research best practices for React performance"`
|
|
23
|
+
- `/ai-agents-test "Debug this authentication error"`
|
|
24
|
+
|
|
25
|
+
# Test Process
|
|
26
|
+
|
|
27
|
+
## 1. Validate Setup
|
|
28
|
+
|
|
29
|
+
First check if the multi-agent project exists:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Check for required files
|
|
33
|
+
if [ -f "index.ts" ] && [ -d "agents" ]; then
|
|
34
|
+
echo "ā
Multi-agent project found"
|
|
35
|
+
else
|
|
36
|
+
echo "ā Multi-agent project not found"
|
|
37
|
+
echo "š” Run /ai-agents-setup first to create the project"
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 2. Parse Test Query
|
|
43
|
+
|
|
44
|
+
Extract the task from user input:
|
|
45
|
+
- If provided: Use their task
|
|
46
|
+
- If empty: Use default test task
|
|
47
|
+
|
|
48
|
+
Default tasks by category:
|
|
49
|
+
- **Code generation**: "Build a TODO API with CRUD operations"
|
|
50
|
+
- **Research**: "Research microservices best practices"
|
|
51
|
+
- **Debug**: "Why is my JWT authentication failing?"
|
|
52
|
+
- **Review**: "Review this code for security issues"
|
|
53
|
+
|
|
54
|
+
## 3. Start Test Execution
|
|
55
|
+
|
|
56
|
+
Create a test runner script:
|
|
57
|
+
|
|
58
|
+
### test-runner.ts
|
|
59
|
+
```typescript
|
|
60
|
+
import { runMultiAgentTask } from './index';
|
|
61
|
+
|
|
62
|
+
interface TestMetrics {
|
|
63
|
+
startTime: number;
|
|
64
|
+
endTime?: number;
|
|
65
|
+
handoffs: Array<{
|
|
66
|
+
from: string;
|
|
67
|
+
to: string;
|
|
68
|
+
reason: string;
|
|
69
|
+
timestamp: number;
|
|
70
|
+
}>;
|
|
71
|
+
agentsInvolved: Set<string>;
|
|
72
|
+
totalDuration?: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function testMultiAgentSystem(task: string) {
|
|
76
|
+
console.log('š Multi-Agent System Test\n');
|
|
77
|
+
console.log('ā'.repeat(60));
|
|
78
|
+
console.log(`š Task: ${task}`);
|
|
79
|
+
console.log('ā'.repeat(60));
|
|
80
|
+
console.log('');
|
|
81
|
+
|
|
82
|
+
const metrics: TestMetrics = {
|
|
83
|
+
startTime: Date.now(),
|
|
84
|
+
handoffs: [],
|
|
85
|
+
agentsInvolved: new Set()
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const result = await runMultiAgentTask(task);
|
|
90
|
+
|
|
91
|
+
metrics.endTime = Date.now();
|
|
92
|
+
metrics.totalDuration = metrics.endTime - metrics.startTime;
|
|
93
|
+
|
|
94
|
+
// Display results
|
|
95
|
+
displayResults(result, metrics);
|
|
96
|
+
|
|
97
|
+
return { success: true, result, metrics };
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error('ā Test failed:', error);
|
|
100
|
+
return { success: false, error, metrics };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function displayResults(result: any, metrics: TestMetrics) {
|
|
105
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
106
|
+
console.log('š Test Results');
|
|
107
|
+
console.log('ā'.repeat(60));
|
|
108
|
+
console.log('');
|
|
109
|
+
|
|
110
|
+
// Success indicator
|
|
111
|
+
console.log('ā
Status: Task completed successfully\n');
|
|
112
|
+
|
|
113
|
+
// Metrics
|
|
114
|
+
console.log('ā±ļø Performance Metrics:');
|
|
115
|
+
console.log(` Total duration: ${metrics.totalDuration}ms (${(metrics.totalDuration! / 1000).toFixed(2)}s)`);
|
|
116
|
+
console.log(` Handoff count: ${metrics.handoffs.length}`);
|
|
117
|
+
console.log(` Agents involved: ${metrics.agentsInvolved.size}`);
|
|
118
|
+
console.log(` Avg time per handoff: ${(metrics.totalDuration! / Math.max(metrics.handoffs.length, 1)).toFixed(0)}ms`);
|
|
119
|
+
console.log('');
|
|
120
|
+
|
|
121
|
+
// Agent flow
|
|
122
|
+
if (metrics.handoffs.length > 0) {
|
|
123
|
+
console.log('š Agent Flow:');
|
|
124
|
+
const agentFlow = ['coordinator'];
|
|
125
|
+
metrics.handoffs.forEach(h => {
|
|
126
|
+
if (!agentFlow.includes(h.to)) {
|
|
127
|
+
agentFlow.push(h.to);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
console.log(` ${agentFlow.join(' ā ')}`);
|
|
131
|
+
console.log('');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Handoff details
|
|
135
|
+
if (metrics.handoffs.length > 0) {
|
|
136
|
+
console.log('š Handoff Details:');
|
|
137
|
+
metrics.handoffs.forEach((handoff, i) => {
|
|
138
|
+
const duration = i < metrics.handoffs.length - 1
|
|
139
|
+
? metrics.handoffs[i + 1].timestamp - handoff.timestamp
|
|
140
|
+
: metrics.endTime! - handoff.timestamp;
|
|
141
|
+
|
|
142
|
+
console.log(` ${i + 1}. ${handoff.from} ā ${handoff.to}`);
|
|
143
|
+
console.log(` Reason: ${handoff.reason}`);
|
|
144
|
+
console.log(` Duration: ${duration}ms`);
|
|
145
|
+
console.log('');
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Output summary
|
|
150
|
+
console.log('š Output Summary:');
|
|
151
|
+
const output = typeof result.output === 'string' ? result.output : JSON.stringify(result.output, null, 2);
|
|
152
|
+
const lines = output.split('\n');
|
|
153
|
+
|
|
154
|
+
if (lines.length > 20) {
|
|
155
|
+
console.log(lines.slice(0, 10).join('\n'));
|
|
156
|
+
console.log(` ... (${lines.length - 20} more lines) ...`);
|
|
157
|
+
console.log(lines.slice(-10).join('\n'));
|
|
158
|
+
} else {
|
|
159
|
+
console.log(output);
|
|
160
|
+
}
|
|
161
|
+
console.log('');
|
|
162
|
+
|
|
163
|
+
// Quality assessment
|
|
164
|
+
console.log('šÆ Quality Assessment:');
|
|
165
|
+
const qualityScore = assessQuality(result, metrics);
|
|
166
|
+
console.log(` Overall score: ${qualityScore.score}/100`);
|
|
167
|
+
console.log(` Completeness: ${qualityScore.completeness}`);
|
|
168
|
+
console.log(` Efficiency: ${qualityScore.efficiency}`);
|
|
169
|
+
console.log(` Coordination: ${qualityScore.coordination}`);
|
|
170
|
+
console.log('');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function assessQuality(result: any, metrics: TestMetrics) {
|
|
174
|
+
let score = 100;
|
|
175
|
+
let completeness = 'ā
Excellent';
|
|
176
|
+
let efficiency = 'ā
Excellent';
|
|
177
|
+
let coordination = 'ā
Excellent';
|
|
178
|
+
|
|
179
|
+
// Check completeness
|
|
180
|
+
const outputLength = JSON.stringify(result.output).length;
|
|
181
|
+
if (outputLength < 100) {
|
|
182
|
+
score -= 30;
|
|
183
|
+
completeness = 'ā ļø Incomplete';
|
|
184
|
+
} else if (outputLength < 500) {
|
|
185
|
+
score -= 10;
|
|
186
|
+
completeness = 'ā
Good';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Check efficiency
|
|
190
|
+
const avgHandoffTime = metrics.totalDuration! / Math.max(metrics.handoffs.length, 1);
|
|
191
|
+
if (avgHandoffTime > 5000) {
|
|
192
|
+
score -= 20;
|
|
193
|
+
efficiency = 'ā ļø Slow';
|
|
194
|
+
} else if (avgHandoffTime > 3000) {
|
|
195
|
+
score -= 10;
|
|
196
|
+
efficiency = 'ā
Good';
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Check coordination
|
|
200
|
+
if (metrics.handoffs.length === 0) {
|
|
201
|
+
score -= 20;
|
|
202
|
+
coordination = 'ā ļø No handoffs';
|
|
203
|
+
} else if (metrics.handoffs.length > 10) {
|
|
204
|
+
score -= 10;
|
|
205
|
+
coordination = 'ā ļø Too many handoffs';
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
score: Math.max(0, score),
|
|
210
|
+
completeness,
|
|
211
|
+
efficiency,
|
|
212
|
+
coordination
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// CLI interface
|
|
217
|
+
const task = process.argv[2];
|
|
218
|
+
|
|
219
|
+
if (!task) {
|
|
220
|
+
console.error('ā Error: Please provide a task to test');
|
|
221
|
+
console.log('');
|
|
222
|
+
console.log('Usage: ts-node test-runner.ts "Your task description"');
|
|
223
|
+
console.log('');
|
|
224
|
+
console.log('Examples:');
|
|
225
|
+
console.log(' ts-node test-runner.ts "Build a REST API with authentication"');
|
|
226
|
+
console.log(' ts-node test-runner.ts "Research React performance best practices"');
|
|
227
|
+
console.log('');
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
testMultiAgentSystem(task)
|
|
232
|
+
.then(({ success }) => {
|
|
233
|
+
process.exit(success ? 0 : 1);
|
|
234
|
+
})
|
|
235
|
+
.catch(error => {
|
|
236
|
+
console.error('Fatal error:', error);
|
|
237
|
+
process.exit(1);
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## 4. Enhanced Orchestration with Metrics
|
|
242
|
+
|
|
243
|
+
Update `index.ts` to emit events for testing:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
export async function runMultiAgentTask(task: string, options?: {
|
|
247
|
+
onHandoff?: (event: HandoffEvent) => void;
|
|
248
|
+
onComplete?: (result: any) => void;
|
|
249
|
+
verbose?: boolean;
|
|
250
|
+
}) {
|
|
251
|
+
const verbose = options?.verbose ?? true;
|
|
252
|
+
|
|
253
|
+
if (verbose) {
|
|
254
|
+
console.log(`\nš¤ Starting multi-agent task: ${task}\n`);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const handoffs: Array<{
|
|
258
|
+
from: string;
|
|
259
|
+
to: string;
|
|
260
|
+
reason: string;
|
|
261
|
+
timestamp: number;
|
|
262
|
+
}> = [];
|
|
263
|
+
|
|
264
|
+
const result = await orchestrate({
|
|
265
|
+
agents,
|
|
266
|
+
task,
|
|
267
|
+
coordinator,
|
|
268
|
+
maxDepth: 10,
|
|
269
|
+
timeout: 300000,
|
|
270
|
+
|
|
271
|
+
onHandoff: (event) => {
|
|
272
|
+
const handoffData = {
|
|
273
|
+
from: event.from,
|
|
274
|
+
to: event.to,
|
|
275
|
+
reason: event.reason,
|
|
276
|
+
timestamp: Date.now()
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
handoffs.push(handoffData);
|
|
280
|
+
|
|
281
|
+
if (verbose) {
|
|
282
|
+
console.log(`\nš Handoff: ${event.from} ā ${event.to}`);
|
|
283
|
+
console.log(` Reason: ${event.reason}\n`);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
options?.onHandoff?.(event);
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
onComplete: (result) => {
|
|
290
|
+
if (verbose) {
|
|
291
|
+
console.log(`\nā
Task complete!`);
|
|
292
|
+
console.log(` Total handoffs: ${handoffs.length}`);
|
|
293
|
+
console.log(` Agents: ${new Set(handoffs.flatMap(h => [h.from, h.to])).size}\n`);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
options?.onComplete?.(result);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
...result,
|
|
302
|
+
metrics: {
|
|
303
|
+
handoffs,
|
|
304
|
+
agentCount: new Set(handoffs.flatMap(h => [h.from, h.to])).size
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## 5. Execute Test
|
|
311
|
+
|
|
312
|
+
Run the test:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# Using ts-node
|
|
316
|
+
ts-node test-runner.ts "Build a REST API with authentication"
|
|
317
|
+
|
|
318
|
+
# Or using npm script
|
|
319
|
+
npm run test:agents "Build a REST API with authentication"
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## 6. Display Real-Time Progress
|
|
323
|
+
|
|
324
|
+
Show live updates during execution:
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
š Multi-Agent System Test
|
|
328
|
+
|
|
329
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
330
|
+
š Task: Build a REST API with authentication
|
|
331
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
332
|
+
|
|
333
|
+
š Handoff: coordinator ā researcher
|
|
334
|
+
Reason: Need to research authentication best practices
|
|
335
|
+
|
|
336
|
+
š Handoff: researcher ā coder
|
|
337
|
+
Reason: Research complete, ready to implement
|
|
338
|
+
|
|
339
|
+
š Handoff: coder ā reviewer
|
|
340
|
+
Reason: Implementation complete, needs review
|
|
341
|
+
|
|
342
|
+
š Handoff: reviewer ā coordinator
|
|
343
|
+
Reason: Review complete, all checks passed
|
|
344
|
+
|
|
345
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
346
|
+
š Test Results
|
|
347
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
348
|
+
|
|
349
|
+
ā
Status: Task completed successfully
|
|
350
|
+
|
|
351
|
+
ā±ļø Performance Metrics:
|
|
352
|
+
Total duration: 47823ms (47.82s)
|
|
353
|
+
Handoff count: 4
|
|
354
|
+
Agents involved: 4
|
|
355
|
+
Avg time per handoff: 11956ms
|
|
356
|
+
|
|
357
|
+
š Agent Flow:
|
|
358
|
+
coordinator ā researcher ā coder ā reviewer ā coordinator
|
|
359
|
+
|
|
360
|
+
š Handoff Details:
|
|
361
|
+
1. coordinator ā researcher
|
|
362
|
+
Reason: Need to research authentication best practices
|
|
363
|
+
Duration: 8234ms
|
|
364
|
+
|
|
365
|
+
2. researcher ā coder
|
|
366
|
+
Reason: Research complete, ready to implement
|
|
367
|
+
Duration: 23456ms
|
|
368
|
+
|
|
369
|
+
3. coder ā reviewer
|
|
370
|
+
Reason: Implementation complete, needs review
|
|
371
|
+
Duration: 12389ms
|
|
372
|
+
|
|
373
|
+
4. reviewer ā coordinator
|
|
374
|
+
Reason: Review complete, all checks passed
|
|
375
|
+
Duration: 3744ms
|
|
376
|
+
|
|
377
|
+
š Output Summary:
|
|
378
|
+
{
|
|
379
|
+
"api": "REST API with JWT authentication",
|
|
380
|
+
"features": [
|
|
381
|
+
"User registration",
|
|
382
|
+
"User login",
|
|
383
|
+
"JWT token generation",
|
|
384
|
+
"Protected routes",
|
|
385
|
+
"Token refresh"
|
|
386
|
+
],
|
|
387
|
+
"security": {
|
|
388
|
+
"passwordHashing": "bcrypt",
|
|
389
|
+
"tokenExpiry": "1h",
|
|
390
|
+
"refreshToken": "7d"
|
|
391
|
+
},
|
|
392
|
+
"endpoints": [
|
|
393
|
+
"POST /api/auth/register",
|
|
394
|
+
"POST /api/auth/login",
|
|
395
|
+
"POST /api/auth/refresh",
|
|
396
|
+
"GET /api/users/me (protected)"
|
|
397
|
+
],
|
|
398
|
+
"tests": "95% coverage"
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
šÆ Quality Assessment:
|
|
402
|
+
Overall score: 95/100
|
|
403
|
+
Completeness: ā
Excellent
|
|
404
|
+
Efficiency: ā
Excellent
|
|
405
|
+
Coordination: ā
Excellent
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## 7. Add Test Script to package.json
|
|
409
|
+
|
|
410
|
+
```json
|
|
411
|
+
{
|
|
412
|
+
"scripts": {
|
|
413
|
+
"test:agents": "ts-node test-runner.ts"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## 8. Create Pre-defined Test Scenarios
|
|
419
|
+
|
|
420
|
+
Create `tests/scenarios.json`:
|
|
421
|
+
|
|
422
|
+
```json
|
|
423
|
+
{
|
|
424
|
+
"scenarios": [
|
|
425
|
+
{
|
|
426
|
+
"name": "Code Generation",
|
|
427
|
+
"task": "Build a REST API with authentication and CRUD operations",
|
|
428
|
+
"expectedAgents": ["coordinator", "researcher", "coder", "reviewer"],
|
|
429
|
+
"expectedHandoffs": 4,
|
|
430
|
+
"maxDuration": 60000
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"name": "Research Task",
|
|
434
|
+
"task": "Research best practices for microservices architecture",
|
|
435
|
+
"expectedAgents": ["coordinator", "researcher"],
|
|
436
|
+
"expectedHandoffs": 2,
|
|
437
|
+
"maxDuration": 20000
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"name": "Debug Task",
|
|
441
|
+
"task": "Debug JWT authentication failing with 401 errors",
|
|
442
|
+
"expectedAgents": ["coordinator", "researcher", "security-auditor"],
|
|
443
|
+
"expectedHandoffs": 3,
|
|
444
|
+
"maxDuration": 30000
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"name": "Complex Pipeline",
|
|
448
|
+
"task": "Design, implement, test, and document a payment processing API",
|
|
449
|
+
"expectedAgents": ["coordinator", "api-designer", "coder", "test-writer", "reviewer"],
|
|
450
|
+
"expectedHandoffs": 6,
|
|
451
|
+
"maxDuration": 120000
|
|
452
|
+
}
|
|
453
|
+
]
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## 9. Troubleshooting
|
|
458
|
+
|
|
459
|
+
If test fails, check:
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
# 1. Environment variables
|
|
463
|
+
if [ -z "$ANTHROPIC_API_KEY" ]; then
|
|
464
|
+
echo "ā Error: ANTHROPIC_API_KEY not set"
|
|
465
|
+
echo "š” Add your API key to .env file"
|
|
466
|
+
exit 1
|
|
467
|
+
fi
|
|
468
|
+
|
|
469
|
+
# 2. Dependencies installed
|
|
470
|
+
if [ ! -d "node_modules/@ai-sdk-tools/agents" ]; then
|
|
471
|
+
echo "ā Error: Dependencies not installed"
|
|
472
|
+
echo "š” Run: npm install"
|
|
473
|
+
exit 1
|
|
474
|
+
fi
|
|
475
|
+
|
|
476
|
+
# 3. Agents registered
|
|
477
|
+
if ! grep -q "researcher" index.ts; then
|
|
478
|
+
echo "ā ļø Warning: Not all agents registered in index.ts"
|
|
479
|
+
fi
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
# Output Summary
|
|
483
|
+
|
|
484
|
+
After test completion, show:
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
ā
Multi-agent test complete!
|
|
488
|
+
|
|
489
|
+
š Results:
|
|
490
|
+
Status: Success
|
|
491
|
+
Duration: 47.8s
|
|
492
|
+
Agents: 4 (coordinator, researcher, coder, reviewer)
|
|
493
|
+
Handoffs: 4
|
|
494
|
+
Quality: 95/100
|
|
495
|
+
|
|
496
|
+
šÆ Assessment:
|
|
497
|
+
ā
All agents coordinated successfully
|
|
498
|
+
ā
Task completed within expected time
|
|
499
|
+
ā
Output quality meets standards
|
|
500
|
+
|
|
501
|
+
š” Recommendations:
|
|
502
|
+
- System is functioning optimally
|
|
503
|
+
- Consider adding more specialized agents for complex tasks
|
|
504
|
+
- Average handoff time is excellent (11.9s)
|
|
505
|
+
|
|
506
|
+
š Full test output saved to: test-results-[timestamp].json
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
# Test Validation Criteria
|
|
510
|
+
|
|
511
|
+
A successful test should have:
|
|
512
|
+
- ā
At least 2 agents involved (coordinator + 1 specialist)
|
|
513
|
+
- ā
Meaningful handoffs with clear reasons
|
|
514
|
+
- ā
Completion within timeout (5 minutes default)
|
|
515
|
+
- ā
Quality output (not just "task complete")
|
|
516
|
+
- ā
No errors or exceptions
|
|
517
|
+
|
|
518
|
+
# Performance Benchmarks
|
|
519
|
+
|
|
520
|
+
Expected performance ranges:
|
|
521
|
+
- **Simple tasks** (research): 10-20 seconds, 2-3 handoffs
|
|
522
|
+
- **Medium tasks** (code generation): 30-60 seconds, 3-5 handoffs
|
|
523
|
+
- **Complex tasks** (full pipeline): 60-120 seconds, 5-8 handoffs
|
|
524
|
+
|
|
525
|
+
If actual performance exceeds these by 2x, investigate:
|
|
526
|
+
- API rate limiting
|
|
527
|
+
- Model selection (use faster models for testing)
|
|
528
|
+
- Network latency
|
|
529
|
+
- Agent prompt optimization
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intentsolutionsio/ai-sdk-agents",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Multi-agent orchestration with AI SDK v5 - handoffs, routing, and coordination for any AI provider (OpenAI, Anthropic, Google)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai-sdk",
|
|
7
|
+
"agents",
|
|
8
|
+
"multi-agent",
|
|
9
|
+
"orchestration",
|
|
10
|
+
"handoff",
|
|
11
|
+
"routing",
|
|
12
|
+
"llm",
|
|
13
|
+
"openai",
|
|
14
|
+
"anthropic",
|
|
15
|
+
"google",
|
|
16
|
+
"claude",
|
|
17
|
+
"ai",
|
|
18
|
+
"coordination",
|
|
19
|
+
"agent-skills",
|
|
20
|
+
"claude-code",
|
|
21
|
+
"claude-plugin",
|
|
22
|
+
"tonsofskills"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/jeremylongshore/claude-code-plugins-plus-skills.git",
|
|
27
|
+
"directory": "plugins/ai-ml/ai-sdk-agents"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://tonsofskills.com/plugins/ai-sdk-agents",
|
|
30
|
+
"bugs": "https://github.com/jeremylongshore/claude-code-plugins-plus-skills/issues",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"author": {
|
|
33
|
+
"name": "Jeremy Longshore",
|
|
34
|
+
"email": "[email protected]"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"README.md",
|
|
41
|
+
".claude-plugin",
|
|
42
|
+
"skills",
|
|
43
|
+
"commands",
|
|
44
|
+
"agents"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"postinstall": "node -e \"console.log(\\\"\\\\nā This npm package is a tracking/proof artifact. Install the plugin via:\\\\n ccpi install ai-sdk-agents\\\\n or /plugin install ai-sdk-agents@claude-code-plugins-plus in Claude Code\\\\n\\\")\""
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orchestrating-multi-agent-systems
|
|
3
|
+
description: |
|
|
4
|
+
Execute orchestrate multi-agent systems with handoffs, routing, and workflows across AI providers.
|
|
5
|
+
Use when building complex AI systems requiring agent collaboration, task delegation, or workflow coordination.
|
|
6
|
+
Trigger with phrases like "create multi-agent system", "orchestrate agents", or "coordinate agent workflows".
|
|
7
|
+
|
|
8
|
+
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(npm:*)
|
|
9
|
+
version: 1.0.0
|
|
10
|
+
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
11
|
+
license: MIT
|
|
12
|
+
compatible-with: claude-code, codex, openclaw
|
|
13
|
+
tags: [ai, workflow, agent-orchestration]
|
|
14
|
+
---
|
|
15
|
+
# Orchestrating Multi-Agent Systems
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
Design and implement multi-agent systems using AI SDK v5 with structured handoffs, intelligent routing, and coordinated workflows across AI providers. This skill covers agent role definition, tool scoping, inter-agent delegation via handoff rules, and workflow orchestration patterns including coordinator-worker and supervisor topologies.
|
|
20
|
+
|
|
21
|
+
## Prerequisites
|
|
22
|
+
|
|
23
|
+
- Node.js 18+ and TypeScript 5.0+ runtime
|
|
24
|
+
- AI SDK v5 (`npm install ai @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google`)
|
|
25
|
+
- API keys for target providers set in environment variables (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`)
|
|
26
|
+
- Zod for input/output schema validation (`npm install zod`)
|
|
27
|
+
- Familiarity with agent-based architecture patterns (coordinator, pipeline, broadcast)
|
|
28
|
+
|
|
29
|
+
## Instructions
|
|
30
|
+
|
|
31
|
+
1. Initialize a TypeScript project with `tsconfig.json` targeting ES2022 and moduleResolution `bundler`
|
|
32
|
+
2. Install AI SDK v5 core and provider packages for each model backend required
|
|
33
|
+
3. Define agent roles by creating separate modules per agent, each with a system prompt, model binding, and scoped tool set
|
|
34
|
+
4. Implement tool functions using `ai.tool()` with Zod input/output schemas for type-safe execution
|
|
35
|
+
5. Configure handoff rules using `ai.handoff()` to delegate tasks between agents with clear trigger conditions and context passing
|
|
36
|
+
6. Build routing logic that classifies incoming requests by topic or intent and dispatches to the appropriate specialist agent
|
|
37
|
+
7. Wire agents into a workflow using sequential, parallel, or conditional orchestration patterns
|
|
38
|
+
8. Add state management to persist context across multi-step workflows using a shared context object or external store
|
|
39
|
+
9. Implement circuit breakers and timeout guards to prevent workflow deadlocks
|
|
40
|
+
10. Test each agent in isolation, then validate end-to-end handoff chains with representative inputs
|
|
41
|
+
|
|
42
|
+
See `${CLAUDE_SKILL_DIR}/references/implementation.md` for the detailed implementation guide.
|
|
43
|
+
|
|
44
|
+
## Output
|
|
45
|
+
|
|
46
|
+
- TypeScript agent modules with AI SDK v5 provider bindings and system prompts
|
|
47
|
+
- Tool definitions with Zod-validated input/output schemas
|
|
48
|
+
- Handoff configuration mapping agent-to-agent delegation triggers
|
|
49
|
+
- Workflow orchestration files defining sequential, parallel, and conditional execution paths
|
|
50
|
+
- Routing classifier that maps user intents to specialist agents
|
|
51
|
+
- Integration test suite covering handoff chains and fallback paths
|
|
52
|
+
|
|
53
|
+
## Error Handling
|
|
54
|
+
|
|
55
|
+
| Error | Cause | Solution |
|
|
56
|
+
|-------|-------|----------|
|
|
57
|
+
| Provider configuration invalid | Missing or malformed API key in environment | Verify `process.env.*_API_KEY` values; check provider SDK version compatibility |
|
|
58
|
+
| Circular handoff detected | Agent A hands off to B which hands back to A | Implement handoff depth counter; set `maxHandoffDepth` and add a fallback terminal agent |
|
|
59
|
+
| Task routed to no agent | Routing classifier returned no match for input | Add a default catch-all route; improve classifier training data or keyword coverage |
|
|
60
|
+
| Tool access violation | Agent invoked a tool outside its scoped permission set | Review `tools` array per agent; ensure tool names match registered definitions exactly |
|
|
61
|
+
| Workflow timeout | Multi-step workflow exceeded deadline without completion | Set per-step timeouts with `AbortController`; add workflow-level deadline and partial-result handling |
|
|
62
|
+
|
|
63
|
+
See `${CLAUDE_SKILL_DIR}/references/errors.md` for the full error reference.
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
**Scenario 1: Customer Support Triage** -- A coordinator agent classifies incoming tickets as billing, technical, or general. Billing queries hand off to a specialist agent with access to Stripe tools. Technical queries route to a code-analysis agent with filesystem read tools. Resolution rate target: 85% automated within 3 handoff steps.
|
|
68
|
+
|
|
69
|
+
**Scenario 2: Research Pipeline** -- A sequential workflow chains a web-search agent, a summarization agent, and a report-writer agent. Each agent produces structured JSON output consumed by the next. The pipeline processes 50 research queries per batch with a p95 latency under 30 seconds per query.
|
|
70
|
+
|
|
71
|
+
**Scenario 3: Code Review Multi-Agent** -- A supervisor agent distributes pull request diffs to specialized reviewers (security, performance, style). Each reviewer returns findings with severity scores. The supervisor aggregates results into a unified review with prioritized action items.
|
|
72
|
+
|
|
73
|
+
See `${CLAUDE_SKILL_DIR}/references/examples.md` for additional examples.
|
|
74
|
+
|
|
75
|
+
## Resources
|
|
76
|
+
|
|
77
|
+
- [AI SDK v5 Documentation](https://sdk.vercel.ai/docs) -- agent creation, tool definitions, handoffs
|
|
78
|
+
- [Zod Schema Library](https://zod.dev) -- input/output validation for tools and flows
|
|
79
|
+
- Provider integration guides: OpenAI, Anthropic, Google Gemini
|
|
80
|
+
- Coordinator-worker and supervisor orchestration pattern references
|
|
81
|
+
- OpenTelemetry tracing for multi-agent observability
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Assets
|
|
2
|
+
|
|
3
|
+
Bundled resources for ai-sdk-agents skill
|
|
4
|
+
|
|
5
|
+
- [ ] agent_template.ts: Template for creating new agents with pre-defined structure and interfaces.
|
|
6
|
+
- [ ] example_coordinator.ts: Example implementation of a coordinator agent with routing logic.
|
|
7
|
+
- [ ] example_workflow.json: Example workflow definition for a multi-agent system.
|