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

# Live editing

> Stream an agent's edits into the document a user has open in Word, ONLYOFFICE, or another editor.

One of the most common uses for a `.docx` agent is live editing: working
alongside a user in the document they already have open. The user asks for a
change, and the agent's edits appear in their editor while the agent is still
writing them. The editor can be Microsoft Word through Office.js, ONLYOFFICE,
or any client that can load a DOCX.

## How it works

Live-editing integrations share one architecture. The client sends the user's
message and the current document to your API, which runs the agent with the
Vespper tools. As the model writes an `edit_document` call, your API parses its
JSON arguments and handles each `old`/`new` pair as soon as it's complete,
without waiting for the whole call. What happens to each pair depends on the
mode.

### Direct mode

The agent changes the document directly. Each pair is applied right away, and
the updated document goes to the client. Edits are recorded as tracked changes
or applied as plain edits, depending on the
[`trackChanges`](/primitives/edit-document#control-tracked-changes-behavior)
setting.

```mermaid theme={"system"}
sequenceDiagram
    participant Client as Client (Word, ONLYOFFICE)
    participant API as Your API (agent)
    participant Vespper

    Client->>API: User message and document
    loop As the model writes each edit
        API->>Vespper: Apply the edit
        API-->>Client: Updated document
    end
```

### Suggestion mode

Each pair is proposed without changing the document and goes to the client as a
suggestion. The user reviews it, edits it if needed, then applies or discards
it. See [Suggestions](/live-editing/suggestions).

```mermaid theme={"system"}
sequenceDiagram
    participant Client as Client (Word, ONLYOFFICE)
    participant API as Your API (agent)
    participant Vespper

    Client->>API: User message and document
    loop As the model writes each edit
        API->>Vespper: Propose the edit
        API-->>Client: Suggestion
    end
    Note over Client: The user reviews and edits
    Client->>API: Suggestions the user accepted
    API->>Vespper: Apply them
    API-->>Client: Updated document
```

## Cookbooks

<Columns cols={2}>
  <Card title="Word add-in" icon="file-word" href="/cookbooks/live-editing/word-add-in">
    Stream tracked edits from an AI agent into the document open in Microsoft
    Word.
  </Card>

  <Card title="ONLYOFFICE add-in" icon="file-pen" href="/cookbooks/live-editing/onlyoffice-add-in">
    Review an agent's edits as suggestion cards in ONLYOFFICE Docs, then apply
    them.
  </Card>
</Columns>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.