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

# Conversation

> Multi-turn stateful interactions with an agent

<Info>
  Source: [`10_conversation.py`](https://github.com/opper-ai/opper-sdks/blob/main/python/examples/agents/10_conversation.py) · [`10-conversation.ts`](https://github.com/opper-ai/opper-sdks/blob/main/typescript/examples/agents/10-conversation.ts)
</Info>

`agent.conversation()` returns a `Conversation` object that tracks message history across turns. Each `.send()` (or `.stream()`) call sees prior context automatically, so you don't manage the items array yourself.

## Multi-turn

<CodeGroup>
  ```python Python theme={null}
  agent = Agent(name="note-assistant", instructions="...", tools=[save_note, list_notes])

  conv = agent.conversation()

  await conv.send("My name is Alice. Remember that.")
  await conv.send("Save a note: buy groceries")
  r = await conv.send("What's my name, and what notes have I saved?")

  print(r.output)             # references Alice and the note
  print(len(conv.get_items()))  # full message history
  ```

  ```typescript TypeScript theme={null}
  const agent = new Agent({ name: "note-assistant", instructions: "...", tools: [saveNote, listNotes] });

  const conv = agent.conversation();

  await conv.send("My name is Alice. Remember that.");
  await conv.send("Save a note: buy groceries");
  const r = await conv.send("What's my name, and what notes have I saved?");

  console.log(r.output);
  console.log(conv.getItems().length);
  ```
</CodeGroup>

## Streaming inside a conversation

`conv.stream(input)` works the same as `agent.stream(input)`, but the conversation accumulates the streamed turn into its history once `.result()` resolves.

```python theme={null}
stream = conv.stream("Summarize everything we discussed.")
async for event in stream:
    if event.type == "text_delta":
        print(event.text, end="", flush=True)
result = await stream.result()
```

## Resetting

`conv.clear()` empties the history and starts fresh. There is no built-in persistence, so serialize `conv.get_items()` / `conv.getItems()` yourself if you need to resume across processes.
