본문 바로가기
AI2026년 4월 24일10분 읽기

Anthropic Managed Agents 실전 — Claude Agent SDK 30분 가이드

YS
김영삼
조회 1
Anthropic Managed Agents 실전 — Claude Agent SDK 30분 가이드

핵심 요약

Anthropic Managed Agents는 2026년 4월 출시된 매니지드 에이전트 플랫폼. 사용자는 도구와 시스템 프롬프트만 정의하면 인프라·세션·메모리·재시도·rate limiting을 모두 Anthropic이 처리.

  • 출시: 2026-04 (Public Beta)
  • 요금: 일반 API + 25% 매니지드 surcharge
  • 기본 모델: Sonnet 4.6 (Opus도 가능)
  • SDK: Python·TypeScript·Go

1. 30분 셋업

pip install claude-agent-sdk
export ANTHROPIC_API_KEY="..."
from claude_agent import Agent, tool

@tool
def search_files(query: str, path: str = ".") -> str:
    """코드베이스에서 검색"""
    import subprocess
    result = subprocess.run(
        ["rg", "--json", query, path],
        capture_output=True, text=True
    )
    return result.stdout

@tool
def read_file(path: str) -> str:
    """파일 내용 읽기"""
    return open(path).read()

agent = Agent(
    name="code-helper",
    model="claude-sonnet-4-6",
    system="You are a coding assistant. Help users understand their codebase.",
    tools=[search_files, read_file],
)

result = agent.run("사용자 인증은 어떻게 구현되어 있나?")
print(result.text)

Agent는 search_files·read_file을 자율적으로 호출하면서 답변 작성.

2. 메모리·세션

# 세션 유지
session = agent.create_session(user_id="user_123")
session.run("React 18 마이그레이션 도와줘")
session.run("그 중 가장 위험한 부분은?")  # 이전 컨텍스트 자동 유지

# Anthropic이 세션·컨텍스트 자동 관리
# 명시적으로 종료 없이 30일 idle 후 만료

3. Long-running 작업

# 며칠 단위 task
task = agent.create_task(
    description="PR 100건 보안 리뷰",
    estimated_duration="hours"
)

# 비동기로 실행
task.start()

# 다른 세션에서 상태 조회
status = task.status()
# pending / running / completed

# 결과 받기
if status == "completed":
    result = task.result()

4. Multi-step + Plan-Execute 자동

agent = Agent(
    name="data-analyst",
    model="claude-opus-4-7",
    tools=[query_db, run_python, write_report],
    behavior={
        "planning_mode": "auto",  # 자동 plan-execute
        "max_iterations": 50,
        "reflection": True,  # 단계마다 자체 검증
    }
)

result = agent.run("지난 분기 사용자 retention 분석 보고서")
# 자동으로:
# 1. SQL 작성·실행
# 2. Python으로 분석·시각화
# 3. 보고서 작성
# 4. 자체 검증·수정

5. 도구 정의 — 타입 명시

from typing import Annotated, Literal

@tool
def create_jira_ticket(
    title: Annotated[str, "티켓 제목 (50자 이내)"],
    description: Annotated[str, "상세 설명"],
    priority: Literal["low", "medium", "high", "critical"] = "medium",
    assignee: Annotated[str | None, "할당할 사용자 ID"] = None,
) -> dict:
    """Jira 티켓 생성"""
    return jira_client.create(...)

SDK가 docstring + type hint를 자동으로 LLM tool spec으로 변환.

6. Streaming — 실시간 응답

for chunk in agent.run_stream("질문"):
    if chunk.type == "text":
        print(chunk.text, end="", flush=True)
    elif chunk.type == "tool_call":
        print(f"\n[도구 호출: {chunk.name}]")
    elif chunk.type == "tool_result":
        print(f"[결과: {chunk.summary}]\n")

7. 에러·재시도

agent = Agent(
    ...,
    retry_policy={
        "max_attempts": 5,
        "backoff": "exponential",
        "retry_on": ["tool_error", "rate_limit"]
    },
    fallback={
        "model": "claude-haiku-3-5",  # opus 한도 시 polyhumus
    }
)

8. 관측성

# 자동 trace 생성
result = agent.run("...")
print(result.trace_id)  # Anthropic 대시보드에서 확인

# 메트릭
# - 입력·출력 토큰
# - 도구 호출 수
# - 단계별 latency
# - 비용 (실시간)

9. RAG 통합

from claude_agent.retrieval import KnowledgeBase

kb = KnowledgeBase.create(
    name="company-docs",
    embedding_model="voyage-3",
)

kb.add_documents([
    {"text": "...", "metadata": {"source": "handbook"}},
    # ...
])

agent = Agent(
    ...,
    knowledge_bases=[kb],
    # Agent가 자동으로 검색·인용
)

10. 사용 비용

항목비용
입력 토큰일반 API + 25%
출력 토큰일반 API + 25%
저장된 메모리·세션$0.001/MB/일
Knowledge Base$0.001/MB/월

인프라 직접 운영 vs 25% 더 비싸지만 SRE·운영 시간 절약. 작은 팀은 매니지드가 합리적.

11. 한계

  • Public Beta — SLA 없음, 일부 변경 가능
  • 도구 호출이 모두 Anthropic 인프라 통과 — 사내망 도구는 reverse tunnel 필요
  • 오프라인·격리 환경 사용 불가 — 자체 운영 필요

12. self-hosted vs Managed 비교

항목self-hosted (LangGraph 등)Managed Agents
인프라 운영직접없음
비용API + 인프라API + 25%
커스터마이징완전제한적
스케일링직접 조정자동
관측성직접 구축기본 제공
벤더 종속낮음높음

자주 묻는 질문

실험적 단계에서 운영 도입?Public Beta. 핵심 워크로드는 자체 fallback 준비. 단 단순 챗봇·내부 도구는 즉시 활용 OK.

OpenAI Assistants API와 차이?비슷한 컨셉. 단 Anthropic이 메모리·long-running·planning을 더 잘 지원.

학습 커브?SDK 매우 단순. 이미 Claude API 익숙하면 30분 안에 첫 에이전트.

댓글 0

아직 댓글이 없습니다.
Ctrl+Enter로 등록