> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tool

> Tool 클래스는 도구 실행 한 건을 execute_tool span으로 기록합니다.

```python theme={"system"}
class Tool(BaseModel): ...
```

단일 도구 실행을 나타냅니다. execute\_tool OTel span에 매핑됩니다.

`arguments`와 `result`에는 `JSONString` 어노테이션이 적용됩니다.
호출자가 dict / list / 스칼라 값을 부여하면 SDK가 생성 시점 또는 부여 시점에
이를 JSON으로 인코딩합니다. 저장되는 값은 GenAI semconv의 전송 형식에 맞춰 항상
문자열입니다.

`Tool`은 Pydantic 모델입니다. 생성할 때 아래의 모든 필드를 키워드 인수로 설정할 수 있습니다.

`Tool`은 컨텍스트 관리자이므로 `with` 문에서 사용할 수 있습니다.

<h2 id="fields">
  필드
</h2>

| 필드 | 유형 | 기본값 |
| - | - | - |
| `name` | `str` | `''` |
| `arguments` | `JSONString` | `''` |
| `result` | `JSONString` | `''` |
| `tool_call_id` | `str` | `''` |
| `tool_type` | `str` | `''` |
| `tool_description` | `str` | `''` |
| `tool_definitions` | `str` | `''` |
| `duration_ms` | `int` | `0` |
| `started_at` | `Union[datetime, None]` | `None` |
| `ended_at` | `Union[datetime, None]` | `None` |

<h2 id="methods">
  메서드
</h2>

<h3 id="end">
  end
</h3>

```python theme={"system"}
def end() -> None: ...
```

<h3 id="start">
  start
</h3>

```python theme={"system"}
def start() -> Self: ...
```

이 span을 한 번 시작합니다. 컨텍스트 관리자로 진입할 때도 동일한 경로를 사용합니다.

<h3 id="record_error">
  record\_error
</h3>

```python theme={"system"}
def record_error(error: BaseException) -> Self: ...
```

span을 종료하지 않은 채 실패를 기록합니다. 종료할 준비가 되면 `end()`를 호출하세요.

<h3 id="set_attributes">
  set\_attributes
</h3>

```python theme={"system"}
def set_attributes(attributes: dict[str, Any]) -> Self: ...
```

이 span에 임의의 OTel 속성을 설정합니다.

키가 하나든 여러 개든 dict를 전달하세요. 키가 하나뿐이라면
`span.set_attributes({"weave.tag": "value"})`처럼 호출합니다. OTel의
`Span.set_attributes`와 동일하게 동작합니다.

`start_*` 팩토리, `start()` 또는 `with`로 span을 시작한 후,
span이 종료되기 전에 호출해야 합니다. 이 윈도우를 벗어나 호출하면 아무 작업도
수행하지 않고 경고를 로깅합니다. 일괄 수집 시에는 객체에 선언된 필드를
직접 채운 후 `log_turn` / `log_conversation`에 전달하세요.
