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.0hindsight-client >= 0.4.0
Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da076c775e2af678898d58b78c3565456c0e421d65cdd5e6ec806f8b41284cdf
|
|
| MD5 |
e85b4ff9f1c8716b6d58b67aeda81f54
|
|
| BLAKE2b-256 |
8d4ddfa182600e5a37044ccff0b98af8785e3a90a1d743987228f0d97d56064f
|
Provenance
The following attestation bundles were made for hindsight_haystack-0.1.1.tar.gz:
Publisher:
release-integration.yml on vectorize-io/hindsight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hindsight_haystack-0.1.1.tar.gz -
Subject digest:
da076c775e2af678898d58b78c3565456c0e421d65cdd5e6ec806f8b41284cdf - Sigstore transparency entry: 1784591426
- Sigstore integration time:
-
Permalink:
vectorize-io/hindsight@a1228ec3a77d19c2f551aa48abb457d2b462397b -
Branch / Tag:
refs/tags/integrations/haystack/v0.1.1 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integration.yml@a1228ec3a77d19c2f551aa48abb457d2b462397b -
Trigger Event:
push
-
Statement type:
File details
Details for the file hindsight_haystack-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hindsight_haystack-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c22849e04497155eced9010f2083db0cfa6ef61e37e0f092da851b4b22aba618
|
|
| MD5 |
1a6b92d57f56cf29952bc570ed9d6c1d
|
|
| BLAKE2b-256 |
c4b08d5ca2c7504d9e52142c9bcc6c0376310f034a69c9623201834b30ba972e
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hindsight_haystack-0.1.1-py3-none-any.whl -
Subject digest:
c22849e04497155eced9010f2083db0cfa6ef61e37e0f092da851b4b22aba618 - Sigstore transparency entry: 1784591571
- Sigstore integration time:
-
Permalink:
vectorize-io/hindsight@a1228ec3a77d19c2f551aa48abb457d2b462397b -
Branch / Tag:
refs/tags/integrations/haystack/v0.1.1 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integration.yml@a1228ec3a77d19c2f551aa48abb457d2b462397b -
Trigger Event:
push
-
Statement type: