Skip to main content

Haystack integration for Hindsight - persistent memory for AI agents

Project description

hindsight-haystack

Haystack integration for Hindsight — persistent long-term memory for AI agents.

Provides Haystack Tool instances that give any Haystack Agent persistent memory via Hindsight's retain/recall/reflect APIs.

Installation

pip install hindsight-haystack

Quick Start

from hindsight_client import Hindsight
from hindsight_haystack import create_hindsight_tools
from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage

client = Hindsight(base_url="http://localhost:8888")

tools = create_hindsight_tools(
    client=client,
    bank_id="user-123",
    mission="Track user preferences",
)

agent = Agent(
    chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"),
    tools=tools,
    system_prompt=(
        "You are a helpful assistant with long-term memory. "
        "Use retain_memory to store important facts. "
        "Use recall_memory to search memory before answering."
    ),
)

result = agent.run(messages=[ChatMessage.from_user("Remember that I prefer dark mode")])
print(result["messages"][-1].text)

Automatic Memory with HindsightMemoryWrapper

For automatic recall and retain without relying on the agent to call tools:

from hindsight_haystack import HindsightMemoryWrapper

toolset = HindsightMemoryWrapper(
    client=client,
    bank_id="user-123",
    mission="Track user preferences",
    auto_recall=True,   # Inject memories into system prompt before each turn
    auto_retain=True,    # Store user + assistant messages after each turn
)

agent = Agent(
    chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"),
    tools=toolset,
    system_prompt="You are a helpful assistant with long-term memory.",
)

# Use toolset.run() for automatic memory behavior
result = toolset.run(agent, messages=[ChatMessage.from_user("I prefer dark mode")])

Selective Tools

# Only retain + recall (no reflect)
tools = create_hindsight_tools(
    client=client,
    bank_id="user-123",
    include_reflect=False,
)

Configuration

from hindsight_haystack import configure

configure(
    hindsight_api_url="http://localhost:8888",
    api_key="your-api-key",
    budget="mid",
    tags=["source:haystack"],
    context="my-app",
    mission="Track user preferences",
)

# Now you can skip client= and url= arguments
tools = create_hindsight_tools(bank_id="user-123")

Requirements

  • Python 3.10+
  • haystack-ai >= 2.12.0
  • hindsight-client >= 0.4.0

Documentation

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

hindsight_haystack-0.1.1.tar.gz (154.5 kB view details)

Uploaded Source

Built Distribution

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

hindsight_haystack-0.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file hindsight_haystack-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for hindsight_haystack-0.1.1.tar.gz
Algorithm Hash digest
SHA256 da076c775e2af678898d58b78c3565456c0e421d65cdd5e6ec806f8b41284cdf
MD5 e85b4ff9f1c8716b6d58b67aeda81f54
BLAKE2b-256 8d4ddfa182600e5a37044ccff0b98af8785e3a90a1d743987228f0d97d56064f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hindsight_haystack-0.1.1.tar.gz:

Publisher: release-integration.yml on vectorize-io/hindsight

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

File details

Details for the file hindsight_haystack-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for hindsight_haystack-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c22849e04497155eced9010f2083db0cfa6ef61e37e0f092da851b4b22aba618
MD5 1a6b92d57f56cf29952bc570ed9d6c1d
BLAKE2b-256 c4b08d5ca2c7504d9e52142c9bcc6c0376310f034a69c9623201834b30ba972e

See more details on using hashes here.

Provenance

The following attestation bundles were made for hindsight_haystack-0.1.1-py3-none-any.whl:

Publisher: release-integration.yml on vectorize-io/hindsight

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