agent-knowledge

agent-knowledge

Long-term memory for AI agents. Compiles conversations into a structured knowledge base with Claim/Evidence model, source provenance, append-only timeline, and contradiction detection. Multi-path retrieval (Exact + BM25 + Graph + weighted RRF + reranker) — 96.6% R@5 on LongMemEval-S, zero vector dependencies.

Category
Visit Server

README

agent-knowledge

PyPI Python License: MIT CI MCP

English | 简体中文

Long-term knowledge for AI agents. Conversations, documents, and decisions are auto-compiled into a structured knowledge base with source provenance, confidence tracking, and contradiction detection. Drop-in MCP server — Claude Code, Cursor, Codex, and any MCP-aware client connect with one config line.

Why

LLM memory today is either flat RAG chunks or a key-value preference cache. Neither answers "how did we get here?".

agent-knowledge adds a knowledge-compilation layer: raw material is decomposed into Claims and Evidence, claims about the same entity are merged into a Compiled Truth, and a timeline is kept append-only — rewritten holistically when new evidence arrives. Every fact is traceable to its source, timestamp, and confidence.

Before / After

Scenario: over 10 weeks the team revisits its frontend stack three times — Week 1 picks Vue, Week 6 evaluates React, Week 10 switches to React. All three meeting notes are in the agent's conversation history.

A new teammate asks the agent "what frontend are we on, and why?"

Without — RAG over chat history

The team decided to use Vue as the frontend framework.

Vector search returns the highest-similarity chunk (the earliest meeting note). No temporal awareness → stale answer.

With agent-knowledgeak_query returns the entity (real vault YAML)

name: Frontend stack
entity_type: concept
compiled_truth:
  claims:
    - text: use React for the dashboard
      status: active
      confidence: 0.85
      evidence:
        - source_id: c3a9d1f2
          weight: 1.0
    - text: use Vue for the dashboard
      status: superseded
      confidence: 0.65
      evidence:
        - source_id: a1b2c3d4
          weight: 0.7
timeline:
  - date: 2026-02-01
    title: Decided on Vue
    source_id: a1b2c3d4
  - date: 2026-03-12
    title: Evaluated React
    source_id: b5e6f7a8
  - date: 2026-04-09
    title: Switched to React; Vue ecosystem limits
    source_id: c3a9d1f2

The agent now sees the current fact, the timeline, the sources, and the superseded prior claim in one call. Its answer naturally becomes "we're on React — switched from Vue in April due to ecosystem limits," with every fact traceable to a source.

Quick Start

pip install compiled-memory   # PyPI package; the Python module is `agent_knowledge`

ak init   ~/my-knowledge
ak ingest ~/my-knowledge --file ./meeting-notes.md
ak query  ~/my-knowledge "why did we pick React?"
ak dream  ~/my-knowledge       # offline consolidation
ak lint   ~/my-knowledge       # health check

Or run it as an MCP server, plugged into any MCP-aware client:

ak mcp ~/my-knowledge

Copy-paste configs for Claude Code / Cursor / Codex live in examples/mcp/; the full tool list is in docs/mcp-integration.md. Agents picking up this repo should read AGENTS.md first.

Architecture

┌─────────────────────────────────┐
│  Adapter Layer                  │  CLI · MCP · pull adapters
├─────────────────────────────────┤
│  UMSF Boundary                  │  unified data contract
├─────────────────────────────────┤
│  Knowledge Layer (core)         │  Compiler · Compiled Truth · Hooks · Dream
├─────────────────────────────────┤
│  Storage                        │  Vault (YAML) + EventIndex (SQLite)
├─────────────────────────────────┤
│  Search Layer                   │  Exact + BM25 + Graph + RRF + Reranker
└─────────────────────────────────┘
  • Knowledge Layer — pure Python over local files, no external services
  • Search Layer — zero dependencies by default; optional embedding model for stronger semantic recall
  • Adapter Layer — UMSF unifies the boundary; a new agent adapter is ~80 lines

See docs/architecture.md.

Benchmark

LongMemEval-S (ICLR 2025) — 500 questions, ~48 sessions/question, ~115K tokens/question:

Metric Score
R@5 96.6%
R@10 98.2%
MRR 0.9031
NDCG@10 0.9218

Zero vector dependencies — BM25 + Exact Match + RRF only. Full per-type breakdown in BENCHMARK.md.

Documentation

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured