Add Multiple Agents

Learn how to run and manage multiple AI agents simultaneously in your IrisOS project.

Overview

IrisOS allows you to create and run multiple agents concurrently, each with their own unique personality, capabilities, and goals. This is useful for:

  • Running specialized agents for different tasks

  • A/B testing different agent configurations

  • Building multi-agent collaboration systems

  • Separating production and development agents

Creating Multiple Agents

Using the API

Create multiple agents by making separate API calls:

const axios = require('axios');

const API_BASE = 'https://api.irisos.xyz/v1';
const API_KEY = process.env.IRIS_API_KEY;

const client = axios.create({
  baseURL: API_BASE,
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  }
});

async function createMultipleAgents() {
  // Agent 1: DeFi Expert
  const defiAgent = await client.post('/agents', {
    name: 'DeFi Oracle',
    bio: ['Expert in DeFi protocols and yield farming'],
    personality: {
      traits: ['analytical', 'data-driven', 'patient'],
      style: 'technical and precise'
    },
    modelProvider: 'openai',
    model: 'gpt-4',
    plugins: [
      { name: '@irisos/plugin-evm', enabled: true }
    ]
  });

  // Agent 2: Social Media Manager
  const socialAgent = await client.post('/agents', {
    name: 'Social Butterfly',
    bio: ['Community engagement specialist'],
    personality: {
      traits: ['friendly', 'enthusiastic', 'creative'],
      style: 'casual and engaging'
    },
    clients: ['discord', 'twitter'],
    modelProvider: 'anthropic',
    model: 'claude-3-sonnet'
  });

  // Agent 3: Research Assistant
  const researchAgent = await client.post('/agents', {
    name: 'Research Bot',
    bio: ['I gather and analyze information from various sources'],
    personality: {
      traits: ['thorough', 'objective', 'organized'],
      style: 'professional and detailed'
    },
    plugins: [
      { name: '@irisos/plugin-web-scraper', enabled: true }
    ],
    modelProvider: 'openai',
    model: 'gpt-4'
  });

  return {
    defi: defiAgent.data.data,
    social: socialAgent.data.data,
    research: researchAgent.data.data
  };
}

createMultipleAgents().then(agents => {
  console.log('Created agents:', agents);
});

Agent Specialization Strategies

1. Task-Based Specialization

Assign specific tasks to each agent:

2. Platform-Based Specialization

Deploy agents for specific platforms:

Managing Multiple Agents

List All Your Agents

Update Specific Agents

Multi-Agent Coordination

Sequential Workflow

Route tasks through multiple agents:

Parallel Processing

Process tasks with multiple agents simultaneously:

Agent Communication Patterns

Hub and Spoke Pattern

Central coordinator agent delegates to specialized agents:

Consensus Pattern

Multiple agents provide opinions, system aggregates:

Resource Management

Monitoring Agent Performance

Load Balancing

Distribute work across multiple agents:

Best Practices

  1. Clear Specialization: Give each agent a distinct role and expertise

  2. Avoid Overlap: Minimize functionality overlap between agents

  3. Consistent Naming: Use clear, descriptive names for agents

  4. Monitor Performance: Track metrics for each agent

  5. Version Control: Keep agent configurations in version control

  6. Test Interactions: Test how agents work together before production

  7. Resource Limits: Set appropriate rate limits per agent

  8. Graceful Degradation: Handle agent failures without affecting others

Example: Complete Multi-Agent System

Here's a complete example of a multi-agent system for a DeFi project:

Next Steps

Need Help?

Last updated