> Fetch the index of every Tonbo docs page as Markdown at https://tonbo.dev/llms.txt

# Rules for streams

Last updated 29 October 2026

Check your writers and readers against these rules before you rely on them: each one keeps messages from being lost or doubled, keys narrow, or the bill small.

Each rule links to its page, which shows what to send and what not to.

## Writers

- [Send producer headers with every append](https://tonbo.dev/docs/streams/rules/writers.md#producer-headers)
- [When an answer is lost, send the same request again](https://tonbo.dev/docs/streams/rules/writers.md#same-request)
- [Give each writer its own producer id, and stop when refused](https://tonbo.dev/docs/streams/rules/writers.md#one-producer)
- [Batch small messages into one append](https://tonbo.dev/docs/streams/rules/writers.md#batch)
- [Close a stream when its writer is done, and let runs expire](https://tonbo.dev/docs/streams/rules/writers.md#close-and-expire)

## Readers

- [Keep offsets exactly as the stream returns them](https://tonbo.dev/docs/streams/rules/readers.md#offsets)
- [Read until the answer is up to date](https://tonbo.dev/docs/streams/rules/readers.md#up-to-date)
- [Save a reader’s offset with what it did](https://tonbo.dev/docs/streams/rules/readers.md#save-offset)
- [Reopen a tail from the last offset it gave you](https://tonbo.dev/docs/streams/rules/readers.md#reopen)
- [Guard against a stream deleted and created again](https://tonbo.dev/docs/streams/rules/readers.md#incarnation)
- [Publish a snapshot, check it, then advance retention](https://tonbo.dev/docs/streams/rules/readers.md#snapshot-then-retention)

## Keys and errors

- [Exchange an Agent’s key before you send it](https://tonbo.dev/docs/streams/rules/keys.md#token)
- [Give each program a key narrowed to its streams](https://tonbo.dev/docs/streams/rules/keys.md#narrow)
- [Give a web page a token for its streams, never a key](https://tonbo.dev/docs/streams/rules/keys.md#browsers)
- [Match a refusal’s code, never its message](https://tonbo.dev/docs/streams/rules/keys.md#codes)
