Skip to main content

Universal OKF-based memory system for Hermes agent — structured, persistent, agent-readable knowledge storage.

Project description

Hermes OKF (Open knowledge Format) — Universal Memory for AI Agents

CI Python License: MIT OKF

The first open-source memory system built on Google's Open Knowledge Format (OKF) for the Hermes agent ecosystem.

Hermes OKF gives your AI agent a persistent, structured, version-controlled memory — no database, no lock-in, just markdown + YAML on your filesystem. Every decision, observation, and project context lives in a human-readable knowledge graph that your agent can read, write, and traverse programmatically.


Why Hermes OKF?

Feature What You Get
🧠 Agent Memory Persistent decisions, observations, and tool-call history across sessions
🔗 Knowledge Graph Implicit graph from markdown links — no RDF, no Cypher
📁 Filesystem-First Plain .md + YAML. cat it, grep it, Git it.
Zero-DB Core Single dependency: pyyaml. Optional RAG via LangChain/ChromaDB.
🎁 Hermes-Ready Drop-in decorators: @memorize_decision, @memorize_tool
🔄 Resume Stop and restart — the agent restores from its OKF bundle
📦 Portable Clone a bundle to another machine — the agent resumes instantly.

Quick Start

pip install hermes-okf
from hermes_okf.bundle import OKFBundle

# Create a knowledge bundle
bundle = OKFBundle("./my_knowledge")

# Store a project concept
bundle.write_concept(
    "projects/my_project",
    body="# My Project\n\nDescribe your project here.",
    type="Project",
    title="My Project",
    tags=["ml", "data", "gpu"],
    resource="https://github.com/YOUR_USERNAME/my-project",
)

# Log a decision
bundle.append_log("Switched from TensorFlow to PyTorch for better ecosystem support", category="Decision")

# Search by tag
for concept in bundle.search_by_tag("gpu"):
    print(concept.title)

# Inspect the graph
for edge in bundle.get_graph_edges():
    print(f"{edge['source']} -> {edge['target']}")

Agent Integration (Memory Mixin)

from hermes_okf.agent import HermesMemoryMixin

class MyAgent(HermesMemoryMixin):
    def __init__(self):
        super().__init__("./agent_knowledge", agent_id="my-agent-v1")
        self.start_session()

    @HermesMemoryMixin.memorize_decision
    def choose_model(self, task: str) -> str:
        if "code" in task.lower():
            return "anthropic/claude-3.5-sonnet"
        return "openai/gpt-4o"

    @HermesMemoryMixin.memorize_tool
    def scrape_data(self, url: str) -> dict:
        return {"url": url, "items": 42}

# Run it
agent = MyAgent()
agent.choose_model("Write a Python script")
agent.scrape_data("https://example.com")

# Recall relevant context
context = agent.with_context("python script", top_k=3)

Full Hermes Agent (State as OKF Bundle)

For deeper integration, use HermesAgent — the entire agent state lives in the OKF bundle. The agent can be stopped, restarted, and resumed from its bundle alone.

from hermes_okf import HermesAgent

# Create or resume an agent
agent = HermesAgent(
    bundle_path="./hermes_agent_brain",
    agent_id="hermes-alpha",
    model="anthropic/claude-3.5-sonnet",
)

# Register tools with JSON schemas
agent.register_tool("search_web", "Search the web", schema={"type": "object", ...})

# Create and execute plans
agent.create_plan("Research AI trends", ["Search", "Summarize", "Report"])
agent.complete_step(0, result="Found 5 major trends")

# Build LLM context automatically
context = agent.build_context("What should I do next?")

# Save snapshot — resume later from this exact state
agent.snapshot()

agent.end_session()

The agent bundle structure:

hermes_agent_brain/
├── config/agent.md        # Identity, model, system prompt
├── tools/*.md             # Tool definitions with schemas
├── sessions/*.md          # Session records
├── plans/*.md             # Active plans with checkable steps
├── plans/archive/*.md     # Completed plans
├── decisions/*.md         # Strategic decisions
├── snapshots/*.md         # Full state snapshots
└── index.md / log.md      # Bundle overview and activity log

Read the full integration guide: docs/HERMES_INTEGRATION.md


CLI

# Initialise a new OKF bundle
hermes-okf init ./knowledge

# Validate conformance
hermes-okf validate --path ./knowledge

# List concepts
hermes-okf list --path ./knowledge

# Show a concept
hermes-okf show --path ./knowledge projects/my_project

# Search
hermes-okf search --path ./knowledge "ffmpeg GPU"

# View log
hermes-okf log --path ./knowledge

# Append to log
hermes-okf log-append --path ./knowledge "New decision made" --category Decision

# Graph inspection
hermes-okf graph-edges --path ./knowledge
hermes-okf graph-neighbors --path ./knowledge projects/my_project

RAG Integration (Optional)

pip install hermes-okf[rag]

Feed your OKF bundle into LangChain + ChromaDB for vector retrieval:

from langchain_community.document_loaders import DirectoryLoader, TextLoader
from langchain.text_splitter import MarkdownHeaderTextSplitter
from langchain_chroma import Chroma
from langchain_openai import OpenAIEmbeddings

from hermes_okf.bundle import OKFBundle

bundle = OKFBundle("./my_knowledge")
loader = DirectoryLoader(
    str(bundle.root),
    glob="**/*.md",
    loader_cls=TextLoader,
    loader_kwargs={"encoding": "utf-8"},
)
docs = loader.load()

splitter = MarkdownHeaderTextSplitter(
    headers_to_split_on=[("#", "Header 1"), ("##", "Header 2")]
)
splits = [chunk for doc in docs for chunk in splitter.split_text(doc.page_content)]

vectorstore = Chroma.from_documents(
    documents=splits,
    embedding=OpenAIEmbeddings(),
    persist_directory="./chroma_okf_db",
)

# Query
retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
results = retriever.invoke("What GPU decisions did we make?")

See examples/rag_integration.py for a complete example.


Architecture

┌─────────────────────────────────────┐
│  CLI (hermes-okf)                   │
├─────────────────────────────────────┤
│  HermesMemory / MemoryMixin         │  ← Agent integration
├─────────────────────────────────────┤
│  OKFBundle                          │  ← Core read/write API
│  ├── Concept (dataclass)            │
│  ├── GraphExtractor                 │
│  ├── SearchIndex                    │
│  └── OKFValidator                   │
├─────────────────────────────────────┤
│  Filesystem (markdown + YAML)       │  ← Persistent storage
└─────────────────────────────────────┘

Read the full architecture in docs/ARCHITECTURE.md.


OKF Format

This library implements the Google Open Knowledge Format (OKF) v0.1 spec:

  • Every concept is a .md file with YAML frontmatter
  • Frontmatter must include a type field
  • Reserved files: index.md (directory), log.md (chronology)
  • Markdown links create implicit directed edges
  • Directory structure provides containment hierarchy
  • Tags create cross-cutting clusters

"If you can cat a file, you can read OKF."


Project Structure

hermes-okf/
├── src/hermes_okf/          # Core library
│   ├── bundle.py             # OKFBundle read/write
│   ├── concept.py            # Concept dataclass
│   ├── graph.py              # Graph extraction & traversal
│   ├── search.py             # Full-text search & indexing
│   ├── validators.py         # OKF conformance checking
│   ├── memory.py             # Agent memory layer
│   ├── agent.py              # Drop-in decorators
│   └── cli.py                # CLI entry point
├── tests/                    # pytest suite
├── examples/                 # Usage examples
├── docs/                     # Architecture docs
└── .github/workflows/        # CI/CD

Development

git clone https://github.com/EliaszDev/hermes-okf.git
cd hermes-okf
pip install -e ".[dev]"
pytest

See CONTRIBUTING.md for full guidelines.


Roadmap

  • Async I/O support for high-throughput agents
  • Multi-agent bundle merging and conflict resolution
  • Git-backed history with automatic diff summaries
  • Web viewer for knowledge graph exploration
  • Plugin system for custom concept types and validators
  • Integration with Hermes agent orchestration layer

License

MIT — see LICENSE.


Acknowledgements

Built for the Hermes agent ecosystem and inspired by the Google Cloud Knowledge Catalog team's OKF draft specification. If you use Hermes or OKF, this library is designed to be your memory backbone.

⭐ Star this repo if you're building agent memory systems — let's make Hermes the best agent framework out there.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hermes_okf-0.2.0.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hermes_okf-0.2.0-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file hermes_okf-0.2.0.tar.gz.

File metadata

  • Download URL: hermes_okf-0.2.0.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.2

File hashes

Hashes for hermes_okf-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cd97ff524b92bd3987ece5da5f28bbe4df83a08d2a2dfb23f8237abec2d956d7
MD5 fe2e16845e09a36238778b21e586b1e4
BLAKE2b-256 9b57145ee40bb493b94441d9ca7c03374a304e92db5b927aa0508421063f6803

See more details on using hashes here.

File details

Details for the file hermes_okf-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: hermes_okf-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.2

File hashes

Hashes for hermes_okf-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9eddcf45566847d04e578056f7b183ad2b5965d0f2509c98f13feb4c46178226
MD5 09fa99d76c17dcdd5d4e5867a17afb2e
BLAKE2b-256 a5ee80635bf7979d3defad549e8a2b22bd04abec92ec75145351ce81d183df9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page