# 版本衝突

Agent 讀了一張訂單、過一陣子才送出修改，這段時間成員可能已經在網站上改過。為了不蓋掉別人的修改，會改既有資料的 tool 要帶 `version`。

## 哪些 tool 要帶 version

| tool | version 從哪裡拿 |
|---|---|
| `order_update` | `order_get` 回的訂單 `version` |
| `quote_update` | `quote_get` 回的報價單 `version` |
| `bill_update_due_date` | `bill_get` 回的請款單 `version`（請款單跟著訂單的 version） |

## 例子

<!-- params: bill_update_due_date -->
```json
{
  "bill": "BL-000123",
  "version": 3,
  "due_date": "2026-12-15",
  "idempotency_key": "due-date-BL-000123-20261116"
}
```

這段時間有人改過訂單、version 已經是 4 時：

```json
{
  "ok": false,
  "error": {
    "code": "CONCURRENT_MODIFICATION",
    "message": "The data was changed after you read it.",
    "field": null,
    "params": {},
    "retryable": false,
    "hint": "Read it again with the matching _get tool, then resend with the new version."
  }
}
```

## 收到 CONCURRENT_MODIFICATION 時

1. 用 `_get` 重新讀，拿新的 `version`。
2. 看看別人改了什麼，確認你的修改還需要、不會跟別人的改動衝突。
3. 帶新的 `version` 再送。因為參數不一樣了，請用**新的** `idempotency_key`。

`order_update`、`quote_update` 是整份換掉（客戶、買方、備註、付款方式一起送），所以一定要從最新的資料改起，不要用很久以前讀的內容。
