Multi-agent teamwork functionality for Robota SDK - dynamic agent coordination and task delegation
npm install @robota-sdk/teamMulti-agent collaboration system for the Robota SDK with advanced workflow management.
The @robota-sdk/team package enables multi-agent collaboration with template-based specialist coordination. It provides a system where a primary agent can delegate subtasks to temporary specialist agents, using pre-configured templates for different types of work.
``bash`
npm install @robota-sdk/team @robota-sdk/agents
`typescript
import { createTeam } from '@robota-sdk/team';
import { OpenAIProvider } from '@robota-sdk/openai';
import { AnthropicProvider } from '@robota-sdk/anthropic';
// Create AI providers
const openaiProvider = new OpenAIProvider({ apiKey: process.env.OPENAI_API_KEY });
const anthropicProvider = new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY });
// Create team with template-based expert selection
const team = createTeam({
aiProviders: [openaiProvider, anthropicProvider]
});
// Execute complex task - automatic expert delegation
const result = await team.execute(
Analyze the market for sustainable energy solutions and develop 3 innovative product concepts.
Include market research, competitive analysis, and detailed product specifications.);
console.log(result);
`
Main class for managing multi-agent teams.
`typescript`
class TeamContainer {
constructor(config: TeamConfig)
// Workflow execution
execute(input: string): Promise
// Team management
addAgent(name: string, agent: AgentInterface): void
removeAgent(name: string): void
getAgent(name: string): AgentInterface | undefined
// Analytics
getStats(): TeamStats
}
`typescript`
interface TeamConfig {
name: string;
agents: Record
workflow?: {
description: string;
steps: WorkflowStep[];
};
options?: {
maxConcurrent?: number;
timeout?: number;
retryPolicy?: RetryPolicy;
};
}
`typescript
interface WorkflowStep {
agent: string;
task: string;
dependsOn?: string[];
condition?: (context: WorkflowContext) => boolean;
timeout?: number;
}
interface WorkflowResult {
success: boolean;
results: Record
metadata: {
totalTime: number;
agentsUsed: string[];
stepResults: StepResult[];
};
}
`
``
packages/team/src/
āāā team-container.ts # Main TeamContainer class
āāā create-team.ts # Team creation utilities
āāā workflow-formatter.ts # Workflow result formatting
āāā types.ts # TypeScript definitions
āāā index.ts # Public exports
- Agent System: Works with any agent implementing AgentInterface
- Plugin System: Inherits all agent plugin capabilities
- Analytics: Aggregates metrics from all team members
- Error Handling: Unified error management across team operations
`typescript`
const team = createTeam({
name: 'Sequential Team',
workflow: {
steps: [
{ agent: 'researcher', task: 'Gather information' },
{ agent: 'analyst', task: 'Analyze data' },
{ agent: 'reporter', task: 'Generate report' }
]
}
});
`typescript`
const team = createTeam({
name: 'Parallel Team',
workflow: {
steps: [
{ agent: 'agent1', task: 'Task A' },
{ agent: 'agent2', task: 'Task B' },
{ agent: 'agent3', task: 'Task C' }
]
},
options: { maxConcurrent: 3 }
});
`typescript`
const team = createTeam({
name: 'Conditional Team',
workflow: {
steps: [
{ agent: 'classifier', task: 'Classify input' },
{
agent: 'specialist1',
task: 'Handle type A',
condition: (ctx) => ctx.classification === 'typeA'
},
{
agent: 'specialist2',
task: 'Handle type B',
condition: (ctx) => ctx.classification === 'typeB'
}
]
}
});
Pre-configured team setups for common scenarios:
`bash`
npm run build
`bash`
npm run test
`bash``
npm run lint
npm run lint:fix
- Basic Team Setup
- Sequential Workflows
- Parallel Processing
- Conditional Logic
- Team Analytics
1. Agent Specialization: Design agents with specific roles and capabilities
2. Error Handling: Implement robust error recovery in workflows
3. Resource Management: Monitor and optimize agent resource usage
4. Task Granularity: Break down complex tasks into manageable steps
5. Performance Monitoring: Regularly analyze team performance metrics
MIT