Skip to content

Commit 4e9db60

Browse files
committed
docs(ai-chat): state the transcript ordering contract for custom storage
1 parent 1a5ad1e commit 4e9db60

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

docs/ai-chat/transcript-storage.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ A few things to get right:
207207

208208
- Pick one view and stay with it. Apply `changes` if you store rows, write `transcript` if you store a document; don't mix them within one save.
209209
- `put` for a known id replaces the message in place; position and ordering don't change.
210+
- Order is a transcript position, not a write time. A document store gets it from `transcript.entries`. A row store needs an order column set once, when a `put` first inserts an id, following the order the `put`s arrive in, and left unchanged when a later `put` replaces that id in place. Don't sort by a write timestamp: a replaced message has to keep its place, and a steering message sent mid-turn sorts before the answer it shaped even though its row is written later.
210211
- `truncateAfter` and `remove` are idempotent. Applying a changeset twice gives the same result as applying it once.
211212
- `load` with no options returns the whole conversation in order. With `limit`, return the most recent messages and a `nextCursor` (the id of the oldest returned message) when earlier messages exist.
212213
- Scope reads and writes by `clientData` where your backend enforces tenancy.

0 commit comments

Comments
 (0)