Skip to main content
Used by adapters that lack server-side message history APIs (e.g. WhatsApp, Telegram). Messages are atomically appended via state.appendToList(), which is safe without holding a thread lock. Distinct from the cross-platform per-user TranscriptsApi (see transcripts.ts) — this cache is keyed by thread, not user.

Constructor

Parameters

required

Returns

ThreadHistoryCache

Methods

append()

Atomically append a message to the history for a thread. Trims to maxMessages (keeps newest) and refreshes TTL.

Parameters

string
required
required

Returns

Promise<void>

getMessages()

Get messages for a thread in chronological order (oldest first).

Parameters

string
required
The thread ID
number
Optional limit on number of messages to return (returns newest N)

Returns

Message