단계 6: Collaborator 설정

이 단계에서는 전문 에이전트 간의 통신을 조정하는 A2A Collaborator Agent의 배포 및 구성을 다룹니다. 이 중앙 에이전트는 에이전트 간 워크플로우를 관리하고 네트워크 운영을 위한 통합 인터페이스를 제공합니다.

circle-exclamation

A2A Collaborator Agent 배포

workshop-module-3 디렉토리 내의 a2a-collaborator-agent 폴더로 이동합니다:

cd /workspace/workshop-module-3/a2a/a2a-collaborator-agent

A2A Collaborator Agent Runtime을 생성합니다. ECS 기반 에이전트 간을 조정할 AgentCore 런타임을 생성합니다:

python3 ./scripts/agentcore_agent_runtime.py create \
  --name a2a_collaborator_agent_runtime
chevron-right🔍 이 스크립트는 무엇을 하나요?hashtag
  1. HostAgent(Collaborator) 코드를 Docker 이미지로 빌드

  2. AgentCore Runtime 생성 (Cognito + Gateway 연결)

  3. HostAgent는 사용자 요청을 분석하여 적절한 A2A 에이전트에 위임

  4. 동시 Bedrock 호출 제한(Semaphore 2) + 지수 백오프 스로틀링 보호 포함

A2A Collaborator 배포
circle-info

이 단계는 완료하는 데 약 3-4분이 소요됩니다.

검증

AWS 콘솔에서 Amazon Bedrock AgentCorearrow-up-right 서비스로 이동합니다. Agent Runtime을 선택합니다. a2a_collaborator_agent_runtime이라는 이름의 에이전트가 생성된 것을 확인할 수 있습니다. 이 런타임은 게이트웨이를 사용하여 타겟에 접근하고 Amazon Cognito를 통해 AgentCore Identity와 통합됩니다.

A2A Collaborator 런타임

이 시점의 아키텍처

코드 분석: Collaborator (Host) Agent

HostAgent 클래스 핵심 구조

라우팅 시스템 프롬프트 핵심

send_message_tool 구현

Rate Limiting 메커니즘

메커니즘
구현
설명

Semaphore

Semaphore(2)

최대 2개 동시 Bedrock API 호출

Minimum Delay

1.0초

API 호출 간 최소 대기 시간

Exponential Backoff

2s → 4s → 8s

스로틀링 발생 시 재시도 간격

Duplicate Prevention

completed_requests set

동일 요청 중복 전송 방지

circle-info

핵심 포인트: Collaborator Agent는 자체 도구가 send_message_tool 하나뿐입니다. LLM이 시스템 프롬프트의 라우팅 규칙을 기반으로 어떤 에이전트에게 보낼지 결정하고, send_message_tool로 A2A 메시지를 전송합니다.

이 단계가 완료되었습니다. 다음 단계로 진행하세요.

마지막 업데이트