types.ConversationStore

types.ConversationStore()

Storage interface for chat conversation history.

Conversations are partitioned by ConversationPartition. Implement the four abstract methods to plug any backend into Chat.enable_history().

Methods

Name Description
delete Remove a conversation. Missing ids are a no-op.
get Full record, or None if missing.
list All conversations in partition, newest-first (by created_at).
put Upsert. Rename = mutate record.title and put().
total_size Total bytes used by all conversations in partition.

delete

types.ConversationStore.delete(partition, conv_id)

Remove a conversation. Missing ids are a no-op.

get

types.ConversationStore.get(partition, conv_id)

Full record, or None if missing.

The record may be either schema version: stores may still hand back a ConversationRecordV1 (e.g. legacy data read from disk); the controller upgrades v1 records in memory on read.

list

types.ConversationStore.list(partition)

All conversations in partition, newest-first (by created_at).

put

types.ConversationStore.put(partition, record)

Upsert. Rename = mutate record.title and put().

The controller and recorder write ConversationRecordV2 records. A store may also receive a ConversationRecordV1 record; do not assume one version. Check the runtime type with isinstance(record, ConversationRecordV2). ConversationRecord is the validation and construction class, not the type of every record a store receives.

Stores that interpret record internals must read the v2 fields (active_leaf and exchange nodes) rather than the v1 fields (current_leaf, node turns/ui). A store that only serializes whole records should be checked with a v2 round trip (put then get) rather than assumed to work unchanged.

total_size

types.ConversationStore.total_size(partition)

Total bytes used by all conversations in partition.

Derived from list()’s per-record size_bytes — backends don’t need to override this unless they have a cheaper way to compute it.