Expand description
Letta/MemGPT-inspired self-editing memory blocks.
Memory blocks are named, versioned text slots that an AI agent can read and
overwrite during a session. Each write increments the version counter and
appends a row to block_edit_log so the full rewrite history is preserved.
§Design
- One row per block name (PRIMARY KEY on
name). - Overflow detection uses a rough 4 chars/token heuristic; if the content
exceeds
max_tokens * 4bytes the excess is returned and the block is truncated to the allowed length. - All timestamps follow the project-wide convention: RFC 3339 UTC strings.
Structs§
- Block
Edit Log - A single entry in the edit history for a block.
- Memory
Block - A named, versioned text slot.
Constants§
- CREATE_
BLOCK_ EDIT_ LOG_ TABLE - SQL that creates the
block_edit_logtable. - CREATE_
MEMORY_ BLOCKS_ TABLE - SQL that creates the
memory_blockstable.
Functions§
- archive_
overflow - If the block’s content exceeds its
max_tokensbudget (estimated at 4 chars/token), truncate the block to the allowed length, persist the truncated version with a log entry, and return the overflow text. - create_
block - Create a new memory block.
- delete_
block - Delete a block and its edit history.
- get_
block - Retrieve a block by name, returning
Nonewhen it does not exist. - get_
block_ history - Retrieve the edit history for a block, most-recent first.
- list_
blocks - Return all memory blocks ordered by name.
- update_
block - Update a block’s content, increment its version, and record the edit.