k
korAI
AI 뉴스 전체
📰 AI 뉴스2026-04-155분

Tool Use 업데이트 — 스키마 검증·재시도 자동화 강화

Anthropic이 Tool Use API의 스키마 검증 레이어를 강화했다. JSON 스키마 위반 시 모델이 자동 재시도하며, 개발자가 받는 응답은 거의 항상 유효한 구조.

anthropictool-useapi

무엇이 바뀌었나

기존에도 tool_use 블록은 JSON 구조를 보장했지만, enum / required / 숫자 범위 같은 세부 제약은 종종 위반됐다. 이번 업데이트로 서버단에서 스키마 검증 후 자동 재시도가 들어갔다.

개발자 체감

  • input.category 가 enum 외 값으로 오는 경우 거의 사라짐
  • required 필드 누락이 줄어듦
  • 그럼에도 클라이언트 검증 코드는 유지 권장 (방어적 코딩)

예시 — 감정 분류기

const result = await client.messages.create({
  model: "claude-haiku-4-5",
  max_tokens: 256,
  tools: [{
    name: "classify_sentiment",
    description: "감정을 분류한다",
    input_schema: {
      type: "object",
      properties: {
        sentiment: { type: "string", enum: ["positive", "neutral", "negative"] },
        confidence: { type: "number", minimum: 0, maximum: 1 },
        reasoning: { type: "string", maxLength: 200 },
      },
      required: ["sentiment", "confidence"],
    },
  }],
  tool_choice: { type: "tool", name: "classify_sentiment" },
  messages: [{ role: "user", content: customerMessage }],
})

const call = result.content.find(c => c.type === "tool_use")
const { sentiment, confidence } = call!.input as any

사용 팁

  • 설명 필드를 상세히description을 잘 쓰면 모델이 의도를 더 잘 이해
  • enum은 실제 코드가 분기 처리할 수 있는 값만 넣어라
  • 출력 포맷이 핵심인 모든 워크로드는 tool use 로 전환
  • 일반 문자열 출력보다 토큰 사용량이 약간 늘 수 있으나 파싱 실패 제로가 값어치
출처: Anthropic Docs