BufferChatMemory is the simplest memory backend for tinygent.
It keeps an in-memory buffer of all messages exchanged in a conversation.
-
Concept: every message (user or agent) is appended to an internal
BaseChatHistoryobject. -
Available methods:
save_context(message): store a new message in the buffer.load_variables(): expose the current buffer as a single string, ready to be injected into the next prompt.clear(): drop the buffer entirely and start fresh.
-
How it works in practice:
- Memory starts empty.
- Each call to
save_contextappends a new message. load_variableslets you pass the full conversation back into the model for continuity.- When you no longer need past context,
clearresets everything.
This is a simple, in-process memory — nothing is persisted to disk or external storage. It’s designed for examples, prototypes, or any agent that only needs short-term conversational context.