_Knowledge graph · LightRAG_

# Your agents stop forgetting what they learned

The graph keeps the knowledge of every element of your node: what was studied, how it connects and where it came from. Any agent finds what it needs with one question instead of rereading old files and conversations.

[Connect your element](#connect)
[Questions and answers](#faq)

## How it works

#### An agent saves

An element hands the graph what it learned: the things, the links between them and a short text saying where it came from.

#### The graph connects

New knowledge settles next to what is already known, and the same thing found in different analyses becomes one point.

#### Any agent asks

For a question in plain words the graph returns a short context: the right things, their links and the source.

Only building costs tokens; reading calls no language model.

## On, asleep only when memory is short

The element starts with the node. With less than 0.5 GB of free memory the node may put it to sleep; the first call or a calendar entry wakes it in seconds, and above 1 GB free it comes back by itself.

## Without a shared memory every conversation starts from zero

An agent studied someone else's site, worked out how its cart works and explained it all to you. The conversation closed and the finding was gone. A week later another agent does the same work again, and you pay for the tokens again.

## What changes for you

| Without it | With the graph |
| --- | --- |
| A finding vanishes when the conversation closes | What an agent finds goes into the graph and survives the end of the conversation, a restart of the node and a change of agent |
| Search finds only the same words | Ask in plain words: the graph finds the text that matches and everything connected to it, down to an item of your product quiz |
| An agent rereads reports hundreds of megabytes long | It gets a short extract made for its question |
| Each element keeps what it learned to itself | What one element puts into the shared graph is there for all the others at once |

## What a knowledge graph is

Picture a map where the towns are things and the roads are the links between them. A site, its search, the request address that search uses and the item of your quiz that grew out of it are points on that map, joined by labelled lines. The graph remembers both the points and the roads between them.

## The heart of LightRAG

LightRAG comes from the paper «LightRAG: Simple and Fast Retrieval-Augmented Generation» (Guo and co-authors, arXiv:2410.05779, October 2024). Its core is a graph inside the index itself: texts are taken apart into things and the links between them, and search walks that map instead of only matching pieces of text.

It is known for dual-level retrieval: the low level finds particular things, the high level the themes and links that join them. New knowledge goes into the graph as it arrives, with no rebuild of the whole index.

In the node the graph never calls a language model: the agent brings the things and links, and the node's own element embeddings counts the meaning.

## Where the tokens go

Only building costs much: a model reads the material and picks out the things and the links between them. Either LightRAG does it when it writes a document, or the element agent that has already studied the material hands the graph ready links. Reading is almost free: the question becomes an embedding, and the graph finds the nearest things and links and returns a short context without calling a language model. The agent passes the keywords for the graph search itself. You pay once to build and read many times for next to nothing.

## Whose graph it is

## undefined

**The main agent of the node** — Asks every graph space of every element and sees whose each answer is.

- **Mom's element** — Her facts and links in her element's own space.
- **Son's element** — His own spaces, opened only with his element's key.
- **Your site** — Its own spaces, its own answers.

Each element opens the graph with its own key, and one space never sees the points and roads of another.

An element works only in its own spaces: el-<its id>, and el-<its id>.<name> for one it names. The deep memory keeps each element's facts the same way. The shared graph with the skills base and the studied products is never reached with an element's key.

A question of an element goes to its own space. The main agent, with the node's data key, asks every space and sees whose each answer is.

The graph keeps the doors apart, not the disk: every space lies in this element's folder on your computer, and all elements run as one user of it.

## Your graph on your computer

The graph runs inside the node on your computer, and its data sits in the node's folder. Each element reads and adds to its own spaces through the graph's doors with its own key; the core and the deep memory use the node's data key. When you need to, you can connect your own tools to the same doors.

## Connect your element

Every element of the node already has its own key. Store what you learned as a ready graph and find it again with your own keywords:

```
// The graph's port: ask the node (npm run a2a -- card graph), never write the number into code.
const base = 'http://127.0.0.1:24689'
const headers = { 'content-type': 'application/json', 'X-Element-Key': process.env.ELEMENT_KEY }
// Store what you learned. Every entity and link names, by source_id, a fragment of the same call.
await fetch(`${base}/api/graph-insert`, { method: 'POST', headers, body: JSON.stringify({
  chunks: [{ content: 'The page /pricing takes payment through Stripe Checkout.', source_id: 'review-42' }],
  entities: [
    { entity_name: 'Pricing page', entity_type: 'page', description: 'The page /pricing of example.com.', source_id: 'review-42' },
    { entity_name: 'Stripe Checkout', entity_type: 'library', description: 'The hosted payment page of Stripe.', source_id: 'review-42' },
  ],
  relationships: [
    { src_id: 'Pricing page', tgt_id: 'Stripe Checkout', description: 'The pricing page takes payment through Stripe Checkout.',
      keywords: 'payment, checkout', source_id: 'review-42' },
  ],
}) })
// Find it again with your own keywords: ll_keywords look for entities, hl_keywords for links.
const answer = await fetch(`${base}/api/graph-query`, { method: 'POST', headers, body: JSON.stringify({
  query: 'How does the site take payments?', mode: 'mix', ll_keywords: ['payment page'], hl_keywords: ['payments'],
}) }).then((r) => r.json())
```

The answer brings the entities, the links and the fragments they came from; when nothing relevant is there it says found: false. Add "space": "<name>" to keep another graph of your own.

## Under the hood

| Part | What it does |
| --- | --- |
| LightRAG 1.5.7 | Lives inside the element: Python managed by uv, one pinned package, installed into the element's own folder |
| One operation per call | Each call starts Python for one operation, about 2 seconds and 200 MB while it lasts, and runs take turns |
| No language model | The caller brings the graph and the keywords; the vectors are counted by the node's embeddings element, 384 numbers, no key |
| Spaces | space: "<name>" keeps a graph of its own in its own folder, and the shared graph never sees it |
| Origin | Knowledge of a studied product is marked external-study, so an agent never takes it for this node's code |
| The lock | Each element's own key in X-Element-Key opens its own spaces; the node's data key in X-Data-Secret opens all; the page «Knowledge graph» shows the architect its size and a search |

## Your own builder comes with it

Every element of the node comes with its own Claude Code agent and can get its own Telegram bot. When something in this element should change, write to its bot from your phone, and the agent updates the logic or the design.

The agent works only in its element's folder and never reads the whole node, so each change costs fewer tokens. Your Claude Code subscription pays for it.

- The element's bot is connected in the core, on its «Telegram» page.
- The agent returns a commit; you look at it in «Preview» and accept it or turn it down.
- At the computer, the agent's terminal is in the core, in this element's «Build».

## Open source

Built by Fractera for the [Lagrix](https://lagrix.dev) protocol and for any web2 project whose agents need a shared memory. MIT license, the code is at [github.com/Fractera/fractera-graph-lightrag-starter](https://github.com/Fractera/fractera-graph-lightrag-starter).

## Questions and answers

**Do I need to install anything?**
No. The element installs Python and LightRAG into its own folder, and nothing goes into the system.

**Where is the data kept?**
In the node's folder on your computer. The graph lives in the memory of its process, and the files on disk are its copy.

**Can I connect to the graph from outside?**
Yes. Today the node's elements use the graph through its doors with the node's key. You can connect your own tools to the same doors.

**What is LightRAG?**
An open-source library for search over a knowledge graph, from the LightRAG Team under the MIT license. The node's graph is built on it.

**What if the graph gets very large?**
The built-in storage is enough for the knowledge of one node. A graph of millions of things needs a database server, and this element does not set one up.

**Can I keep backups?**
Yes. The element is ready for its programmer agent to set up backups on a schedule or by hand: tell the element's agent in Telegram or in the terminal. It makes no copies on its own until you ask.