Skip to content

에이전트 런타임

Commander의 핵심 실행 엔진입니다. AgentRuntime은 단일 에이전트의 전체 수명주기를 관리합니다. LLM 호출, 도구 실행, 검증, 체크포인트, 재시도 — 모두 설정 가능한 토큰·스텝 예산 안에서.

구조

AgentRuntime.execute(ctx)

  ├─ acquireSlot()        ← 동시성 세마포어
  ├─ [Tenant check]       ← rate limit + 동시성 쿼터
  ├─ resolve storage      ← 테넌트 스코프 메모리 + 캐시

  ├─ [Retry loop: 0..maxRetries]
  │   ├─ callWithTimeout()       ← LLM 프로바이더
  │   ├─ [Tool execution loop]
  │   │   ├─ planner.plan()      ← 의존성 인식 실행 계획
  │   │   ├─ executeTool()       ← StepErrorBoundary → tool.execute()
  │   │   └─ cache.set()
  │   ├─ verification.check()    ← 5 품질 게이트
  │   └─ checkpoint()            ← atomic 저장

  ├─ releaseSlot()
  └─ flush traces + samples

메인 루프

  1. 슬롯 획득 — 최대 동시 run 초과 방지
  2. 테넌트 검증 — rate limit·동시성 쿼터
  3. LLM 호출 — 타임아웃 설정 가능
  4. 도구 실행ToolPlanner가 의존성을 분석해 병렬 가능 도구를 동시 실행
  5. 검증 — 5 게이트 실패 시 재시도
  6. 체크포인트 — 단계마다 atomic 영속화
  7. 트레이싱 — 실행 트레이스·LLM 샘플 flush

핵심 컴포넌트

컴포넌트파일역할
AgentRuntimeruntime/agentRuntime.ts메인 루프
ToolPlannerruntime/toolPlanner.ts의존성 인식 도구 계획
ToolOrchestratorruntime/toolOrchestrator.ts계획된 도구 실행
StepErrorBoundaryruntime/stepErrorBoundary.ts단계별 skip/retry/abort
StepTimeoutManagerruntime/stepTimeoutManager.ts단계 타임아웃
ContextCompactorruntime/contextCompactor.ts토큰 인식 메시지 압축
ContextWindowruntime/contextWindow.ts슬라이딩 윈도우
TokenGovernorruntime/tokenGovernor.ts토큰 예산
CycleDetectorruntime/cycleDetector.ts무한 루프 탐지
ToolOutputManagerruntime/toolOutputManager.ts도구 출력 토큰 예산

설정

typescript
interface AgentRuntimeConfig {
  maxStepsPerRun: number; // run당 최대 LLM→tool 사이클
  maxRetries: number; // 검증 재시도
  timeoutMs: number; // LLM 호출 타임아웃
  maxConcurrency: number; // 최대 동시 에이전트
  budgetHardCapTokens: number; // 절대 토큰 상한
}

실행 계획

도구는 LLM 응답 순서 그대로가 아닙니다. ToolPlanner가 의존성을 분석합니다.

  • 독립 도구는 동시 실행
  • 종속 도구는 선행 후 순차
  • 순환 의존성은 실행 전에 검증

관련

MIT — 멀티 에이전트 오케스트레이션을 위해.