KnowledgeStore
autogen.beta.knowledge.base.KnowledgeStore #
Bases: Protocol
Virtual path-based store for actor knowledge.
Provides filesystem semantics over any storage backend. Paths use Unix conventions: /dir/subdir/file.txt Directories are implicit -- writing /a/b/c.txt implies /a/ and /a/b/ exist. Listing returns immediate children. Directory entries end with '/'.
The network layer uses the same protocol to back the hub's virtual file system; see :mod:autogen.beta.network. Three methods beyond the basic CRUD are required for WAL-backed sessions: append and read_range are mandatory, while on_change is optional (backends that cannot observe changes efficiently return a :class:NoopChangeSubscription and callers fall back to polling).
read async #
write async #
list async #
List immediate children of a directory path.
Returns relative names. Directories end with '/'. Example: list("/log/") might return ["stream-abc.jsonl", "stream-def.jsonl"]
Source code in autogen/beta/knowledge/base.py
delete async #
exists async #
append async #
Atomically append content to the file at path.
Creates the file (and its parents) if it does not exist. Returns the byte offset at which content was written, so callers can record a cursor for later read_range calls.
Source code in autogen/beta/knowledge/base.py
read_range async #
Read the byte slice [start, end) of the file at path.
end of None means "up to the current end of file". Returns an empty string if the file does not exist. Slices are returned as UTF-8 text; callers that append multi-byte content must align offsets to character boundaries themselves.
Source code in autogen/beta/knowledge/base.py
on_change async #
Subscribe to change notifications at path.
Backends that can observe changes efficiently invoke callback(path) whenever a file under path changes. Backends that cannot must return :class:NoopChangeSubscription; the hub then polls on a short interval instead.