Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

store-reference.md

618 lines24.4 KB

1---
2title: Store Reference (Advanced)
3id: store-reference
4---
5​
6These are the public contracts from `@tanstack/ai-persistence`. Implement only the
7stores you need. Middleware turns behavior on from whichever stores are present, so
8there is no separate enable list.
9​
10| Store | Purpose | Used by |
11| --- | --- | --- |
12| `messages` | Authoritative model-message history per thread. | `withPersistence`, required |
13| `runs` | Run status, timing, errors, usage. | `withPersistence` |
14| `interrupts` | Pending, resolved or cancelled human waits. Needs `runs`. | `withPersistence` |
15| `metadata` | App and integration key/value state. | `withPersistence` |
16| `generationRuns` | Generation run status and result metadata, keyed by its own `runId`. | `withGenerationPersistence`, required |
17| `artifacts` | File metadata. Needs `blobs`. | `withGenerationPersistence`, portable snapshots |
18| `blobs` | File bytes. Needs `artifacts`. | `withGenerationPersistence`, portable snapshots |
19​
20Named groupings of the chat stores (`ChatTranscriptStores`, `ChatPersistenceStores`,
21`ChatWithInterruptsStores`) are covered in [Controls](./controls).
22​
23`runs` is typed against `RunRecord` and `RunStore` from `@tanstack/ai`, not from this
24package. One definition is what lets chat persistence and a sandbox run driver key on
25the same record instead of disagreeing about one run.
26​
27## MessageStore
28​
29```ts
30import type { ModelMessage } from '@tanstack/ai'
31​
32type MessagePage =
33 | {
34 messages: Array<ModelMessage>
35 truncated: false
36 cursor?: never
37 }
38 | {
39 messages: Array<ModelMessage>
40 truncated: true
41 cursor: string
42 }
43​
44interface MessageStore {
45 loadThread(
46 threadId: string,
47 options?: { limit?: number; before?: string },
48 ): Promise<Array<ModelMessage> | MessagePage>
49 saveThread(threadId: string, messages: Array<ModelMessage>): Promise<void>
51```
52​
53- `loadThread` with only `threadId` (middleware, `onStart`, `onFinish`) returns
54 the full array. Never a `MessagePage`.
55- `limit` and `before` are a paging hint for hydrate. You can ignore them and
56 return the full array. `reconstructChat` then slices after UI conversion.
57- To page in the database, return a `MessagePage`. `truncated: true` requires a
58 `cursor`. `truncated` and `cursor` use the same words as `BlobStore.list`.
59- If you ignore `before` and return the newest array again, `reconstructChat`
60 loads the full thread and slices.
61- `saveThread` receives the full merged list. It is a replace, not an append.
62 Merge by id is `withPersistence`, not this store.
63​
64`loadThread` returns `[]` (never `null`) for a thread that was never saved.
65​
66## RunStore
67​
68`RunStore` and `RunRecord` come from `@tanstack/ai`; `@tanstack/ai-persistence`
69re-exports both, which is why the samples on this page import them from either
70package. `RunError` is exported from `@tanstack/ai` only.
71​
72```ts
73import type { TokenUsage } from '@tanstack/ai'
74​
75type TerminalRunStatus = 'completed' | 'failed' | 'aborted'
76type RunStatus = 'running' | 'interrupted' | TerminalRunStatus
77​
78// Why a run failed. `message` is the provider's prose, which changes between
79// model versions and cannot be branched on; `code` is the stable
80// classification a consumer switches over to retry, escalate, or show a
81// specific UI. Providers do not always supply one, so `code` is optional.
82interface RunError {
83 message: string
84 code?: string
86​
87interface RunRecord {
88 runId: string
89 threadId: string
90 // Present on a subagent child run. Absent on the parent chat run.
91 parentRunId?: string
92 subagentRunId?: string
93 name?: string
94 status: RunStatus
95 startedAt: number // epoch ms
96 finishedAt?: number // epoch ms, set once the run reaches a terminal status
97 error?: RunError
98 usage?: TokenUsage // reported usage accumulated for this runId
99 // ---------------------------------------------------------------------------
100 // DURABLE SANDBOXED RUNS ONLY. A chat app never writes these four and nothing
101 // in `@tanstack/ai-persistence` reads them. Leave the columns out until you
102 // wire `withSandbox(sandbox, { runs, durability })`, and see
103 // [Build a Sandbox Adapter](./build-a-sandbox-adapter#the-four-run-fields)
104 // for what each one does and how to prove them.
105 // ---------------------------------------------------------------------------
106 sandboxKey?: string // which sandbox this run is bound to
107 detachedSince?: number // epoch ms since the last viewer left
108 cancelRequested?: boolean // an out-of-band cancel was recorded
109 driverEpoch?: number // fencing token, bumped by each host that claims the run
111​
112interface RunStore {
113 // Required: insert-if-absent. An existing runId returns the stored record
114 // unchanged, so resuming a run never resets its startedAt or status.
115 createOrResume(input: {
116 runId: string
117 threadId: string
118 status?: RunStatus
119 startedAt: number
120 // Copied on the first insert only. A later call leaves them unchanged.
121 parentRunId?: string
122 subagentRunId?: string
123 name?: string
124 }): Promise<RunRecord>
125 // Required: patching an unknown runId is a no-op, not an error.
126 update(
127 runId: string,
128 patch: Partial<
129 Pick<
130 RunRecord,
131 | 'status'
132 | 'finishedAt'
133 | 'error'
134 | 'usage'
135 | 'sandboxKey'
136 | 'detachedSince'
137 | 'cancelRequested'
138 | 'driverEpoch'
139 >
140 >,
141 ): Promise<void>
142 // Required.
143 get(runId: string): Promise<RunRecord | null>
144 // Required. The most recent 'running' run for a thread (greatest
145 // `startedAt` wins), or null when the thread is idle. `reconstructChat`
146 // calls it to report `activeRun`, which is how a hydrating client tails a
147 // run that is still generating.
148 findActiveRun(threadId: string): Promise<RunRecord | null>
149 // Optional. Every run for a thread, ascending by startedAt. Only needed to
150 // render a thread's past agent activity.
151 listByThread?(threadId: string): Promise<Array<RunRecord>>
152 // Optional. Child runs for one parent, oldest startedAt first.
153 // reconstructChat uses this to put subagent cards back on the parent message.
154 listByParentRun?(parentRunId: string): Promise<Array<RunRecord>>
155 // Optional. Runs where status is 'running' and detachedSince <= now - ttlMs
156 // (inclusive). This is the query `reapDetachedRuns` (@tanstack/ai-sandbox)
157 // runs to find abandoned runs; scheduling that sweep is the app's job.
158 listReclaimable?(opts: {
159 now: number
160 ttlMs: number
161 }): Promise<Array<RunRecord>>
163```
164​
165`withPersistence` sums reported numeric usage fields across provider calls for
166the same `runId`. The opaque `providerUsageDetails` field retains the latest
167reported bag. Known usage is persisted when the run interrupts or reaches a
168terminal status.
169​
170`createOrResume`, `update`, `get`, and `findActiveRun` are the floor: a backend
171that implements those four is a valid `RunStore`. Three contracts to hold:
172​
173- `createOrResume` must be idempotent. A second call for an existing `runId`
174 returns the complete stored record unchanged, including `usage`. This makes
175 resuming a run safe and lets usage continue accumulating. Retries may repeat
176 the same run id.
177- `update` against an unknown `runId` is a no-op.
178- `findActiveRun` must do real work. Stub it to `null` and `reconstructChat`
179 always reports `activeRun: null`, so a client that reloads (or switches back
180 to) a still-generating thread restores the transcript but never resumes the
181 live reply. Nothing detects it either, because `null` is also the right answer
182 for an idle thread. It was optional for exactly one release cycle and cost
183 precisely that, which is why it is required now.
184​
185`listByThread`, `listByParentRun`, and `listReclaimable` are optional.
186Consumers feature-detect each one. After you declare an omission of
187`listByThread` or `listReclaimable` in `skipMethods`, the conformance suite
188skips that method. Implement the ones
189your app needs:
190​
191- Skip `listByThread` and a reload loses the cards of children that a tool call
192 started. `reconstructChat` calls it to find their parent runs.
193- Skip `listByParentRun` and a reload shows the saved child text. The subagent
194 cards stay absent. `reconstructChat` calls this method to build the cards.
195 The conformance suite skips the subagent checks when this method is absent,
196 so it needs no `skipMethods` entry.
197- Skip `listReclaimable` and the store cannot be reaped: `reapDetachedRuns`
198 feature-detects it, logs one line, and sweeps nothing, so detached runs are
199 never finalized and their sandboxes never reclaimed. `detachedSince` *is*
200 populated for you by `withSandbox`'s detach path, and note that the reaper is a
201 function the application schedules, so implementing this method is necessary
202 but not by itself sufficient. See
203 [Takeover & Detached Runs](../sandbox/takeover#configuration) for the option,
204 and [Reaping & Retention](../sandbox/reaping) for the sweep itself and the
205 schedules that drive it.
206​
207The four durable-run fields are a sandbox concern, so they are documented and
208proven on the sandbox side:
209[Build a Sandbox Adapter](./build-a-sandbox-adapter#the-four-run-fields).
210`runPersistenceConformance` does not assert them, and a chat-only backend can leave
211the columns out entirely. If you do wire durable sandboxed runs, run
212`runDurableRunFieldsConformance` from `@tanstack/ai-sandbox/testkit` against the same
213`runs` store: each field breaks one mechanism silently when dropped, which is why it
214gets its own suite rather than a paragraph of warnings.
215​
216Two helpers travel with the contract, and both exist so a caller does not have
217to reach for a cast:
218​
219- Deciding "can this run still emit events?" from a bare `RunStatus` string
220 leaves you holding the wide union afterwards. `isTerminalRunStatus` is a type
221 predicate, so inside the guard the status is a `TerminalRunStatus` and can be
222 passed wherever one is required.
223​
224 ```ts
225 import { isTerminalRunStatus } from '@tanstack/ai-persistence'
226 import type { RunRecord, TerminalRunStatus } from '@tanstack/ai-persistence'
227​
228 function finalStatus(run: RunRecord): TerminalRunStatus | null {
229 return isTerminalRunStatus(run.status) ? run.status : null
230 }
231 ```
232​
233- An optional method you did implement should not need a `?.` from inside your
234 own code. `defineRunStore` is generic over the object you pass, so the result
235 keeps that object's exact shape: `createRunStore(db).findActiveRun(threadId)`
236 is a direct call on the store built in the
237 [chat walkthrough](./build-your-own-chat-adapter), while a consumer holding a
238 bare `RunStore` still feature-detects the same method.
239​
240Capability tiers belong at the STORE level, not the method level. A backend that
241genuinely has no run lifecycle should declare `ChatTranscriptStores` and omit
242`runs` entirely rather than supply a `RunStore` with a stubbed method: an absent
243store is caught by the type system, an incomplete one fails silently at runtime.
244​
245`createOrResume` copies `parentRunId`, `subagentRunId`, and `name` on the first
246insert. A second call for the same `runId` leaves those fields unchanged. If
247the caller omits a field, omit that field on the stored record. Do not write
248`''` for a field the caller did not pass.
249​
250The reference implementation, `MemoryRunStore` in
251`packages/ai-persistence/src/memory.ts`, implements all seven run methods. The
252`examples/ts-react-chat` SQLite adapter (`src/lib/sqlite-persistence.ts`)
253implements all seven run methods.
254​
255## InterruptStore
256​
257```ts
258interface InterruptRecord {
259 interruptId: string
260 runId: string
261 threadId: string
262 status: 'pending' | 'resolved' | 'cancelled'
263 requestedAt: number // epoch ms
264 resolvedAt?: number // epoch ms, set once resolved or cancelled
265 payload: Record<string, unknown>
266 response?: unknown
268​
269type InterruptCommitEntry =
270 | { interruptId: string; status: 'resolved'; response?: unknown }
271 | { interruptId: string; status: 'cancelled' }
272​
273interface InterruptStore {
274 create(record: Omit<InterruptRecord, 'status' | 'resolvedAt'>): Promise<void>
275 commitBatch?(entries: ReadonlyArray<InterruptCommitEntry>): Promise<void>
276 resolve(interruptId: string, response?: unknown): Promise<void>
277 cancel(interruptId: string): Promise<void>
278 get(interruptId: string): Promise<InterruptRecord | null>
279 list(threadId: string): Promise<Array<InterruptRecord>>
280 listPending(threadId: string): Promise<Array<InterruptRecord>>
281 listByRun(runId: string): Promise<Array<InterruptRecord>>
282 listPendingByRun(runId: string): Promise<Array<InterruptRecord>>
284```
285​
286`commitBatch` is optional. Use one database transaction for all entries when
287you implement it. The legacy `resolve` and `cancel` fallback is sequential and
288is not atomic.
289​
290If you implement `commitBatch`, reject the whole batch (throw, write nothing)
291when any entry has a duplicate `interruptId`, names an interrupt that does not
292exist, or names an interrupt that is not `'pending'`. `resolve` and `cancel`
293stay no-ops for a missing `interruptId`.
294​
295`create` accepts a record without `status`/`resolvedAt` so every interrupt is
296born `'pending'`; it is insert-if-absent, so a duplicate `create` never clobbers
297an already-resolved interrupt. The `list*` methods return records ordered by
298`requestedAt` ascending. An `interrupts` store requires a `runs` store when used
299with chat persistence.
300​
301## MetadataStore
302​
303```ts
304interface MetadataStore {
305 get(scope: string, key: string): Promise<unknown | null>
306 set(scope: string, key: string, value: unknown): Promise<void>
307 delete(scope: string, key: string): Promise<void>
309```
310​
311Namespaces and value schemas are application-owned, and `(scope, key)` is the
312composite identity. A stored `null` is indistinguishable from absence at the type
313level, so wrap a value you must persist as `null` (e.g. `{ value: null }`), or
314reject nullish values outright the way the SQLite store above does.
315​
316`withPersistence` also provides this store through the core
317`MetadataCapability`. Middleware can use it for derived state without depending
318on `@tanstack/ai-persistence`. For example, `withCompaction` stores validated
319context checkpoints here. Do not place the canonical transcript in metadata;
320the `messages` store owns it.
321​
322## GenerationRunStore
323​
324The generation counterpart to `RunStore`. Keyed by its own `runId`, with
325`threadId` the slot `findLatestForThread` looks runs up by.
326`withGenerationPersistence` requires this store, not `runs`.
327​
328Its `status` uses the same vocabulary as a chat run's `RunStatus`, so one status
329column and one set of checks cover both tables.
330​
331```ts
332import type { PersistedArtifactRef, TokenUsage } from '@tanstack/ai'
333​
334// The same vocabulary as a chat run's `RunStatus`.
335type GenerationRunStatus =
336 | 'running'
337 | 'interrupted'
338 | 'completed'
339 | 'failed'
340 | 'aborted'
341​
342interface GenerationRunRecord {
343 runId: string
344 threadId: string // the slot this run fills, hydrated by findLatestForThread
345 activity: string // 'image' | 'audio' | 'tts' | 'video' | 'transcription'
346 provider: string
347 model: string
348 status: GenerationRunStatus
349 startedAt: number // epoch ms
350 finishedAt?: number // epoch ms, set once the run reaches a terminal status
351 error?: { message: string; code?: string }
352 result?: unknown // terminal result metadata (ids, urls), never media bytes
353 artifacts?: Array<PersistedArtifactRef> // present with an artifacts + blobs backend
354 usage?: TokenUsage
356​
357interface GenerationRunStore {
358 createOrResume(input: {
359 runId: string
360 activity: string
361 provider: string
362 model: string
363 startedAt: number
364 threadId: string
365 status?: GenerationRunStatus
366 }): Promise<GenerationRunRecord>
367 update(
368 runId: string,
369 patch: Partial<
370 Pick<
371 GenerationRunRecord,
372 'status' | 'finishedAt' | 'error' | 'result' | 'artifacts' | 'usage'
373 >
374 >,
375 ): Promise<void>
376 get(runId: string): Promise<GenerationRunRecord | null>
377 // The most recent run filed under a thread (greatest `startedAt`), or null.
378 // Required: it is the only query that hydrates a generation, so an adapter
379 // without it would be indistinguishable from one whose thread has no runs:
380 // `persistence: true` would silently restore nothing, forever.
381 findLatestForThread(threadId: string): Promise<GenerationRunRecord | null>
383```
384​
385Implement `createOrResume` idempotently: a second call for an existing `runId`
386returns the stored record unchanged (`startedAt` / `activity` / `provider` /
387`model` / `threadId` are not mutated), which is what makes resuming a run safe.
388`update` against an unknown `runId` is a no-op.
389​
390## ArtifactStore
391​
392Metadata rows for persisted media. The bytes live in a `BlobStore`; this record
393holds the descriptive metadata and an optional `sourceUrl` for reference-only
394backends. Provide it together with a `BlobStore` to keep generated bytes.
395​
396```ts
397interface ArtifactRecord {
398 artifactId: string
399 runId: string
400 threadId: string
401 blobKey?: string // where the bytes live; absent on pre-blobKey records
402 name: string
403 mimeType: string
404 size: number
405 sourceUrl?: string // where the bytes were fetched FROM (provenance)
406 createdAt: number // epoch ms
408​
409interface ArtifactStore {
410 save: (record: ArtifactRecord) => Promise<void>
411 get: (artifactId: string) => Promise<ArtifactRecord | null>
412 list: (runId: string) => Promise<Array<ArtifactRecord>> // [] when the run has none
413 // Complete thread history, ordered by (createdAt, artifactId) ascending.
414 listForThread: (threadId: string) => Promise<Array<ArtifactRecord>>
415 delete: (artifactId: string) => Promise<void>
416 deleteForRun: (runId: string) => Promise<void>
418```
419​
420`list` and `listForThread` use `createdAt` first, then ordinal bytewise
421`artifactId` order. Compare UTF-8 bytes from left to right. Do not use locale
422collation.
423​
424## BlobStore
425​
426A durable object/blob store for the bytes. `withGenerationPersistence` writes
427each generated file under the key `artifacts/<runId>/<artifactId>`.
428​
429```ts
430type BlobBody =
431 | ReadableStream<Uint8Array>
432 | ArrayBuffer
433 | ArrayBufferView
434 | string
435 | Blob
436​
437interface BlobRecord {
438 key: string
439 size?: number
440 etag?: string
441 contentType?: string
442 customMetadata?: Record<string, string>
443 createdAt?: number // epoch ms first written
444 updatedAt?: number // epoch ms last overwritten
446​
447interface BlobObject extends BlobRecord {
448 arrayBuffer(): Promise<ArrayBuffer>
449 text(): Promise<string>
450 body?: ReadableStream<Uint8Array>
451 // The slice served, when a range was requested. Absent on a whole read.
452 range?: { offset: number; length: number }
454​
455interface BlobListPage {
456 objects: Array<BlobRecord>
457 cursor?: string // present only when `truncated`
458 truncated?: boolean
460​
461interface BlobPutOptions {
462 contentType?: string
463 customMetadata?: Record<string, string>
464 // Exact byte length of `body`, when the producer knows it. Advisory: use it
465 // to pick an upload strategy (single-shot vs multipart), never as a
466 // substitute for counting the bytes you actually store.
467 expectedLength?: number
469​
470interface BlobRange {
471 offset: number // from the start of the object; must be inside it
472 length?: number // defaults to "to the end"; clamped when it overshoots
474​
475interface BlobGetOptions {
476 range?: BlobRange
478​
479interface BlobListOptions {
480 prefix?: string
481 cursor?: string
482 limit?: number
484​
485interface BlobStore {
486 put(key: string, body: BlobBody, options?: BlobPutOptions): Promise<BlobRecord>
487 get(key: string, options?: BlobGetOptions): Promise<BlobObject | null>
488 head(key: string): Promise<BlobRecord | null>
489 delete(key: string): Promise<void>
490 list(options?: BlobListOptions): Promise<BlobListPage>
492```
493​
494Three contracts to hold for `list`:
495​
496- `prefix` matches literally and case-sensitively. Escape SQL `LIKE`
497 metacharacters.
498- When `limit` is given and more keys match, return `truncated: true` with a
499 `cursor`. Passing that cursor back returns the strictly-following keys, so
500 paging visits every key exactly once.
501- `limit: 0` yields an empty, untruncated page.
502​
503And one for `put`: the body can be a `ReadableStream` with **no declared
504length**. That is how a URL-fetched artifact arrives whenever the origin does
505not declare one it can be held to: a chunked reply, or a compressed one whose
506`content-length` describes the compressed bytes. (When the origin *does* declare
507a usable length, the body reaches you exactly as `fetch` produced it, length
508intact, and `expectedLength` carries the same number.) Your store must drain a
509length-less stream, not require a length up front. Backends that need a declared
510length for a single-shot upload (Cloudflare R2 on workerd is one) can re-attach
511`expectedLength` when it is present and stream through a multipart upload when it
512is not; the `ai-persistence/build-cloudflare-artifact-store` skill ships that
513recipe. The conformance testkit exercises the length-less case, so a store that
514only handles byte bodies fails the suite.
515​
516And one for `get`: honour `options.range` by returning **only that slice**.
517`size` keeps reporting the whole object, and the returned `range` reports what
518you actually served. Together they are the `206` response a media player's
519seeking depends on. `resolveBlobRange(size, range)` does the clamping (a
520`length` past the end is legal and clamps; an `offset` past the end throws,
521because a serve route should have answered `416` from `record.size` first):
522​
523```ts ignore
524import { resolveBlobRange } from '@tanstack/ai-persistence'
525​
526async get(key: string, options?: BlobGetOptions) {
527 const row = await selectBlob(key)
528 if (!row) return null
529 if (!options?.range) return blobObject(row, row.body)
530 const served = resolveBlobRange(row.size, options.range)
531 // Slice at the storage layer, not after loading the whole object.
532 const bytes = await selectBlobSlice(key, served.offset, served.length)
533 return blobObject(row, bytes, served)
535```
536​
537This is not optional for a store that holds bytes, and the conformance testkit
538asserts it. Ignoring `range` and returning the whole file is what makes
539`<video>` seeking (and Safari playback at all) fail, and it silently sends the
540entire artifact for every seek. A reference-only backend that stores no bytes
541skips `blobs` altogether instead.
542​
543## How the records relate
544​
545The thread is not a table of its own: it exists as the `thread_id` the other records
546hang off. `metadata` stands apart, keyed by `(namespace, key)`. Note the asymmetry on
547the generation side, where a run is keyed by its own `run_id` first and its
548`thread_id` names the slot the run fills, which is what `findLatestForThread`
549hydrates by.
550​
551```mermaid
552erDiagram
553 MESSAGES ||--o{ RUN : "thread_id, a thread has many runs"
554 RUN ||--o{ INTERRUPT : "run_id, a run may pause on interrupts"
555 MESSAGES ||..o{ GENERATION_RUN : "thread_id, the slot a run fills"
556 GENERATION_RUN ||--o{ ARTIFACT : "run_id, a run produces artifacts"
557 ARTIFACT ||--|| BLOB : "blob_key, the bytes"
558​
559 MESSAGES {
560 string thread_id PK
561 json messages_json "full transcript, overwritten on save"
562 }
563 RUN {
564 string run_id PK
565 string thread_id
566 string status "running | completed | failed | interrupted"
567 int started_at
568 int finished_at
569 }
570 INTERRUPT {
571 string interrupt_id PK
572 string run_id
573 string thread_id
574 string status "pending | resolved | cancelled"
575 int requested_at
576 }
577 GENERATION_RUN {
578 string run_id PK
579 string thread_id "the slot this run fills"
580 string activity "image | audio | tts | video | transcription"
581 string status "running | completed | failed | interrupted"
582 }
583 ARTIFACT {
584 string artifact_id PK
585 string run_id
586 string blob_key "where the bytes live"
587 string mime_type
588 int size
589 }
590 BLOB {
591 string key PK
592 blob bytes
593 }
594```
595​
596## Typing an adapter
597​
598Each store has a `define*Store` helper (`defineMessageStore`, `defineRunStore`,
599`defineInterruptStore`, `defineMetadataStore`, `defineGenerationRunStore`,
600`defineArtifactStore`, `defineBlobStore`). They compose into `defineAIPersistence`,
601which tracks exact presence: the stores you passed autocomplete on
602`persistence.stores`, and reading one you did not pass is a compile error.
603​
604Those seven keys are the only ones `stores` accepts. Anything else throws
605`Unknown AIPersistence store key` at construction.
606​
607To annotate the value instead, use a named shape:
608​
609- `ChatPersistence`: all four chat stores.
610- `ChatTranscriptPersistence`: the `messages` floor.
611- `AIPersistence`: the all-optional bag. `withPersistence` rejects it, because
612 `stores.messages` is possibly `undefined`.
613​
614## Where to go next
615​
616- [Build a chat adapter](./build-your-own-chat-adapter): these contracts implemented against SQLite.
617- [Build a generation adapter](./build-your-own-generation-adapter): the generation half.
618- [Build your own adapter](./build-your-own-adapter#verify-with-the-conformance-suite): check an implementation against the conformance suite.