AG2 integration for Hindsight - persistent memory tools for AI agents
Project description
hindsight-ag2
AG2 integration for Hindsight — persistent long-term memory for AI agents.
Provides Hindsight-backed tool functions that give AG2 agents long-term memory across conversations via retain/recall/reflect operations.
Prerequisites
- Python 3.10+
- Running Hindsight instance (quickstart)
Installation
pip install hindsight-ag2
Quick Start
from autogen import AssistantAgent, UserProxyAgent, LLMConfig
from hindsight_ag2 import register_hindsight_tools
llm_config = LLMConfig(api_type="openai", model="gpt-4o-mini")
with llm_config:
assistant = AssistantAgent(
name="assistant",
system_message="You are a helpful assistant with long-term memory.",
)
user_proxy = UserProxyAgent(
name="user",
human_input_mode="NEVER",
)
# Register Hindsight memory tools on both agents
register_hindsight_tools(
assistant, user_proxy,
bank_id="my-bank",
hindsight_api_url="http://localhost:8888",
)
# The assistant can now use hindsight_retain, hindsight_recall, hindsight_reflect
result = user_proxy.initiate_chat(
assistant,
message="Remember that I prefer Python over JavaScript.",
)
Tools
| Tool | Operation | Description |
|---|---|---|
hindsight_retain |
Retain | Store facts, preferences, decisions to long-term memory |
hindsight_recall |
Recall | Multi-strategy search across stored memories |
hindsight_reflect |
Reflect | Synthesize reasoned answers from memories |
Configuration
Global config
from hindsight_ag2 import configure
configure(
hindsight_api_url="http://localhost:8888",
api_key="your-key", # or set HINDSIGHT_API_KEY env var
budget="mid", # low / mid / high
max_tokens=4096,
tags=["source:ag2"], # default tags for retain
)
Per-call overrides
All global settings can be overridden per create_hindsight_tools() call:
| Parameter | Description | Default |
|---|---|---|
bank_id |
Memory bank ID (required) | — |
client |
Pre-configured Hindsight client |
— |
hindsight_api_url |
API URL | Global config or production |
api_key |
API key | Global config or env var |
budget |
Recall/reflect budget | "mid" |
max_tokens |
Max tokens for recall | 4096 |
tags |
Tags for retain operations | None |
recall_tags |
Tags to filter recall | None |
recall_tags_match |
Tag match mode | "any" |
retain_metadata |
Metadata dict for retain | None |
retain_document_id |
Document ID for retain | None |
recall_types |
Fact types to filter | None |
recall_include_entities |
Include entities in recall | False |
reflect_context |
Additional context for reflect | None |
reflect_max_tokens |
Max tokens for reflect | max_tokens |
reflect_response_schema |
JSON schema for reflect output | None |
reflect_tags |
Tags for reflect (fallback: recall_tags) |
None |
reflect_tags_match |
Tag match for reflect | recall_tags_match |
Advanced: Manual Registration
from hindsight_ag2 import create_hindsight_tools
tools = create_hindsight_tools(
bank_id="my-bank",
hindsight_api_url="http://localhost:8888",
)
for tool_fn in tools:
assistant.register_for_llm(description=tool_fn.__doc__)(tool_fn)
user_proxy.register_for_execution()(tool_fn)
Advanced: GroupChat with Shared Memory
from autogen import AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager, LLMConfig
from hindsight_ag2 import register_hindsight_tools
llm_config = LLMConfig(api_type="openai", model="gpt-4o-mini")
with llm_config:
researcher = AssistantAgent(name="researcher", system_message="You research topics.")
writer = AssistantAgent(name="writer", system_message="You write content.")
executor = UserProxyAgent(name="executor", human_input_mode="NEVER")
# All agents share the same memory bank
for agent in [researcher, writer]:
register_hindsight_tools(agent, executor, bank_id="team-memory")
group_chat = GroupChat(agents=[researcher, writer, executor], messages=[])
manager = GroupChatManager(groupchat=group_chat)
Requirements
ag2>=0.9.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_ag2-0.1.2.tar.gz.
File metadata
- Download URL: hindsight_ag2-0.1.2.tar.gz
- Upload date:
- Size: 119.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70aed2951b76c05ff98b9fd9f2d1ec1fd7aa163b076983c553f920a595286c43
|
|
| MD5 |
066cbe83f8118385f76500e5fd3c3e27
|
|
| BLAKE2b-256 |
8025f42d9a9ccc8a1af987b875d58a5b73aeef50158327652e972aff7129846e
|
Provenance
The following attestation bundles were made for hindsight_ag2-0.1.2.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_ag2-0.1.2.tar.gz -
Subject digest:
70aed2951b76c05ff98b9fd9f2d1ec1fd7aa163b076983c553f920a595286c43 - Sigstore transparency entry: 1306279541
- Sigstore integration time:
-
Permalink:
vectorize-io/hindsight@2eab07834a7063e1025e2fd908ffec4b04f83639 -
Branch / Tag:
refs/tags/integrations/ag2/v0.1.2 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integration.yml@2eab07834a7063e1025e2fd908ffec4b04f83639 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hindsight_ag2-0.1.2-py3-none-any.whl.
File metadata
- Download URL: hindsight_ag2-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.3 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 |
be2fd7aab2f7f320ca1acf9692b238d65ebc2ae82167542a8a02d884517405e0
|
|
| MD5 |
2f450d2d708ac6a2668621d1b511854e
|
|
| BLAKE2b-256 |
b7699a91e11227dadf08b1d9ad68b30602592ad931556dab1c7db155317f7627
|
Provenance
The following attestation bundles were made for hindsight_ag2-0.1.2-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_ag2-0.1.2-py3-none-any.whl -
Subject digest:
be2fd7aab2f7f320ca1acf9692b238d65ebc2ae82167542a8a02d884517405e0 - Sigstore transparency entry: 1306279610
- Sigstore integration time:
-
Permalink:
vectorize-io/hindsight@2eab07834a7063e1025e2fd908ffec4b04f83639 -
Branch / Tag:
refs/tags/integrations/ag2/v0.1.2 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-integration.yml@2eab07834a7063e1025e2fd908ffec4b04f83639 -
Trigger Event:
push
-
Statement type: