기본 서브 에이전트

복잡한 작업 위임을 위해 여러 AI 에이전트를 만들고 조율합니다.

빠른 시작#

전체 예제 클론하기#

가장 쉬운 시작 방법은 전체 예제 저장소를 클론하는 것입니다:

bash
git clone https://github.com/astreus-ai/examples
cd examples/sub-agents-basic
npm install

또는 패키지만 설치하기#

처음부터 직접 구축하려면:

bash
npm install @astreus-ai/astreus

환경 설정#

bash
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db

간단한 서브 에이전트 설정#

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

// 전문화된 서브 에이전트 생성
const researcher = await Agent.create({
  name: 'Researcher',
  model: 'gpt-6-astra',
  systemPrompt: 'You are an expert researcher who gathers comprehensive information.'
});

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

// 메인 코디네이터 에이전트 생성
const mainAgent = await Agent.create({
  name: 'Coordinator',
  model: 'gpt-6-astra',
  systemPrompt: 'You coordinate tasks between specialized agents.',
  subAgents: [researcher, writer]
});

// 자동 위임 사용
const result = await mainAgent.ask(
  'Research artificial intelligence trends and write a summary',
  {
    useSubAgents: true,
    delegation: 'auto'
  }
);

console.log(result);

예제 실행하기#

저장소를 클론했다면:

bash
npm run dev

처음부터 구축했다면, 위 코드로 index.ts 파일을 만들고 다음을 실행하세요:

bash
npx tsx index.ts

저장소#

전체 예제는 GitHub에서 확인할 수 있습니다: examples/sub-agents-basic