# Can people and an AI agent edit the same spreadsheet at the same time?

> How live operational transformation and isolated drafts handle concurrent human and agent edits, with three collision cases and a two-browser test.

<https://univer.ai/blog/can-people-and-ai-edit-the-same-spreadsheet/>

*Published November 26, 2026 · By Univer Team*

**Short answer:** Yes. People and an agent can edit one live workbook if every writer uses the same collaboration service to reconcile changes. With Univer, use live collaboration for edits colleagues should see immediately and give the agent a separate Worktree draft when someone needs to check its work first.

_Product details checked on November 26, 2026._

## The scenario: a late shipment during a reorder pass

A merch planner owns a replenishment workbook. The `Reorder` sheet has one row per SKU with these columns: SKU, On hand, Inbound, Weekly sales, Target weeks of cover, and Reorder qty. A total row at the bottom sums Reorder qty and feeds a purchase-order sheet.

The planner asks an AI agent to recalculate reorder quantities for 40 SKUs. While the agent works, the warehouse emails about a late shipment: 150 units of `TEE-BLK-M` are arriving after all. The planner opens the same workbook and types 150 into Inbound for that row. They also insert a new row for a SKU that wasn't on the sheet yet.

Here is that one row in numbers:

| Field                | Before the email | After the email |
| -------------------- | ---------------- | --------------- |
| On hand              | 120              | 120             |
| Inbound              | 0                | 150             |
| Weekly sales         | 60               | 60              |
| Target cover (weeks) | 6                | 6               |
| Correct reorder qty  | 240              | 90              |

The target stock is 60 × 6 = 360 units. Before the email, the agent should order 360 − 120 − 0 = 240. After the email, the right answer is 90. What ends up in the cell depends on how the agent writes, when it read its inputs, and which collaboration model connects it to the planner.

## Two models: live OT and isolated drafts

### Live editing with operational transformation

In a live session, every edit is an operation, such as "set cell F14 to 240" or "insert one row before row 9." A collaboration server orders operations. When a client sends an operation built against an older revision, the server transforms it against the operations that landed in between, so the operation still applies sensibly. For example, a write aimed at row 14 becomes a write to row 15 if someone inserted a row above it. Every connected client then applies the same sequence and sees the same sheet.

Univer's real-time collaboration is built on OT and is a commercial server feature, along with edit history ([collaboration extensions docs](https://docs.univer.ai/server/collaboration/extensions), [pricing](https://univer.ai/pricing/)). An agent that connects as another collaborator is just another source of operations.

### Isolated drafts with review

In a draft model, the agent doesn't touch the shared workbook. It edits a separate working copy. People keep editing the original, and nothing from the agent appears there until someone reviews the draft and merges it.

Univer's server-side Worktree feature provides this. Agent work stays a draft until it is reviewed and merged ([Univer for agents](https://univer.ai/agents/)). Calling `markReady()` freezes the draft's current revision for review. Only a draft in the draft state accepts edits, so once it's marked ready, further agent writes are refused rather than quietly mixed into what the reviewer is looking at. `mergeWorktree()` merges Units, such as workbooks or documents, one at a time ([docs](https://docs.univer.ai/server/collaboration/extensions)).

### Convergence is not agreement

OT guarantees **convergence**: once operations stop arriving, every replica shows identical contents. It doesn't guarantee **agreement**, meaning that the converged value is the one the planner and the agent would both accept as correct given the current inputs.

In the scenario, both browsers can show 240 in Reorder qty for `TEE-BLK-M`, perfectly in sync, while the correct number is 90. OT did its job, but the sheet is still wrong. That gap matters most when an agent writes in bulk.

## Three collisions to trace

### Same-cell write

Suppose the planner, out of habit, types 100 directly into Reorder qty for `TEE-BLK-M` at the moment the agent writes 240 to the same cell.

**Live OT.** The two writes reach the server in some order. Both are transformed and applied, and every client converges on whichever value ends up last in the server's sequence. Neither person nor agent is asked to choose. One value simply replaces the other, and edit history records that both writes happened. Unless one side reloads and checks, neither may notice.

**Draft.** The agent's 240 sits in the draft, and the planner's 100 sits in the original. Show both values at review, where someone has to decide which value the merged workbook should keep. Don't assume the merge step will choose the right value on its own. After merging, read back the cell and compare it with the quantity the planner approved.

### Inserted row

The planner inserts a row above `TEE-BLK-M` while the agent is partway through writing quantities by row index.

**Live OT.** If the agent's write was built against the revision before the insert, the server shifts it down one row, and the value lands on the intended SKU. This is OT's main strength. The risk is an agent that caches row positions _between_ reads, re-reads part of the sheet later, and mixes old and new indices in one batch. Transformation can only correct an operation relative to the revision it claims to be based on.

**Draft.** The agent's draft never sees the insert, so its own indices stay internally consistent. The structural difference has to be reconciled at merge. Check row alignment in the merged result rather than assuming it.

A safer pattern for both models is to have the agent locate rows by a key column (SKU) rather than a fixed row number, then verify the key immediately before writing.

### Stale dependent total

This is the case behind the 240-versus-90 example. The agent read Inbound = 0, calculated 240 outside the spreadsheet, and wrote the literal number. The planner then entered 150 in Inbound. The total row sums Reorder qty, so it now overstates the order by 150 units, and the purchase-order sheet inherits the error.

**Live OT.** Everything converges, and nothing is flagged. A literal value doesn't recalculate when its inputs change.

**Draft.** The draft was computed from a snapshot that predates the shipment. Merging it brings in a number that was correct for that snapshot and wrong for the current sheet.

The fix is a design decision. Where possible, have the agent write a **formula** such as `=MAX(0, D14*E14 - B14 - C14)` instead of a computed literal, so the workbook recalculates when Inbound changes. When the agent has to write literals, for example because the quantity depends on supplier minimums it looked up, have it recalculate and read back the affected cells right before the draft is marked ready, and again after merge. Univer's CLI and skill let an existing agent calculate the workbook and read values back, as well as read and edit Excel, Word, and PowerPoint files and check rendered output ([Univer for agents](https://univer.ai/agents/)).

## Choosing between the models

| Criterion                   | Live OT session                                      | Isolated draft (Worktree)                                     |
| --------------------------- | ---------------------------------------------------- | ------------------------------------------------------------- |
| When people see agent edits | Immediately                                          | After review and merge                                        |
| Same-cell collisions        | Resolved by server order, silently                   | Visible at review, decided by a person                        |
| Inserted or deleted rows    | Transformed automatically for concurrent operations  | Reconciled at merge, so check the result                      |
| Stale computed values       | Not detected                                         | Not detected unless your review step checks them              |
| Review gate                 | None built in                                        | `markReady()` freezes a revision for review                   |
| Multi-file changes          | Each file updates live                               | Merged Unit by Unit, not atomic across Units                  |
| Best fit                    | Small, supervised edits where the person is watching | Bulk edits, overnight runs, anything feeding a purchase order |

For the reorder pass, a draft is the better default. Forty quantities that feed a purchase order deserve a review step, and the planner's late-shipment edit shouldn't race against a bulk write.

## A two-browser acceptance test

Before you trust either model with planner workbooks, run this test against your own deployment. It checks convergence and agreement separately.

**Setup**

1. Seed a workbook with the `Reorder` sheet described above: 40 SKUs, the total row, and a purchase-order sheet that references the total. Put formulas in Reorder qty for half the rows and literals for the other half.
2. Open the workbook in two browsers, A (planner) and B (observer), signed in as different users.
3. Connect the agent through the CLI, once as a live collaborator and once against a Worktree draft.

**Test 1: same-cell write (live)**

4. Have the agent write 240 to `TEE-BLK-M` Reorder qty while browser A types 100 into the same cell. Repeat ten times with the timing varied.
5. Pass for convergence: A and B show the same value every time after edits stop. Record which value won each time, and confirm that edit history lists both writes.

**Test 2: inserted row (live)**

6. Have the agent write quantities to rows 10 through 30 by index while browser A inserts a row at row 12.
7. Pass: every written value sits on the SKU it was computed for. Compare against the agent's own log of SKU and value. Repeat with the agent using SKU lookup instead of indices, and compare failure counts.

**Test 3: stale dependent total (both models)**

8. Have the agent read inputs, then pause it. In browser A, set Inbound for `TEE-BLK-M` to 150. Resume the agent.
9. Pass for convergence: A and B match. Pass for agreement: every Reorder qty equals the value recomputed from the current inputs, and the total row matches. Expect literal rows to fail this check unless the agent recalculates and reads back. That result is the point of the test.

**Test 4: draft lifecycle**

10. Run the reorder pass in a Worktree draft while browser A edits the original. Call `markReady()`, then have the agent try one more write. Pass: the write is rejected because the draft is no longer in the draft state.
11. Call `mergeWorktree()` on a change set that spans the workbook and a second Unit, such as a supplier memo document. Pass: your interface shows a separate result for each Unit, and your runbook says what to do if one Unit merges and another doesn't.
12. After the merge, repeat the agreement check from step 9.

Record pass or fail for each step, the revision identifiers involved, and screenshots from both browsers. Don't record speed numbers unless you measure them on your own infrastructure.

## Where Univer fits, and its limitations

### What the product provides

- An Apache-2.0 open-source core for spreadsheets, documents, and presentations ([docs](https://docs.univer.ai/server/collaboration/extensions)).
- Commercial server features: real-time collaboration based on OT, edit history, server-side Worktree, and XLSX conversion ([pricing](https://univer.ai/pricing/)).
- An agent CLI and skill that let an existing agent read and edit Excel, Word, and PowerPoint files, calculate and read back values, and check renders ([Univer for agents](https://univer.ai/agents/)).
- Worktree lifecycle calls: `markReady()` to freeze a revision, edits accepted only in the draft state, and `mergeWorktree()` merging Units one at a time.

### What it doesn't do for you

- OT keeps copies consistent. It doesn't tell you whether a converged value is correct.
- A merge that spans several Units isn't atomic across them. Your interface should show the result for each Unit, and your process should cover a mixed outcome.
- Don't build on the assumption that review offers cell-by-cell accept or reject, or that the system resolves conflicts by meaning, such as recognizing that a new Inbound value invalidates a Reorder qty. Those checks belong in your workflow.
- The commercial features are licensed by capacity, measured in collaborative connections and monthly exports ([pricing](https://univer.ai/pricing/)). Size live sessions with agents counted as connections, and size export-heavy workflows accordingly.

### What we recommend you build

These are workflow suggestions, not built-in features. Have agents write formulas where the logic allows it. Have them locate rows by key. Run a recalculate-and-read-back pass immediately before `markReady()`. Re-run the agreement check after merge, and show the per-Unit merge result to the person who approved it.

## FAQ

### Does OT prevent an agent from overwriting a person's edit?

No. OT makes sure every client ends up with the same contents. If a person and an agent write to the same cell, one value replaces the other according to server order. Edit history records both writes, but nobody is prompted to choose.

### If I use drafts, can the agent's work ever conflict with live edits?

Yes, at merge time. The draft was computed from an earlier state of the workbook. Changes people made in the meantime, such as new rows or new inputs, have to be reconciled, so check the merged result.

### Why can't the agent just recompute everything at merge?

It can if you build that step. The merge itself combines changes. It doesn't rerun the agent's reasoning. Have the agent recalculate and read back against the current workbook before you mark the draft ready, and check again after the merge.

### Is a multi-file merge all or nothing?

Not across Units. `mergeWorktree()` handles Units one at a time, so a change set that spans a workbook and a document can produce a different result for each. Show each result separately.

### Which parts of this need a commercial license?

Real-time OT collaboration, edit history, server-side Worktree, and XLSX conversion are commercial. The core editor is Apache-2.0. See the [pricing page](https://univer.ai/pricing/) for how capacity is measured.

To see how the CLI and skill connect an existing agent to these workflows, start at [Univer for agents](https://univer.ai/agents/).
