Skip to main content

A local-first memory sidecar for agent applications

Project description

HotMem

A local-first memory sidecar for agent applications. One SQLite DB. One port: 8711.

HotMem provides fast, queryable working memory with hybrid vector + keyword search. Store facts, retrieve them ranked, and get back LLM-ready message objects you can stitch directly into prompts.

Install

pip install hotmem@git+https://github.com/KnowGuard-AI/HotMem.git
# or
uv add hotmem@git+https://github.com/KnowGuard-AI/HotMem.git

Or add to requirements.txt:

hotmem @ git+https://github.com/KnowGuard-AI/HotMem.git

Quick Start

# Start with a mount directory (portable memory)
hotmem serve --mount ./hotmem

# Or just start (uses temp DB)
hotmem serve

CLI

hotmem serve --port 8711 --mount ./data/hotmem
hotmem serve --db ./my.sqlite
hotmem hydrate --file swap.jsonl --db ./my.sqlite
hotmem snapshot --file swap.jsonl --db ./my.sqlite
hotmem status

API

All endpoints under /v1. Default: http://127.0.0.1:8711

GET /v1/health

{"status": "ok", "memory_count": 42, "db_path": "...", "uptime_s": 120.5}

POST /v1/add

{"identifier": "vendor_x", "fact": "Invoice total was $5000", "importance": 0.8}

POST /v1/search

{"query": "duplicate invoice risk", "top_k": 5, "max_chars": 1500}

Returns ranked message objects ready for LLM stitching:

{
  "memories": [
    {"role": "system", "content": "...", "memory_id": "...", "identifier": "...", "score": 0.87}
  ],
  "count": 5,
  "trace_ms": 2.1
}

POST /v1/hydrate

{"file": "swap.jsonl"}

POST /v1/snapshot

{"file": "swap.jsonl"}

Python Client

from hotmem.client import HotMemClient

with HotMemClient("http://127.0.0.1:8711") as client:
    client.add("vendor_x", "Invoice total $5000", importance=0.8)

    memories = client.search("duplicate invoice risk", top_k=5, max_chars=1500)

    # memories are LLM-ready message objects
    messages = memories + [{"role": "user", "content": "Analyze this vendor."}]

Mounting

Any directory can be a HotMem mount. The mount contains:

  • hotmem.sqlite — the database
  • swap.jsonl — portable JSONL backup
  • manifest.json — mount metadata
hotmem serve --mount /mnt/usb/hotmem     # portable memory on USB
hotmem serve --mount ./data/hotmem        # local project memory

Development

uv sync                          # install deps
uv run pytest                    # run tests
uv run ruff check src/ tests/    # lint
uv run ruff format src/ tests/   # format
uv build                         # build wheel

Architecture (for agents)

Each source module is independently extensible with self-documenting headers:

Module Purpose Extension Point
trace.py Structured JSON logging Add sinks, formatters
embed.py Hash-based embedder (dim=64) Swap for real model
db.py SQLite + cosine UDF Add FTS5, indexes
search.py Hybrid ranking Add reranking, MMR
swap.py JSONL hydrate/snapshot Add compression
mount.py Directory bootstrap Add remote sync
server.py FastAPI endpoints Add CORS, new routes
cli.py Click CLI Add subcommands
client.py httpx SDK Add async client

Every operation emits structured JSON traces to stderr with component tags:

hotmem serve --mount ./data 2>&1 | grep '"component": "search"'

Contributing

Contributions are welcome! Whether you're fixing bugs, adding features, or improving documentation, here's how to get started:

Setup

git clone https://github.com/KnowGuard-AI/HotMem.git
cd HotMem
uv sync

Testing

uv run pytest              # run all tests
uv run pytest -v          # verbose output
uv run pytest tests/test_search.py  # run specific test file

Code Quality

uv run ruff check src/ tests/    # lint
uv run ruff format src/ tests/   # auto-format

Before submitting a PR:

  • Ensure all tests pass: uv run pytest
  • Format your code: uv run ruff format src/ tests/
  • Run linter: uv run ruff check src/ tests/

Module Guidelines

When adding features, follow the module architecture:

  • Keep concerns isolated — each module has a single responsibility
  • Add self-documenting headers — module docstrings explain the extension point
  • Emit JSON traces — use trace.py for structured logging
  • Write tests — place tests in tests/ alongside the module name

Pull Requests

  • Target main branch
  • Include tests for new features
  • Update README.md if adding public APIs
  • Keep commits focused and descriptive

License

By contributing, you agree that your contributions will be licensed under the same license as the project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hotmem-0.1.5.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hotmem-0.1.5-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file hotmem-0.1.5.tar.gz.

File metadata

  • Download URL: hotmem-0.1.5.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hotmem-0.1.5.tar.gz
Algorithm Hash digest
SHA256 b2bc4d319c9eba27d6d2eab3e9977e1c14d914fc8d582e4436d9c7e1a35fb465
MD5 da6a2e72d567b10025b1515a82b34e2c
BLAKE2b-256 b67c5f82087e79a6e58841d20bfbd590cc91500ac85f6389fe5c06baaf28764b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hotmem-0.1.5.tar.gz:

Publisher: release.yml on KnowGuard-AI/HotMem

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hotmem-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: hotmem-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hotmem-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 abba90e1419acf3085fe4c1a3e102254a6216be9bc8a243cbd426969c947f157
MD5 0d1004b6fb7e64465115863a3ebe38f3
BLAKE2b-256 26d281bcc12adbffa35e6c362194c480bab59f20a15d6c0584023181e81d0c02

See more details on using hashes here.

Provenance

The following attestation bundles were made for hotmem-0.1.5-py3-none-any.whl:

Publisher: release.yml on KnowGuard-AI/HotMem

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page