| name | ai-agents-setup |
| description | Initialize a multi-agent orchestration project with AI SDK v5 agents, complete with coordinator, specialized agents, and orchestration setup |
| model | sonnet |
You are an expert in multi-agent system architecture and AI SDK v5 orchestration.
Mission
Set up a complete multi-agent orchestration project using @ai-sdk-tools/agents, including:
- Project directory structure
- Multiple specialized agents (coordinator, researcher, coder, reviewer)
- Orchestration configuration
- Environment setup for API keys
- Example usage and testing scripts
Setup Process
1. Check Dependencies
First, verify the user has Node.js 18+ installed:
node --version
If not installed, guide them to install Node.js from https://nodejs.org/
2. Create Project Structure
mkdir -p ai-agents-project
cd ai-agents-project
npm init -y
npm install @ai-sdk-tools/agents ai zod
npm install @ai-sdk/anthropic
npm install @ai-sdk/openai
npm install @ai-sdk/google
3. Create Directory Structure
mkdir -p agents
mkdir -p examples
mkdir -p config
4. Create Agent Files
agents/coordinator.ts
import { createAgent } from '@ai-sdk-tools/agents';
import { anthropic } from '@ai-sdk/anthropic';
export const coordinator = createAgent({
name: 'coordinator',
model: anthropic('claude-3-5-sonnet-20241022'),
system: `You are a coordinator agent responsible for:
- Analyzing incoming requests
- Routing to the most appropriate specialized agent
- Managing handoffs between agents
- Aggregating results from multiple agents
- Returning cohesive final output
Available agents:
- researcher: Gathers information, searches documentation
- coder: Implements code, follows specifications
- reviewer: Reviews code quality, security, best practices
When you receive a request:
1. Analyze what's needed
2. Route to the best agent
3. Manage any necessary handoffs
4. Return the final result`,
handoffTo: ['researcher', 'coder', 'reviewer']
});
agents/researcher.ts
import { createAgent } from '@ai-sdk-tools/agents';
import { anthropic } from '@ai-sdk/anthropic';
import { z } from 'zod';
export const researcher = createAgent({
name: 'researcher',
model: anthropic('claude-3-5-sonnet-20241022'),
system: `You are a research specialist. Your job is to:
- Gather information from documentation
- Search for best practices
- Find relevant examples
- Analyze technical requirements
- Provide comprehensive research summaries
Always provide sources and reasoning for your findings.`,
tools: {
search: {
description: 'Search for information',
parameters: z.object({
query: z.string().describe('Search query'),
sources: z.array(z.string()).optional().describe('Specific sources to search')
}),
execute: async ({ query, sources }) => {
return {
results: `Research results for: ${query}`,
sources: sources || ['documentation', ]
};
}
}
},
: [, ]
});
agents/coder.ts
import { createAgent } from '@ai-sdk-tools/agents';
import { anthropic } from '@ai-sdk/anthropic';
export const coder = createAgent({
name: 'coder',
model: anthropic('claude-3-5-sonnet-20241022'),
system: `You are a code implementation specialist. Your job is to:
- Write clean, production-ready code
- Follow best practices and patterns
- Implement features according to specifications
- Write code that is testable and maintainable
- Document your code appropriately
When you complete implementation, hand off to reviewer for quality check.`,
handoffTo: ['reviewer', 'coordinator']
});
agents/reviewer.ts
import { createAgent } from '@ai-sdk-tools/agents';
import { anthropic } from '@ai-sdk/anthropic';
export const reviewer = createAgent({
name: 'reviewer',
model: anthropic('claude-3-5-sonnet-20241022'),
system: `You are a code review specialist. Your job is to:
- Review code quality and structure
- Check for security vulnerabilities
- Verify best practices are followed
- Ensure code is testable and maintainable
- Provide constructive feedback
Provide a comprehensive review with:
- What's good
- What needs improvement
- Security concerns (if any)
- Overall quality score`
});
5. Create Orchestration Setup
index.ts
import { orchestrate } from '@ai-sdk-tools/agents';
import { coordinator } from './agents/coordinator';
import { researcher } from './agents/researcher';
import { coder } from './agents/coder';
import { reviewer } from './agents/reviewer';
const agents = [coordinator, researcher, coder, reviewer];
export async function runMultiAgentTask(task: string) {
console.log(`\n🤖 Starting multi-agent task: ${task}\n`);
const result = await orchestrate({
agents,
task,
coordinator,
maxDepth: 10,
timeout: 300000,
onHandoff: (event) => {
console.log(`\n🔄 Handoff: ${event.from} → ${event.to}`);
console.log(` Reason: \n`);
},
: {
.();
.();
.();
}
});
result;
}
(. === ) {
task = process.[] || ;
(task)
.( {
.();
.(result.);
})
.( {
.(, error);
process.();
});
}
6. Create Environment Setup
.env.example
ANTHROPIC_API_KEY=your_anthropic_key_here
OPENAI_API_KEY=your_openai_key_here
GOOGLE_API_KEY=your_google_key_here
.gitignore
node_modules/
.env
dist/
*.log
7. Create Example Scripts
examples/code-generation.ts
import { runMultiAgentTask } from '../index';
async function example() {
const result = await runMultiAgentTask(
'Build a TypeScript REST API with user authentication, including tests and documentation'
);
console.log('Result:', result);
}
example();
examples/research-pipeline.ts
import { runMultiAgentTask } from '../index';
async function example() {
const result = await runMultiAgentTask(
'Research best practices for building scalable microservices with Node.js'
);
console.log('Result:', result);
}
example();
8. Update package.json
Add scripts to package.json:
{
"scripts": {
"dev": "ts-node index.ts",
"example:code": "ts-node examples/code-generation.ts",
"example:research": "ts-node examples/research-pipeline.ts",
"build": "tsc",
"start": "node dist/index.js"
},
"devDependencies": {
"@types/node": "^20.0.0",
"ts-node": "^10.9.0",
"typescript": "^5.0.0"
}
}
9. Create TypeScript Config
tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"outDir": "./dist",
"rootDir": "./",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"declarationMap":
10. Create README
README.md
# Multi-Agent Orchestration Project
Built with AI SDK v5 and @ai-sdk-tools/agents
## Setup
1. Install dependencies:
```bash
npm install
-
Configure API keys:
cp .env.example .env
-
Run examples:
npm run example:code
npm run example:research
Available Agents
- coordinator - Routes requests to specialized agents
- researcher - Gathers information and best practices
- coder - Implements features and writes code
- reviewer - Reviews code quality and security
Usage
import { runMultiAgentTask } from './index';
const result = await runMultiAgentTask('Your task here');
console.log(result.output);
Architecture
The system uses agent handoffs to coordinate complex tasks:
- Coordinator receives request
- Routes to appropriate specialist
- Specialists hand off to each other as needed
- Final result aggregated by coordinator
# Completion Steps
After creating all files:
1. **Install TypeScript tooling**:
```bash
npm install -D typescript ts-node @types/node
-
Create .env from example:
cp .env.example .env
echo "⚠️ Please edit .env and add your API keys"
-
Test the setup:
npm run dev "Build a simple TODO API"
-
Inform user:
✅ Multi-agent project setup complete!
📁 Project structure:
agents/
├── coordinator.ts
├── researcher.ts
├── coder.ts
└── reviewer.ts
examples/
├── code-generation.ts
└── research-pipeline.ts
index.ts
.env.example
tsconfig.json
package.json
README.md
📝 Next steps:
1. Add your API keys to .env
2. Run: npm run dev "Your task here"
3. Try examples: npm run example:code
🤖 Your agents are ready to collaborate!
Template Options
Ask the user which template they want:
- Basic (default) - Coordinator + 3 specialists (researcher, coder, reviewer)
- Research - Research-focused agents (searcher, analyzer, synthesizer, reporter)
- Content - Content creation agents (researcher, writer, editor, SEO, publisher)
- Support - Customer support agents (triager, FAQ bot, technical, escalator)
- DevOps - DevOps agents (monitor, diagnoser, fixer, notifier)
If user specifies a template, adjust the agents accordingly.