Skip to main content
Glama
Agent Knowledge Ledger

Agent Knowledge Ledger

by supermikol
README.md
# Agent Knowledge Ledger

[![Verification](https://github.com/supermikol/agent-knowledge-ledger/actions/workflows/verify.yml/badge.svg)](https://github.com/supermikol/agent-knowledge-ledger/actions/workflows/verify.yml) · [MIT licensed](LICENSE)

A knowledge base for AI agents that need to answer **“What did we decide, and what evidence still applies?”** An agent can search team records, open the exact version behind a claim, and leave a cited handoff that another session can verify.

I built a shared knowledge system so people could pick up work across agent sessions without reconstructing the decision from chat history. This public edition reimplements its retrieval and handoff design with SQLite, five Model Context Protocol (MCP) tools, and an entirely fictional radio observatory. The local demo runs offline with Python. An MCP client can connect its own model.

**[Read a real agent's shift handoff](doc/shift-handoff.md)** · **[Explore the architecture](doc/architecture.md)** · **[Connect your agent](doc/agent-client.md)**

## Try it in one minute

Use Python 3.11+ with SQLite FTS5. The core uses the Python standard library.

```sh
git clone https://github.com/supermikol/agent-knowledge-ledger.git
cd agent-knowledge-ledger
python3 -m knowledge_ledger demo
```

The walkthrough opens three records that a new shift could easily confuse.

| What the shift needs to know | What the evidence says |
| --- | --- |
| Clear skies | The adopted decision moved calibration from **30 to 45 minutes**. |
| Visible frost on the feed enclosure | An adopted exception shortens the interval to **15 minutes**. |
| A more recent proposal | **60 minutes** is a proposed trial. Its record carries draft status. |

The demo saves a handoff with all three revision digests, reopens the database, and prints the citations. It uses a temporary database. To investigate the evidence yourself, keep a local copy and ask for the revision history.

```sh
python3 -m knowledge_ledger seed --db field.sqlite
python3 -m knowledge_ledger search --db field.sqlite --query "calibration cadence"
python3 -m knowledge_ledger history --db field.sqlite --id cadence-rule
```

## Where the engineering lives

| Design question | Implementation |
| --- | --- |
| Can the model look beyond the first hit? | Independent text search and tag discovery return leads. Exact reads expose the full text, provenance, status and revision. |
| Can a hidden document displace a visible result? | Each audience has its own full-text index. Ranking and page bounds operate over visible records. |
| What happens if the source changes while the agent is writing? | One transaction compares every cited digest with its current source before committing the handoff. A stale write fails so the agent can read the change. |
| What survives a retry or withdrawal? | An identical request returns its original receipt. A conflicting retry fails. Withdrawing evidence also hides handoffs that depend on it, including after a source import is replayed. |

The public edition uses a trusted local process. The operator selects the audience when launching MCP. Anyone with filesystem access to the database can inspect it. The [architecture walkthrough](doc/architecture.md) shows where identity and storage controls belong in a shared deployment.

## Evaluate it or fork it

```sh
python3 evals/run.py
```

Seven end-to-end scenarios exercise the CLI across fresh processes. A separate SDK evaluation opens real MCP connections, saves a handoff and reads it after restart. The repository includes the question, tool trace and four citations from one actual model run. See the [evaluation and replay guide](doc/evaluation.md).

To use your own records, start with the [fork guide](doc/fork-guide.md). It walks through importing a source, correcting it without breaking old citations, and withdrawing it. To give an agent the same reading and capture workflow, use the [portable skill](skills/evidence-handoff/SKILL.md).