> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Agents (Multi-Agent)

> Orchestrate multiple agents working together

# Agents (Multi-Agent Orchestration)

> [!NOTE]
>
> `AgentTeam` is now the primary class name (v1.5.5+). `Agents` is a silent alias for backward compatibility. See [AgentTeam](https://praison.ai/docs/js/agent-team.md) for the latest documentation.

The `Agents` class enables multi-agent orchestration, allowing multiple agents to work together sequentially or in parallel.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    User([User]) --> Team[AgentTeam]
    Team --> A1[Agent 1]
    Team --> A2[Agent 2]
    A1 --> Out([Results])

    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff

    class Team,A1,A2 agent
    class User,Out tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

**1. Simple Usage**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, AgentTeam } from 'praisonai';

// Create agents
const researcher = new Agent({ instructions: "Research the topic thoroughly" });
const writer = new Agent({ instructions: "Write based on the research" });

// Orchestrate with array syntax
const agents = new AgentTeam([researcher, writer]);
const results = await agents.start();
```

**2. Install**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npm install praisonai
```

***

## Basic Usage

### Array Syntax (Recommended)

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, AgentTeam } from 'praisonai';

const agent1 = new Agent({ instructions: "Analyze the data" });
const agent2 = new Agent({ instructions: "Summarize the analysis" });

// Simple array syntax
const agents = new AgentTeam([agent1, agent2]);
await agents.start();
```

### Config Object Syntax

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agents = new AgentTeam({
  agents: [agent1, agent2],
  process: 'sequential',  // or 'parallel'
  verbose: true
});
```

## Process Modes

### Sequential (Default)

Agents run one after another, with each agent receiving the output of the previous:

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const researcher = new Agent({ 
  name: "Researcher",
  instructions: "Research AI trends" 
});

const writer = new Agent({ 
  name: "Writer",
  instructions: "Write an article based on the research" 
});

const agents = new AgentTeam({
  agents: [researcher, writer],
  process: 'sequential'
});

const results = await agents.start();
// researcher runs first, writer receives researcher's output
```

### Parallel

All agents run simultaneously:

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const analyst1 = new Agent({ instructions: "Analyze market A" });
const analyst2 = new Agent({ instructions: "Analyze market B" });
const analyst3 = new Agent({ instructions: "Analyze market C" });

const agents = new AgentTeam({
  agents: [analyst1, analyst2, analyst3],
  process: 'parallel'
});

const results = await agents.start();
// All analysts run at the same time
```

## Configuration Options

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface AgentsConfig {
  // Required
  agents: Agent[];              // Array of Agent instances
  
  // Optional
  tasks?: string[];             // Custom tasks for each agent
  process?: 'sequential' | 'parallel';  // Execution mode
  verbose?: boolean;            // Enable logging
  pretty?: boolean;             // Pretty output formatting
}
```

## Custom Tasks

Override agent instructions with specific tasks:

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agents = new AgentTeam({
  agents: [researcher, writer],
  tasks: [
    "Research the history of artificial intelligence",
    "Write a 500-word summary of the research"
  ]
});
```

## Examples

### Research Pipeline

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, AgentTeam } from 'praisonai';

const researcher = new Agent({
  name: "Researcher",
  instructions: "You are a thorough researcher. Find key facts and data."
});

const analyst = new Agent({
  name: "Analyst", 
  instructions: "You analyze research findings and identify patterns."
});

const writer = new Agent({
  name: "Writer",
  instructions: "You write clear, engaging content based on analysis."
});

const pipeline = new AgentTeam([researcher, analyst, writer]);
const results = await pipeline.start();

console.log("Research:", results[0]);
console.log("Analysis:", results[1]);
console.log("Article:", results[2]);
```

### Parallel Analysis

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const sentimentAgent = new Agent({
  instructions: "Analyze the sentiment of the text"
});

const summaryAgent = new Agent({
  instructions: "Summarize the main points"
});

const keywordsAgent = new Agent({
  instructions: "Extract key topics and keywords"
});

const agents = new AgentTeam({
  agents: [sentimentAgent, summaryAgent, keywordsAgent],
  process: 'parallel',
  tasks: [
    "Analyze: 'The product is amazing but expensive'",
    "Summarize: 'The product is amazing but expensive'",
    "Extract keywords: 'The product is amazing but expensive'"
  ]
});

const [sentiment, summary, keywords] = await agents.start();
```

### With Tools

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const searchWeb = (query: string) => `Results for: ${query}`;
const analyzeData = (data: string) => `Analysis of: ${data}`;

const researcher = new Agent({
  instructions: "Research using web search",
  tools: [searchWeb]
});

const analyst = new Agent({
  instructions: "Analyze the research data",
  tools: [analyzeData]
});

const agents = new AgentTeam([researcher, analyst]);
await agents.start();
```

## Accessing Results

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agents = new AgentTeam([agent1, agent2, agent3]);
const results = await agents.start();

// Results is an array matching agent order
results.forEach((result, index) => {
  console.log(`Agent ${index + 1}: ${result}`);
});
```

## Legacy Compatibility

`Agents` is an alias for `AgentTeam`:

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// Both are equivalent
import { AgentTeam, Agents } from 'praisonai';

const a1 = new AgentTeam([agent1, agent2]);
const a2 = new Agents([agent1, agent2]);

// They are the same class
console.log(AgentTeam === Agents); // true
```

## Related

> [card] [AgentTeam](https://praison.ai/docs/js/agent-team.md)
>
> Recommended team orchestration

> [card] [Agent](https://praison.ai/docs/js/agent.md)
>
> Single agent API

> [card] [Agents CLI](https://praison.ai/docs/js/agents-cli.md)
>
> CLI commands


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.