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

# Conversation

> Conversation クラスは、複数のターンを 1 つの会話 ID でグループ化します。

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

会話を表します。conversation\_id ごとにターンをグループ化します (スパンは作成しません) 。

`continue_parent_trace` は、この会話が作成するターンのトレース分離を制御します。
デフォルトの `False` では、各ターンがそれぞれ独自の OTel
トレースを開始します (スタンドアロンの Conversations タブのビューにはこの設定が適しています) 。エージェントの invocation を含めるべき外側のトレース (たとえば fastapi でインストルメントされた
リクエスト) がアプリケーションにある場合は、`True` に設定します。

`Conversation` は Pydantic モデルです。インスタンスを構築する際に、以下の任意のフィールドをキーワード引数として指定できます。

`Conversation` はコンテキストマネージャーであり、`with` ステートメントで使用できます。

<h2 id="fields">
  フィールド
</h2>

| フィールド | タイプ | デフォルト | 説明 |
| - | - | - | - |
| `conversation_id` | `str` | `''` | |
| `conversation_name` | `str` | `''` | |
| `agent_name` | `str` | `''` | 各ターンが継承する会話レベルのデフォルト値です (ターン側で値を指定した場合はそちらが優先されます) 。system\_instructions はターンごとに異なるため、対象外です。 |
| `model` | `str` | `''` | |
| `agent_id` | `str` | `''` | |
| `agent_description` | `str` | `''` | |
| `agent_version` | `str` | `''` | |
| `include_content` | `bool` | `True` | |
| `continue_parent_trace` | `bool` | `False` | |
| `attributes` | `dict[str, Any]` | `{}` | この会話が出力するすべてのスパンに付与される属性です。 |

<h2 id="methods">
  メソッド
</h2>

<h3 id="start_turn">
  start\_turn
</h3>

```python theme={"system"}
def start_turn(
    *,
    user_message: str = '',
    model: str = '',
    agent_name: str = '',
    agent_id: str = '',
    agent_description: str = '',
    agent_version: str = '',
    system_instructions: Union[list[str], None] = None,
) -> Turn: ...
```

ターンを作成して開始します。前のターンがまだ開いている場合は、自動的に終了します。

`_current_turn` contextvar を設定するため、コンテキストマネージャーを使用するかどうかにかかわらず、
`get_current_turn()` でターンを参照できます。
`agent_name` / `model` / `agent_id` / `agent_description`
/ `agent_version` は、空のままにするとそれぞれ会話のデフォルト値が使用されます。
`continue_parent_trace` は継承されます。これらはいずれも、後から
`turn.record(...)` で上書きできます。

`system_instructions` (エージェントのシステムプロンプト) は、ターンの
invoke\_agent スパンに保持されます。`start_llm` と同様に、返された `Turn` の
属性に値を代入して後から設定することもできます。

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

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