Fortgeschrittene Sub-Agenten
Anspruchsvolle Multi-Agent-Workflows mit komplexen Koordinationsmustern und spezialisierten Fähigkeiten erstellen.
Schnellstart#
Das vollständige Beispiel klonen#
Der einfachste Weg zum Start ist das Klonen des vollständigen Beispiel-Repositorys:
git clone https://github.com/astreus-ai/examples
cd examples/sub-agents-advanced
npm installOder nur das Paket installieren#
Wenn du lieber von Grund auf neu aufbauen möchtest:
npm install @astreus-ai/astreusUmgebungseinrichtung#
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
ANTHROPIC_API_KEY=your-anthropic-api-key-here
DB_URL=sqlite://./astreus.dbMulti-Modell-Agententeam#
import { Agent } from '@astreus-ai/astreus';
// Create diverse agent team with different models
const strategicPlanner = await Agent.create({
name: 'StrategicPlanner',
model: 'gpt-6-astra', // High reasoning for strategy
systemPrompt: 'You are a strategic business consultant with deep analytical thinking.',
memory: true,
knowledge: true
});
const creativeWriter = await Agent.create({
name: 'CreativeWriter',
model: 'claude-sonnet-5', // Excellent for creative writing
systemPrompt: 'You are a creative copywriter who crafts compelling narratives.',
vision: true
});
const dataScientist = await Agent.create({
name: 'DataScientist',
model: 'gpt-6-astra', // Strong analytical capabilities
systemPrompt: 'You are a data scientist specializing in statistical analysis and insights.',
useTools: true
});
const executiveTeam = await Agent.create({
name: 'ExecutiveTeam',
model: 'gpt-6-astra', // High-level coordination
systemPrompt: 'You coordinate executive-level strategic initiatives across expert teams.',
subAgents: [strategicPlanner, creativeWriter, dataScientist]
});
const businessPlan = await executiveTeam.ask(
'Develop comprehensive go-to-market strategy for AI-powered healthcare platform',
{
useSubAgents: true,
delegation: 'auto',
coordination: 'sequential'
}
);
console.log('Business plan completed:', businessPlan);Das Beispiel ausführen#
Falls du das Repository geklont hast:
npm run devFalls du von Grund auf neu aufgebaut hast, erstelle eine index.ts-Datei mit dem obigen Code und führe aus:
npx tsx index.tsRepository#
Das vollständige Beispiel ist auf GitHub verfügbar: examples/sub-agents-advanced