Skip to content
PyromancerBoomPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Relay


Save some time and:


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.

Why Relay exists

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.

What works now

  • A local web demo.
  • A Python function named observe that saves a chat session.
  • A Python function named recall that 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.

What is not ready

  • 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.

Run the demo

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.

Windows

Open PowerShell in this folder.

  1. Create a Python environment and install the packages.

    py -3 -m venv .venv
    .\.venv\Scripts\Activate.ps1
    python -m pip install -r requirements.txt
  2. Start HydraDB, the database that stores Relay's facts.

    .\start_demo_hydra.bat
  3. Check when HydraDB is ready. This command should print 200.

    (Invoke-WebRequest http://127.0.0.1:19090/readyz -UseBasicParsing).StatusCode
  4. 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
  5. 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 down

The demo database uses separate ports. It will not stop a test database on ports 8443 and 9090.

macOS or Linux

Run these commands from this repository's folder. Each group is one step.

  1. Create a Python environment and install the packages.

    python3 -m venv .venv
    source .venv/bin/activate
    python -m pip install -r requirements.txt
  2. 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
  3. Wait for HydraDB. This command should succeed.

    curl -f http://127.0.0.1:19090/readyz
  4. Start Relay in the same terminal.

    HYDRADB_QUERY_PORT=18443 HYDRADB_HEALTH_PORT=19090 RELAY_PORT=8788 python -m relay.serve
  5. 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.

What the demo proves

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:

  1. Split each session into source text.
  2. Write the fixed facts to HydraDB.
  3. Link HydraDB as the current database.
  4. Link Postgres as the old database.
  5. Read the facts back from HydraDB.
  6. Show the returned facts in the web page.

The web page does not keep a second copy of the graph data.

How Relay works

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.

Live write mode

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.

Run the tests

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.py

You can also run:

pytest

These two tests need HydraDB on ports 8443 and 9090:

python isolation_test.py
python traversal_test.py

They write test data. Reset the test database before a scored run.

Test database

Use the main database for tests and benchmark work.

.\reset_hydradb.bat
docker compose up -d

Wait 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:

  1. HYDRADB_TOKEN.
  2. hydradb-data/auth-token.
  3. The local test token.

Main limits

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.

Fair benchmark rules

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_answer flag.

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.

Files to know

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.

License

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages