Integration

Long-term memory for Haystack

Haystack 2.x's vector DocumentStores are single-purpose: vector retrieval and not much else. `EngramWriter` and `EngramRetriever` are Haystack `@component` classes you add to any `Pipeline`, and they bring hybrid retrieval (BM25 + vector + graph) plus a synthesized answer with no extra DocumentStore needed.

Install

Three steps: sign up for an Engram API key, paste a BYOK LLM-provider key on /models, then drop the snippet below into Haystack.

Three steps to memory in your agent

  1. Sign up. Free, no card. You'll land on a Getting Started page that walks the next two steps.
  2. Add your LLM key. Engram is BYOK. Paste an OpenAI / Anthropic / Groq / Together / Fireworks key and we'll route every extraction and query call through your provider. You pay your provider directly. We never see your inference.
  3. Paste the snippet below into your agent and restart it. Use Authorization: Bearer <api-key>with the API key from your portal.

engram-haystack: EngramWriter + EngramRetriever for Haystack 2.x

Two @component classes that plug into any Pipeline. Writer ingests facts into a single Engram bucket, Retriever returns Haystack Documentobjects plus a synthesized answer. Hybrid retrieval (BM25 + vector + KG) replaces the vector-only DocumentStore stack. Source: github.com/lumetra-io/engram-haystack.

  1. Install:
  2. Terminal
    pip install lumetra-engram haystack-ai
  3. Vendor engram_haystack.py (~60 LOC) and export your API key:
  4. Terminal
    curl -fsSL https://raw.githubusercontent.com/lumetra-io/engram-haystack/main/engram_haystack.py -o engram_haystack.py
    export ENGRAM_API_KEY="<api-key>"
  5. Use as a pipeline retriever (returns both synthesized answer and ranked Documents):
  6. Python
    from haystack import Pipeline
    from engram_haystack import EngramRetriever
    
    pipe = Pipeline()
    pipe.add_component("retriever", EngramRetriever(bucket="my-app", top_k=5))
    
    result = pipe.run({"retriever": {"query": "What does the user prefer for UI themes?"}})
    print(result["retriever"]["answer"])         # synthesized answer
    for doc in result["retriever"]["documents"]:  # Haystack Document objects
        print(doc.score, doc.content[:80])

What you can do once memory's wired in

  • Replace a vector-only retrieval stage with `EngramRetriever` and get BM25 + vector + graph fusion for free
  • Connect `EngramWriter` to an ingestion pipeline that stores extracted facts as memories
  • Combine with Haystack's other components: `EngramRetriever` returns both `Document` objects and a synthesized `answer`
  • Self-host Engram, point both components at your endpoint, and run an air-gapped RAG stack

FAQ

Does `EngramRetriever` return Haystack `Document` objects?

Yes. `documents` is a list of `Document` with `.content`, `.score`, and metadata, plus an `answer` field with Engram's synthesized response. Use both, or just one.

Can I stack Haystack's reranker on top of `EngramRetriever`?

You can, but Engram already reranks internally (cross-encoder). Double-reranking usually hurts more than it helps, so profile before stacking.

Is the package on PyPI?

Vendor `engram_haystack.py` from the repo (~60 LOC) for now. PyPI release coming.

Ship durable memory in Haystack today

Free tier: 10K memories and 50K retrievals per month. No credit card. Same Engram backend powers all 41 integrations, so memories you write from one client are immediately queryable from the rest.