# Durable messaging

Durable messaging stores a conversation's messages, branches and read state across refreshes, reconnects and long-running work.

```mermaid
flowchart LR
  Conversation[Conversation] --> Messages[Messages]
  Messages --> Parts[Typed message parts]
  Messages --> Branches[Branches]
  Conversation --> Participants[Participants]
  Conversation --> ReadState[Read state]
  Conversation --> InputRequests[Input requests]
```

## What it owns

| Concept       | Purpose                                                                                        |
| ------------- | ---------------------------------------------------------------------------------------------- |
| Conversation  | Thread metadata, project scope, status, title, active branch, and message count.               |
| Message       | User, assistant, system, or tool content.                                                      |
| Message part  | Structured content such as text, files, tool calls, tool results, citations, errors, and data. |
| Branch        | Alternate message path created by edits, forks, or regenerated answers.                        |
| Participant   | User and role attached to a conversation.                                                      |
| Read state    | Last-read cursor and unread count.                                                             |
| Input request | Structured input needed while work is paused.                                                  |

## Message graph

Messages form a graph through parent links. The conversation records the active branch tip. Editing, forking and branch selection preserve alternate paths.

## Messaging and execution

Saving a message persists conversation state. A separate run request starts execution:

1. A user prompt is stored as a message.
2. The client requests a run, which creates or claims an assistant message.
3. Runtime events stream and persist while work runs.
4. Final output is stored back on the assistant message.
5. Later reads use messages for the visible thread and runs for execution history.
