This guide builds on concepts from Add Multiple Agents

Step 1: Test multi-agent configuration

We added a bunch of new features to our project. In addition to the default tests that projects ship with, let’s write some new tests to cover our new feature scope:
FeatureTest TypeWhat We’re Validating
Multi-agent configurationComponentTwo agents with unique Discord tokens, voice IDs, and plugins
Multi-agent runtimeE2EBoth agents initialize and run simultaneously
ElizaOS projects ship with comprehensive built-in tests for core functionality (character config, plugin loading, runtime behavior). For details on the default test structure, see Testing Projects.

Create component tests

Let’s create a new component test file to test the specific multi-agent features we built:
src/__tests__/multi-agent-features.test.ts
import { describe, it, expect } from 'bun:test';
import { character as shakespeare } from '../character';
import hemingway from '../../hemingway.json';

describe('multi-agent configuration', () => {
  it('loads second agent (hemingway.json)', () => {
    expect(hemingway).toBeDefined();
    expect(hemingway.name).toBe('Hemingway');
  });

  it('agents have unique Discord credentials', () => {
    expect(shakespeare.settings?.secrets?.DISCORD_API_TOKEN).toBeDefined();
    expect(hemingway.settings?.secrets?.DISCORD_API_TOKEN).toBeDefined();
    
    // Each agent must have different bot token
    expect(shakespeare.settings?.secrets?.DISCORD_API_TOKEN)
      .not.toBe(hemingway.settings?.secrets?.DISCORD_API_TOKEN);
  });

  it('includes ElevenLabs plugin in both agents', () => {
    expect(shakespeare.plugins).toContain('@elizaos/plugin-elevenlabs');
    expect(hemingway.plugins).toContain('@elizaos/plugin-elevenlabs');
  });

  it('voice is enabled for Discord', () => {
    expect(shakespeare.settings?.secrets?.DISCORD_VOICE_ENABLED).toBe('true');
    expect(hemingway.settings?.secrets?.DISCORD_VOICE_ENABLED).toBe('true');
  });

  it('each agent has unique ElevenLabs voice ID', () => {
    expect(shakespeare.settings?.secrets?.ELEVENLABS_VOICE_ID).toBe('pqHfZKP75CvOlQylNhV4');
    expect(hemingway.settings?.secrets?.ELEVENLABS_VOICE_ID).toBe('Xb7hH8MSUJpSbSDYk0k2');
  });
});

Step 2: Test runtime functionality

Create e2e tests

The project-starter.e2e.ts file already contains default tests for core functionality (agent initialization, message processing, memory storage). Add these multi-agent specific tests to the existing ProjectStarterTestSuite.tests array:
src/__tests__/e2e/project-starter.e2e.ts
export const ProjectStarterTestSuite: TestSuite = {
  name: 'project-starter-e2e',
  tests: [
    {
      name: 'agent_should_respond_to_greeting',
      fn: async (runtime: IAgentRuntime) => {
        // ... existing test code
      }
    },
    // ... other existing tests

    // Add the new multi-agent tests:
    {  
      name: 'multi_agent_project_should_load_both_agents',  
      fn: async (runtime: IAgentRuntime) => {  
        // This test validates that our multi-agent project setup works correctly
        // It should run once for each agent in the project (Shakespeare and Hemingway)
        const agentName = runtime.character.name;  
        const agentId = runtime.agentId;  
        // Verify agent has valid identity
        if (!agentName) {  
          throw new Error('Agent name is not defined');  
        }  
        if (!agentId) {  
          throw new Error('Agent ID is not defined');  
        }  
        // Check it's one of our expected agents from the multi-agent guide
        const expectedAgents = ['Shakespeare', 'Hemingway'];  
        if (!expectedAgents.some(expected => agentName.toLowerCase().includes(expected.toLowerCase()))) {  
          throw new Error(`Unexpected agent name: ${agentName}. Expected one containing: ${expectedAgents.join(', ')}`);  
        }  
        logger.info(`✓ Multi-agent project: ${agentName} initialized successfully`);  
      }  
    },  
    // Additional tests: agents_should_have_distinct_discord_configurations,
    // agents_should_have_distinct_voice_configurations, etc.

Step 3: Run and validate tests

Execute your test suite

Terminal
# Run all tests
elizaos test

# Run only component tests
elizaos test --type component

# Run only E2E tests  
elizaos test --type e2e

# Run specific test suite (case sensitive)
elizaos test --name "multi-agent"

Verify test results

For complete test runner options, see the CLI Test Reference.

What’s Next?