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 HindsightToolset

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

from hindsight_haystack import HindsightToolset

toolset = HindsightToolset(
    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.0.tar.gz (154.6 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.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hindsight_haystack-0.1.0.tar.gz
  • Upload date:
  • Size: 154.6 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.0.tar.gz
Algorithm Hash digest
SHA256 dfd4e08c83d1df17ea939e1710b69825ddbdcb9a865b14b69f8254343af6add6
MD5 aed4b874bd1c7da8cc62efca1642d106
BLAKE2b-256 60697eb5df84426eb003ef54cd6831ebffb779702e61b25805dd59e0b68b197f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hindsight_haystack-0.1.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hindsight_haystack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5284f661c303f3e973fda2b533abb0e9a66056f2aab585e4158592ff51bbd33d
MD5 a15d82b4a8f4d82f7efee6fd1a05785f
BLAKE2b-256 4107fe6435ac6feafb6a1a8f69110b2ed6323e75d29352320bc9be3d0d458471

See more details on using hashes here.

Provenance

The following attestation bundles were made for hindsight_haystack-0.1.0-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