OpenAI Agents SDK integration for Hindsight - persistent memory tools for AI agents
Project description
hindsight-openai-agents
OpenAI Agents SDK integration for Hindsight — persistent long-term memory for AI agents.
Provides FunctionTool instances that give OpenAI Agents SDK agents the ability to store, search, and synthesize memories across conversations.
Prerequisites
- A running Hindsight instance (self-hosted via Docker or Hindsight Cloud)
- Python 3.10+
Installation
pip install hindsight-openai-agents openai-agents
hindsight-openai-agents pulls in openai-agents and hindsight-client.
Quick Start
import asyncio
from agents import Agent, Runner
from hindsight_client import Hindsight
from hindsight_openai_agents import create_hindsight_tools
async def main():
client = Hindsight(base_url="http://localhost:8888")
await client.acreate_bank(bank_id="user-123")
tools = create_hindsight_tools(client=client, bank_id="user-123")
agent = Agent(
name="assistant",
instructions="You are a helpful assistant with long-term memory. Use hindsight_retain to store important facts. Use hindsight_recall to search memory before answering.",
tools=tools,
)
# Store a memory
result = await Runner.run(agent, "Remember that I prefer dark mode")
print(result.final_output)
# Hindsight processes retained content asynchronously (fact extraction,
# entity resolution, embeddings). A brief pause ensures memories are
# searchable before the next recall. In production, this delay is only
# needed when retain and recall happen back-to-back in the same script.
await asyncio.sleep(3)
# Recall it later
result = await Runner.run(agent, "What are my UI preferences?")
print(result.final_output)
# Clean up
await client.aclose()
asyncio.run(main())
The agent gets three tools:
hindsight_retain— Store information to long-term memoryhindsight_recall— Search long-term memory for relevant factshindsight_reflect— Synthesize a reasoned answer from memories
Selecting Tools
Include only the tools you need:
tools = create_hindsight_tools(
client=client,
bank_id="user-123",
include_retain=True,
include_recall=True,
include_reflect=False, # Omit reflect
)
Global Configuration
Instead of passing a client to every call, configure once:
from hindsight_openai_agents import configure, create_hindsight_tools
configure(
hindsight_api_url="http://localhost:8888",
api_key="your-api-key", # Or set HINDSIGHT_API_KEY env var
budget="mid", # Recall budget: low/mid/high
max_tokens=4096, # Max tokens for recall results
tags=["env:prod"], # Tags for stored memories
recall_tags=["scope:global"], # Tags to filter recall
recall_tags_match="any", # Tag match mode
)
# Now create tools without passing client
tools = create_hindsight_tools(bank_id="user-123")
Memory Scoping with Tags
Use tags to partition memories by topic, session, or user:
# Store memories tagged by source
tools = create_hindsight_tools(
client=client,
bank_id="user-123",
tags=["source:chat", "session:abc"],
recall_tags=["source:chat"],
recall_tags_match="any",
)
Configuration Reference
| Parameter | Default | Description |
|---|---|---|
bank_id |
required | Hindsight memory bank ID |
client |
None |
Pre-configured Hindsight client |
hindsight_api_url |
None |
API URL (used if no client provided) |
api_key |
None |
API key (used if no client provided) |
budget |
"mid" |
Recall/reflect budget level (low/mid/high) |
max_tokens |
4096 |
Maximum tokens for recall results |
tags |
None |
Tags applied when storing memories |
recall_tags |
None |
Tags to filter when searching |
recall_tags_match |
"any" |
Tag matching mode (any/all/any_strict/all_strict) |
retain_metadata |
None |
Default metadata dict for retain operations |
retain_document_id |
None |
Default document_id for retain (groups/upserts memories) |
recall_types |
None |
Fact types to filter (world, experience, opinion, observation) |
recall_include_entities |
False |
Include entity information in recall results |
reflect_context |
None |
Additional context for reflect operations |
reflect_max_tokens |
None |
Max tokens for reflect results (defaults to max_tokens) |
reflect_response_schema |
None |
JSON schema to constrain reflect output format |
reflect_tags |
None |
Tags to filter memories used in reflect (defaults to recall_tags) |
reflect_tags_match |
None |
Tag matching for reflect (defaults to recall_tags_match) |
include_retain |
True |
Include the retain (store) tool |
include_recall |
True |
Include the recall (search) tool |
include_reflect |
True |
Include the reflect (synthesize) tool |
Requirements
- Python >= 3.10
- openai-agents >= 0.1.0
- hindsight-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_openai_agents-0.1.0.tar.gz.
File metadata
- Download URL: hindsight_openai_agents-0.1.0.tar.gz
- Upload date:
- Size: 133.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 |
8e8bc24d87ab83acb9c32b620337506d74e2505b8c8eb234a1f2d95a6df27ba1
|
|
| MD5 |
12cd01f9470a0633621352917ef1c56d
|
|
| BLAKE2b-256 |
22335c23e69d9b8f64c9ab79121f6a74eab785a91043840cad54ca4906023660
|
Provenance
The following attestation bundles were made for hindsight_openai_agents-0.1.0.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_openai_agents-0.1.0.tar.gz -
Subject digest:
8e8bc24d87ab83acb9c32b620337506d74e2505b8c8eb234a1f2d95a6df27ba1 - Sigstore transparency entry: 1328170483
- Sigstore integration time:
-
Permalink:
vectorize-io/hindsight@abf24b4e22dc3f279b1d6a482d321b7dc8366dff -
Branch / Tag:
refs/tags/integrations/openai-agents/v0.1.0 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integration.yml@abf24b4e22dc3f279b1d6a482d321b7dc8366dff -
Trigger Event:
push
-
Statement type:
File details
Details for the file hindsight_openai_agents-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hindsight_openai_agents-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 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 |
d85d068e1dd6618ffd93566b0a66e08c556de37beb4f69de168cbaff7342ebbb
|
|
| MD5 |
4ebef9e3b62bff465b7d8acdaab13ab3
|
|
| BLAKE2b-256 |
c1b29c200c822d3d1e2ae4c587a35530bbfb910e0b1dc5dc6cb9afceaffd28e6
|
Provenance
The following attestation bundles were made for hindsight_openai_agents-0.1.0-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_openai_agents-0.1.0-py3-none-any.whl -
Subject digest:
d85d068e1dd6618ffd93566b0a66e08c556de37beb4f69de168cbaff7342ebbb - Sigstore transparency entry: 1328170488
- Sigstore integration time:
-
Permalink:
vectorize-io/hindsight@abf24b4e22dc3f279b1d6a482d321b7dc8366dff -
Branch / Tag:
refs/tags/integrations/openai-agents/v0.1.0 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integration.yml@abf24b4e22dc3f279b1d6a482d321b7dc8366dff -
Trigger Event:
push
-
Statement type: