agentcache / src /cache /context.py
Yash030's picture
feat: migrate agentmemory to agentcache namespace, endpoints, and tools
12a6c9a
Raw
History Blame Contribute Delete
977 Bytes
"""
src/memory/context.py β€” Context compilation, export, and index rebuilding.
Public API:
context(kv, data) β€” compile token-budgeted context for a session/project
export_data(kv, data) β€” export all folder observations + memories as JSON
rebuild_index(kv) β€” cold-rebuild BM25/vector index from KV store
"""
from __future__ import annotations
from typing import Any, Dict
from db import StateKV
import functions as _fn
def context(kv: StateKV, data: Dict[str, Any]) -> Dict[str, Any]:
"""Assemble context for a session: slots β†’ profile β†’ lessons β†’ past summaries."""
return _fn.context(kv, data)
def export_data(kv: StateKV, data: Dict[str, Any]) -> Dict[str, Any]:
"""Export all folder observations and global memories as JSON (v2 format)."""
return _fn.export_data(kv, data)
def rebuild_index(kv: StateKV) -> int:
"""Rebuild BM25/vector index from all KV observations and memories."""
return _fn.rebuild_index(kv)