Save some time and:
- Watch the demo on YouTube.
- Go through the learning notes for ideas and lessons.
- Read the system design for the exact rules if you're in a hurry.
Relay explores one shared memory for coding agents. The agent connections are still planned. You can run the local demo today.
It stores facts in a graph. It can tell which fact is current. It can also show where each fact came from.
Relay is a Hack Hydra prototype. Do not use it for production data.
Coding agents can save old chat text and search it later. This can fail when a fact changes.
For example:
August 1: Relay uses Postgres.
August 15: Relay now uses HydraDB.
A text search can return both lines. It may not know which line is current.
Relay stores the change itself:
Relay -> database -> HydraDB current
Relay -> database -> Postgres closed by the newer fact
Relay can now answer three useful questions:
- What is true now?
- What was true before?
- Where did this fact come from?
If Relay finds no answer, it returns not in memory.
- A local web demo.
- A Python function named
observethat saves a chat session. - A Python function named
recallthat answers a question. - Facts, dates, and source text stored in HydraDB, a graph database.
- Old facts linked to the facts that replaced them.
- Separate memory for each project or test question.
- Tests that keep test answers private and limit graph reads.
- Direct links to Claude Code, Codex, or Cursor.
- A public server.
- User accounts or strong access control.
- Fast work on large chat histories.
- A complete LongMemEval-S graph score.
The demo uses fixed sample facts. A separate local API can save new text. Neither one is a full coding-agent connection.
You need Python 3.11 or newer and Docker Compose. Start Docker first. Run each command from this repository's folder. You also need PowerShell on Windows.
Open PowerShell in this folder.
-
Create a Python environment and install the packages.
py -3 -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install -r requirements.txt
-
Start HydraDB, the database that stores Relay's facts.
.\start_demo_hydra.bat -
Check when HydraDB is ready. This command should print
200.(Invoke-WebRequest http://127.0.0.1:19090/readyz -UseBasicParsing).StatusCode
-
Start Relay in the same PowerShell window.
$env:HYDRADB_QUERY_PORT = "18443" $env:HYDRADB_HEALTH_PORT = "19090" $env:RELAY_PORT = "8788" python -m relay.serve
-
Open http://127.0.0.1:8788. The page loads the sample facts. Try a suggested question.
Stop Relay with Ctrl+C.
Stop the demo database with:
docker compose -f docker-compose.demo.yml downThe demo database uses separate ports. It will not stop a test database on ports 8443 and 9090.
Run these commands from this repository's folder. Each group is one step.
-
Create a Python environment and install the packages.
python3 -m venv .venv source .venv/bin/activate python -m pip install -r requirements.txt -
Create the local database folders and token. Then start HydraDB.
mkdir -p hydradb-demo-data/store hydradb-demo-data/cache printf 'local-development-token-32-bytes\n' > hydradb-demo-data/auth-token docker compose -f docker-compose.demo.yml up -d
-
Wait for HydraDB. This command should succeed.
curl -f http://127.0.0.1:19090/readyz
-
Start Relay in the same terminal.
HYDRADB_QUERY_PORT=18443 HYDRADB_HEALTH_PORT=19090 RELAY_PORT=8788 python -m relay.serve
-
Open http://127.0.0.1:8788. The page loads the sample facts. Try a suggested question.
If the readiness check fails, make sure Docker is running. Then check the
database with docker compose -f docker-compose.demo.yml ps.
The demo has seven sample chat sessions in relay/demo.py. It uses fixed
facts so the result is the same each time.
The demo skips the model that finds facts in new text. It still uses the real database write and read code.
The demo does this:
- Split each session into source text.
- Write the fixed facts to HydraDB.
- Link HydraDB as the current database.
- Link Postgres as the old database.
- Read the facts back from HydraDB.
- Show the returned facts in the web page.
The web page does not keep a second copy of the graph data.
Relay saves facts from a chat with their dates and source text. It links a new fact to an older fact when the new one replaces it. When you ask a question, Relay follows those links and shows the source behind its answer.
The system design explains each step and shows diagrams.
The local server also has a live memory area. It accepts new text through
POST /api/remember. The web page shows the fixed demo area.
Live writes need an AI model to extract facts. This prototype includes a
model adapter for the original setup. To use your own AI service, replace
that adapter with one that returns facts in the schema in relay/curate.py.
The fixed demo and graph recall do not need an AI model. A hosted model may
receive the text you save.
The local server has these routes:
| Route | Use |
|---|---|
GET /api/health |
Check HydraDB. |
GET /api/memory?scope=demo |
Read one memory scope. |
POST /api/demo/load |
Load the fixed demo. |
POST /api/remember |
Save live text. |
POST /api/recall |
Ask a question. |
The server listens only on 127.0.0.1. It has no user login. Keep it local.
Tests that do not need HydraDB:
python integrity_test.py
python pipeline_test.py
python hydra_client_test.py
python serve_test.py
python web_test.pyYou can also run:
pytestThese two tests need HydraDB on ports 8443 and 9090:
python isolation_test.py
python traversal_test.pyThey write test data. Reset the test database before a scored run.
Use the main database for tests and benchmark work.
.\reset_hydradb.bat
docker compose up -dWait for http://127.0.0.1:9090/readyz to return HTTP 200.
The query address is http://127.0.0.1:8443.
Relay reads the HydraDB token in this order:
HYDRADB_TOKEN.hydradb-data/auth-token.- The local test token.
Relay has important limits.
- HydraDB stops some graph reads after 30 seconds.
- Large graphs can cause read errors or timeouts.
- Writes use many small HTTP calls and can be slow.
- Source text is cut at 16,000 characters per chunk.
- The name list lives in Python memory. A restart clears that list.
- A missed name or alias can hide a fact that exists in HydraDB.
- The fact finder can mark a fact with the wrong type.
- The read path cannot do math.
- The read path returns at most 12 facts.
The 19-question LongMemEval-S graph run is not complete. Do not report its current result as a final score.
LongMemEval tests memory over long chat histories. It is a test tool. It is not the product.
Relay must never read the test answers before it answers a question.
relay/dataset.py removes these private fields:
answer.answer_session_ids.- Each turn's
has_answerflag.
Only relay/scorer.py can use them for scoring.
The graph read path must not use BM25 text search. The BM25 version is a separate system used for a fair comparison.
Do not change the fixed values in relay/config.py after you see scores.
See System_Design.md for all test rules.
| Path | Use |
|---|---|
relay/pipeline.py |
Joins the write and read paths. |
relay/graph_write.py |
Writes facts to HydraDB. |
relay/graph_read.py |
Reads facts from HydraDB. |
relay/curate.py |
Finds facts in a session. |
relay/lexicon.py |
Keeps names used to enter the graph. |
relay/demo.py |
Holds the fixed demo data. |
relay/serve.py |
Runs the local web server. |
web/ |
Holds the local web page. |
| learning.md | Explains the ideas and lessons behind Relay. |
| System_Design.md | Gives the exact system rules. |
results/ |
Holds test lists and score reports. |
Relay uses the GNU Affero General Public License version 3 only.
If you host a changed version, you must offer its source code to its users. Other rules also apply. Read LICENSE.
SPDX name: AGPL-3.0-only.
The bundled Geist fonts use OFL-1.1. See
web/fonts/OFL.txt.