Build autonomous multi-agent crews
mainYou can build crews of specialized agents that automatically coordinate with each other. Instead of manual orchestration or complex state machines, you define agents with specific name and description properties. An LLM coordinator then intelligently routes tasks to the appropriate agent based on those descriptions.
To implement a crew:
- Define specialized agents using
agent({ llm, name, description }). - Create a coordinator agent using
agent({ llm }). - Use
.then({ prompt, agents: [...] })to provide the coordinator with the list of available agents. - Call
.run()to execute the autonomous workflow.
import { agent, llmOpenAI } from "@volcano.dev/agent";
const llm = llmOpenAI({ apiKey: process.env.OPENAI_API_KEY! });
// 1. Define specialized agents with clear roles
const researcher = agent({
llm,
name: "researcher",
description: "Analyzes topics, gathers data, and provides factual information.",
});
const writer = agent({
llm,
name: "writer",
description: "Creates engaging, well-structured articles and content.",
});
// 2. Create a coordinator that autonomously delegates tasks
const results = await agent({ llm })
.then({
prompt: "Create a comprehensive blog post about AI safety",
agents: [researcher, writer],
})
.run();