Implements thread-scoped, append-only storage for validated payloads. Handlers receive immutable references; messages cannot be modified after insertion. Core components: - BufferSlot: frozen dataclass holding payload + metadata - ThreadContext: append-only buffer per thread - ContextBuffer: global manager with GC and limits Design parallels OS virtual memory: - Thread ID = virtual address space - Buffer slot = memory page - Immutable reference = read-only mapping - Thread isolation = process isolation Integration: - Incoming messages appended after pipeline validation - Outgoing responses appended before serialization - Full audit trail preserved This is incremental - handlers still receive copies for backward compatibility. Next step: skip serialization for internal routing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
27 lines
648 B
Python
27 lines
648 B
Python
"""
|
|
memory — Virtual memory management for AI agents.
|
|
|
|
Provides thread-scoped, append-only context buffers with:
|
|
- Immutable slots (handlers can't modify messages)
|
|
- Thread isolation (handlers only see their context)
|
|
- Complete audit trail (all messages preserved)
|
|
- GC and limits (prevent runaway memory usage)
|
|
"""
|
|
|
|
from agentserver.memory.context_buffer import (
|
|
ContextBuffer,
|
|
ThreadContext,
|
|
BufferSlot,
|
|
SlotMetadata,
|
|
get_context_buffer,
|
|
slot_to_handler_metadata,
|
|
)
|
|
|
|
__all__ = [
|
|
"ContextBuffer",
|
|
"ThreadContext",
|
|
"BufferSlot",
|
|
"SlotMetadata",
|
|
"get_context_buffer",
|
|
"slot_to_handler_metadata",
|
|
]
|