> ## 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.

# 에이전트 배치 로깅

> 이미 LLM Call을 완료했고 이를 기록해야 하는 프레임워크에서 에이전트 트레이스를 수동으로 로깅합니다.

export const AgentLensBanner = ({href}) => <Tip>
    <strong>This workflow is also available in CoreWeave Agent Lens.</strong> Agent Lens is the Forge experience built for tracing, monitoring, and analyzing AI agents, with automated insights into agent failures and user intents. It uses the same trace data as Weights & Biases Weave, so the traces you already send appear there with nothing to migrate.{' '}
    <a href={href || '/products/agent-lens'}>{href ? 'See how to do this in Agent Lens' : 'Learn about Agent Lens'}</a>.
  </Tip>;

<AgentLensBanner href="/ko/products/agent-lens/tracing/batch-logging" />

이미 LLM Call을 완료하여 기록만 하면 되는 프레임워크에서는 `weave.log_turn`과 `weave.log_conversation`을 사용하세요. 모든 span은 컨텍스트 관리자를 열어 둔 상태로 유지하지 않고 즉시 생성되고 종료됩니다.

이 방식으로 로깅한 데이터는 과거 데이터일 수 있습니다. 실시간 대화는 필요하지 않습니다. `conversation_id`를 대화를 고유하게 식별하는 임의의 고정 문자열로 설정하세요. 동일한 `conversation_id`를 공유하는 턴은 **Agents** 뷰에서 하나의 대화로 그룹화됩니다.

자체 에이전트 루프를 구축하는 경우에는 대신 [에이전트 트레이싱](/ko/products/wandb/weave/guides/tracking/trace-agents)에 설명된 실시간 계측 API를 사용하세요.

<h2 id="log-a-turn">
  턴 로깅하기
</h2>

이미 완료된 단일 턴을 기록하려면 `weave.log_turn`을 사용하세요. 이 함수는 모든 LLM span과 도구 span을 포함한 완성된 턴을 받습니다.

<Tabs>
  <Tab title="Python">
    ```python lines highlight="1,3,28" theme={"system"}
    weave.init("[YOUR-TEAM]/[YOUR-PROJECT]")

    from weave.conversation import LLM, Message, Tool, Usage

    llm_span = LLM(
        model="gpt-4o",
        provider_name="openai",
        input_messages=[Message(role="user", content="What is the weather?")],
        output_messages=[Message(role="assistant", content="Let me check.")],
        usage=Usage(input_tokens=100, output_tokens=20),
    )

    tool_span = Tool(
        name="get_weather",
        arguments='{"city": "Tokyo"}',
        result='"24°C, sunny"',
    )

    llm_span2 = LLM(
        model="gpt-4o",
        provider_name="openai",
        input_messages=[Message(role="user", content="What is the weather?")],
        output_messages=[Message(role="assistant", content="It is 24°C and sunny.")],
        usage=Usage(input_tokens=150, output_tokens=30),
    )

    # 모든 span과 함께 턴을 로깅합니다.
    weave.log_turn(
        conversation_id="my-conversation-abc",
        agent_name="weather-bot",
        messages=[
            Message(role="user", content="What is the weather in Tokyo?"),
            Message(role="assistant", content="It is 24°C and sunny in Tokyo."),
        ],
        spans=[llm_span, tool_span, llm_span2],
    )
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    이 기능은 아직 TypeScript SDK에서 사용할 수 없습니다.
    ```
  </Tab>
</Tabs>

`log_turn`은 생성된 span의 트레이스 ID가 담긴 `LogResult`를 반환합니다.

`log_turn`의 선택 매개변수인 `model`은 하위 LLM span이 아닌 턴 자체의 span에 모델을 설정합니다. 각 `LLM` span은 저마다 독립적인 `model` 값을 가집니다. 한 턴에서 여러 모델을 사용한다면 해당 턴의 주 모델로 여기는 모델을 `log_turn`의 `model`에 설정하세요.

<h2 id="log-a-conversation">
  대화 로깅하기
</h2>

여러 턴으로 구성된 전체 대화를 한 번에 일괄 임포트하려면 `weave.log_conversation`을 사용하세요. `turns` 매개변수는 `Turn` 객체의 목록을 받으며, 각 객체는 앞의 `log_turn` 예시와 동일한 방식으로 생성합니다.

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}
    weave.log_conversation(
        conversation_id="my-conversation-abc",
        agent_name="weather-bot",
        turns=[turn_1, turn_2],
    )
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    이 기능은 아직 TypeScript SDK에서 사용할 수 없습니다.
    ```
  </Tab>
</Tabs>
