Observed since 20 Oct, 22:18 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
agentic-memory
A Graph-Theoretic Memory Kernel for Agentic AI Systems
A Graph-Theoretic Memory Kernel for Agentic AI Systems
"Beyond RAG: Stateful memory for AI agents that actually remembers."
ContextOS is a framework for building AI agents with persistent, structured memory. Unlike standard RAG (Retrieval-Augmented Generation) which treats documents as flat vectors, ContextOS models memory as a graph where:
PageRank centrality + Vector similarityThis enables multi-hop reasoning that pure vector search cannot achieve.
pip install agentic-memory
Or from source:
git clone https://github.com/ARYAN2302/ContextOS.git
cd context-os
pip install -e .
from agentic_memory import ContextClient, MemoryType
# Initialize (loads existing memory if available)
client = ContextClient()
# Add memories
client.add_memory("User prefers dark mode", MemoryType.SEMANTIC)
client.add_memory("User asked about Python yesterday", MemoryType.EPISODIC)
# Compile context for a query
context = client.compile("What are the user's preferences?")
print(context)
from agentic_memory import ContextClient
client = ContextClient()
def my_llm(system_prompt: str, user_query: str) -> str:
# Your LLM call here (OpenAI, Groq, Anthropic, etc.)
return llm.invoke(system_prompt + user_query)
# Run a full RAG loop with automatic memory logging
response = client.chat("What should I work on today?", llm_callable=my_llm)
from agentic_memory import ContextGraph, ContextNode, ContextEdge, MemoryType, ContextCompiler
# Direct graph access
kernel = ContextGraph()
node = ContextNode(content="Important fact", type=MemoryType.SEMANTIC)
kernel.add_node(node)
# Add relationships
edge = ContextEdge(source=node1.id, target=node2.id, relation="CAUSES")
kernel.add_edge(edge)
# Compile context
compiler = ContextCompiler(kernel)
context = compiler.compile("query", token_budget=500, alpha=50, beta=50)
context_os/
├── client.py # ContextClient - main entry point
├── core/
│ ├── schema.py # Pydantic models (ContextNode, ContextEdge, MemoryType)
│ └── graph.py # Hybrid storage (NetworkX + ChromaDB)
├── memory/
│ ├── ingestor.py # LLM-powered memory classification
│ └── compiler.py # PageRank + Vector hybrid retrieval
└── utils/
└── text.py # Text processing utilities
relevance(node, query) = (α × semantic_similarity) + (β × pagerank_centrality × time_decay)
ContextOS retrieves a "needle" fact from 100+ distractor memories with 100% recall.
cd experiments && python niah_benchmark.py
| Configuration | Multi-Hop Accuracy |
|---|---|
| Vector Only (RAG) | 50% |
| Graph Only | 50% |
| ContextOS (Hybrid) | 100% |
client = ContextClient(
storage_path="my_memory.json", # Graph persistence
chroma_path="my_vectors/", # Vector store
auto_persist=True # Save on every change
)
# Retrieval tuning
context = client.compile(
query="...",
token_budget=1000, # Max tokens in context
alpha=50.0, # Vector weight
beta=50.0 # Graph weight
)
MIT License - See LICENSE for details.
Inspired by the CoALA architecture for cognitive agents.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
networkxEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | networkx>=3.0 | runtime |
pydanticEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | pydantic>=2.0 | runtime |
chromadbEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | chromadb>=0.4.0 | runtime |
sentence-transformersEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | sentence-transformers>=2.0.0 | runtime |
langchain-groqEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | langchain-groq>=0.1.0 | runtime |
langchain-coreEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | langchain-core>=0.1.0 | runtime |
pytestEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | pytest>=7.0; extra == "dev" | runtime |
pytest-covEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | pytest-cov>=4.0; extra == "dev" | runtime |
blackEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | black>=23.0; extra == "dev" | runtime |
ruffEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | ruff>=0.1.0; extra == "dev" | runtime |
bdist_wheel · 11.64 KB · Python py3
sdist · 12.47 KB · Python source
Observed since 20 Oct, 22:18 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:41ccaa89cbf9e641ec6255f1a2c5bc24e78cecf80c14affb4bbe6f95c4cedcb8