서브 에이전트

전문화된 에이전트들이 협력하여 작업을 처리하는 지능적인 작업 위임

Overview#

서브 에이전트는 메인 에이전트가 특화된 서브 에이전트에게 작업을 지능적으로 위임하는 정교한 멀티 에이전트 협업을 가능하게 합니다. 각 서브 에이전트는 고유한 전문성, 기능, 역할을 가지고 있으며, 단일 에이전트로는 처리하기 어려운 복잡한 워크플로우를 함께 완수합니다.

새로운 기능: 서브 에이전트는 이제 그래프 워크플로우와 원활하게 통합되어, 복잡한 워크플로우 오케스트레이션 시스템 전반에 걸쳐 계층적 작업 분배를 가능하게 합니다.

Creating Sub-Agents#

서브 에이전트는 독립적으로 생성된 다음 메인 코디네이터 에이전트에 연결됩니다.

typescript
import { Agent } from '@astreus-ai/astreus';

// Create specialized sub-agents
const researcher = await Agent.create({
  name: 'ResearcherBot',
  model: 'gpt-6-astra',
  systemPrompt: 'You are an expert researcher who gathers and analyzes information thoroughly.',
  memory: true,
  knowledge: true
});

const writer = await Agent.create({
  name: 'WriterBot',
  model: 'gpt-6-astra',
  systemPrompt: 'You are a skilled content writer who creates engaging, well-structured content.',
  vision: true
});

const analyst = await Agent.create({
  name: 'AnalystBot', 
  model: 'gpt-6-astra',
  systemPrompt: 'You are a data analyst who provides insights and recommendations.',
  useTools: true
});

// Create main agent with sub-agents
const mainAgent = await Agent.create({
  name: 'CoordinatorAgent',
  model: 'gpt-6-astra',
  systemPrompt: 'You coordinate complex tasks between specialized sub-agents.',
  subAgents: [researcher, writer, analyst]
});

Delegation Strategies#

Auto Delegation#

메인 에이전트는 LLM의 지능을 활용해 작업을 분석하고 최적으로 할당합니다.

typescript
const result = await mainAgent.ask(
  'Research AI market trends, analyze the data, and write an executive summary',
  {
    useSubAgents: true,
    delegation: 'auto'  // AI-powered task distribution
  }
);

Task Analysis#

메인 에이전트가 LLM 추론을 사용해 복잡한 작업을 분석합니다.

Agent Matching#

각 서브 에이전트의 역량과 전문 분야를 평가합니다.

Optimal Assignment#

가장 적합한 에이전트에게 구체적인 하위 작업을 생성합니다.

Coordinated Execution#

실행 흐름과 결과 취합을 관리합니다.

Manual Delegation#

에이전트 ID를 사용해 특정 작업을 특정 에이전트에 명시적으로 할당합니다.

typescript
const result = await mainAgent.ask(
  'Complex multi-step project',
  {
    useSubAgents: true,
    delegation: 'manual',
    taskAssignment: {
      [researcher.id]: 'Research market opportunities in healthcare AI',
      [analyst.id]: 'Analyze market size and growth potential',
      [writer.id]: 'Create executive summary with recommendations'
    }
  }
);

Sequential Delegation#

서브 에이전트가 순서대로 작업하며 이전 결과를 바탕으로 이어갑니다.

typescript
const result = await mainAgent.ask(
  'Create a comprehensive business plan for an AI startup',
  {
    useSubAgents: true,
    delegation: 'sequential'  // Each agent builds on the previous work
  }
);

Coordination Patterns#

Parallel Execution#

서브 에이전트가 최대 효율을 위해 동시에 작업합니다.

typescript
const result = await mainAgent.ask(
  'Multi-faceted analysis task',
  {
    useSubAgents: true,
    delegation: 'auto',
    coordination: 'parallel'  // All agents work concurrently
  }
);

Sequential Execution#

서브 에이전트가 컨텍스트를 전달하며 순서대로 작업합니다.

typescript
const result = await mainAgent.ask(
  'Research → Analyze → Report workflow',
  {
    useSubAgents: true,
    delegation: 'auto', 
    coordination: 'sequential'  // Agents work in dependency order
  }
);

Sub-Agent Configuration#

Specialized Roles#

특정 전문 영역을 위해 서브 에이전트를 구성합니다.

typescript
// Research Specialist
const researcher = await Agent.create({
  name: 'ResearchSpecialist',
  systemPrompt: 'You conduct thorough research using multiple sources and methodologies.',
  knowledge: true,  // Access to knowledge base
  memory: true,     // Remember research context
  useTools: true    // Use research tools
});

// Content Creator
const creator = await Agent.create({
  name: 'ContentCreator', 
  systemPrompt: 'You create compelling content across different formats and audiences.',
  vision: true,     // Process visual content
  useTools: true    // Use content creation tools
});

// Technical Analyst
const analyst = await Agent.create({
  name: 'TechnicalAnalyst',
  systemPrompt: 'You analyze technical data and provide actionable insights.',
  useTools: true    // Use analysis tools
});

Graph Integration#

서브 에이전트는 복잡한 오케스트레이션을 위해 그래프 워크플로우와 원활하게 작동합니다.

typescript
import { Agent, Graph } from '@astreus-ai/astreus';

// Create specialized sub-agents
const researcher = await Agent.create({
  name: 'ResearchBot',
  systemPrompt: 'You conduct thorough research and analysis.',
  knowledge: true
});

const writer = await Agent.create({
  name: 'WriterBot',
  systemPrompt: 'You create compelling content and reports.',
  vision: true
});

// Main coordinator with sub-agents
const coordinator = await Agent.create({
  name: 'ProjectCoordinator',
  systemPrompt: 'You coordinate complex projects using specialized teams.',
  subAgents: [researcher, writer]
});

// Create sub-agent aware graph
const projectGraph = new Graph({
  name: 'Market Analysis Project',
  defaultAgentId: coordinator.id,
  subAgentAware: true,
  optimizeSubAgentUsage: true
}, coordinator);

// Add tasks with intelligent sub-agent delegation
const researchTask = projectGraph.addTaskNode({
  name: 'Market Research',
  prompt: 'Research AI healthcare market trends and opportunities',
  useSubAgents: true,
  subAgentDelegation: 'auto'
});

const reportTask = projectGraph.addTaskNode({
  name: 'Executive Report',
  prompt: 'Create comprehensive executive report based on research',
  dependencies: [researchTask],
  useSubAgents: true,
  subAgentCoordination: 'sequential'
});

// Execute the graph
const result = await projectGraph.run();

Graph Sub-Agent Features#

  • 자동 감지: 그래프 노드는 이점이 있을 때 자동으로 서브 에이전트를 사용합니다
  • 컨텍스트 전달: 더 나은 협업을 위해 워크플로우 컨텍스트가 서브 에이전트로 전달됩니다
  • 성능 최적화: 실시간 모니터링과 자동 전략 조정
  • 유연한 설정: 그래프 설정에서 상속받는 노드별 서브 에이전트 설정

Advanced Examples#

Content Production Pipeline#

typescript
const contentPipeline = await Agent.create({
  name: 'ContentPipeline',
  model: 'gpt-6-astra',
  subAgents: [researcher, writer, analyst]
});

const blogPost = await contentPipeline.ask(
  'Create a comprehensive blog post about quantum computing applications in finance',
  {
    useSubAgents: true,
    delegation: 'auto',
    coordination: 'sequential'
  }
);

Market Research Workflow#

typescript
const marketResearch = await Agent.create({
  name: 'MarketResearchTeam',
  model: 'gpt-6-astra',
  subAgents: [researcher, analyst, writer]
});

const report = await marketResearch.ask(
  'Analyze the fintech market and create investor presentation',
  {
    useSubAgents: true,
    delegation: 'manual',
    coordination: 'parallel',
    taskAssignment: {
      [researcher.id]: 'Research fintech market trends and competitors',
      [analyst.id]: 'Analyze market data and financial projections',
      [writer.id]: 'Create compelling investor presentation'
    }
  }
);

Response Types#

서브 에이전트 메서드는 작업에 따라 다른 응답 형식을 반환합니다.

Execute With Sub-Agents Response#

기본 서브 에이전트 실행은 최종 결합 결과를 문자열로 반환합니다.

typescript
const result = await mainAgent.executeWithSubAgents(
  "Research renewable energy and create comprehensive report",
  [researchAgent, writerAgent],
  { coordination: 'sequential' }
);

// Response: string
"Research complete: Solar and wind energy show 23% growth year-over-year. Report includes market analysis, technology trends, and investment opportunities across 15 regions."

Delegate Task Response#

작업 위임은 서브 에이전트의 응답을 문자열로 반환합니다.

typescript
const result = await mainAgent.delegateTask(
  "Translate this document to Spanish",
  translatorAgent
);

// Response: string
"Documento traducido exitosamente. El contenido ha sido adaptado para audiencia hispanohablante manteniendo el tono profesional original."

Coordinate Agents Response#

여러 에이전트를 조율하면 작업-결과 쌍의 배열을 반환합니다.

typescript
const results = await mainAgent.coordinateAgents([
  { agent: analyzerAgent, prompt: "Analyze Q4 sales data" },
  { agent: reportAgent, prompt: "Create executive summary" },
  { agent: visualizerAgent, prompt: "Generate performance charts" }
], 'sequential');

// Response structure:
[
  {
    task: {
      agent: analyzerAgent,  // IAgent object
      prompt: "Analyze Q4 sales data"
    },
    result: "Q4 analysis complete: Revenue increased 18%, top products identified, seasonal trends mapped."
  },
  {
    task: {
      agent: reportAgent,
      prompt: "Create executive summary"
    },
    result: "Executive summary created with key findings: 18% growth driven by product line expansion..."
  },
  {
    task: {
      agent: visualizerAgent,
      prompt: "Generate performance charts"
    },
    result: "Performance visualizations generated: 5 charts showing revenue trends, product mix, and regional distribution."
  }
]

Agent.ask() with Sub-Agents Response#

서브 에이전트 옵션과 함께 agent.ask()를 사용하면 최종 응답 문자열을 반환합니다.

typescript
const result = await mainAgent.ask(
  "Create market analysis presentation",
  {
    useSubAgents: true,
    delegation: 'auto',
    coordination: 'parallel'
  }
);

// Response: string
"Market analysis presentation completed with 3 specialized teams: Research team gathered competitor data, Analysis team processed financial metrics (showing 12% market growth), and Content team created 25-slide deck with executive summary."

Manual Task Assignment Response#

수동 할당 역시 결합된 결과를 문자열로 반환합니다.

typescript
const result = await coordinatorAgent.ask(
  "Develop comprehensive product launch strategy",
  {
    useSubAgents: true,
    delegation: 'manual',
    coordination: 'sequential',
    taskAssignment: {
      [marketResearcher.id]: "Research target market and competitors",
      [strategyAnalyst.id]: "Develop go-to-market strategy",
      [contentCreator.id]: "Create launch materials and messaging"
    }
  }
);

// Response: string
"Product launch strategy complete: Target market identified (tech-savvy professionals 25-40), competitive positioning defined (premium quality, mid-tier pricing), go-to-market plan created with 3-phase rollout, and launch materials prepared including website, social media, and press kit."