Skip to main content

Module chat_message_store

Module chat_message_store 

Source
Expand description

A Redis-backed HistoryProvider: conversation history stored in a Redis LIST.

Mirrors the Python agent_framework_redis.RedisChatMessageStore: each session owns one Redis list at key {key_prefix}:{session_id}, messages are appended with RPUSH (chronological order, oldest first), read back with LRANGE, and — when max_messages is configured — trimmed to the most recent N entries with LTRIM after every write. Each list element is one message, JSON-serialized with serde_json (equivalent to the Python store’s Message.to_json() / Message.from_json() round trip).

Upstream folded the standalone ChatMessageStore abstraction into HistoryProvider — a ContextProvider that prepends its stored messages ahead of a run (before_run) and records the run’s request + response messages after a successful run (after_run). RedisChatMessageStore follows suit directly (rather than wrapping an InMemoryHistoryProvider) so history actually persists to Redis, the same way FileHistoryProvider persists to disk.

Structs§

RedisChatMessageStore
Redis-backed HistoryProvider: one Redis LIST per session, JSON-serialized messages, optional automatic trimming.

Constants§

DEFAULT_KEY_PREFIX
Default Redis key prefix, matching the Python store’s default.