xml-pipeline/agentserver/memory/__init__.py
dullfig fc7170a02e Add context buffer - virtual memory manager for AI agents
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>
2026-01-10 17:20:43 -08:00

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",
]