版本衝突
修改訂單、報價單、改到期日要帶 version;資料在讀取之後被別人改過,回 CONCURRENT_MODIFICATION,重新讀一次再送。
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) |
例子
{
"bill": "BL-000123",
"version": 3,
"due_date": "2026-12-15",
"idempotency_key": "due-date-BL-000123-20261116"
}
這段時間有人改過訂單、version 已經是 4 時:
{
"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 時
- 用
_get重新讀,拿新的version。 - 看看別人改了什麼,確認你的修改還需要、不會跟別人的改動衝突。
- 帶新的
version再送。因為參數不一樣了,請用新的idempotency_key。
order_update、quote_update 是整份換掉(客戶、買方、備註、付款方式一起送),所以一定要從最新的資料改起,不要用很久以前讀的內容。