Skip to main content

AutoGen integration for Hindsight - persistent memory tools for AI agents

Project description

hindsight-autogen

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

Provides FunctionTool instances that give AutoGen agents the ability to store, search, and synthesize memories across conversations.

Prerequisites

Installation

pip install hindsight-autogen autogen-agentchat "autogen-ext[openai]"

hindsight-autogen pulls in autogen-core and hindsight-client. You also need autogen-agentchat for AssistantAgent and autogen-ext[openai] for the OpenAI model client.

Quick Start

import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from hindsight_client import Hindsight
from hindsight_autogen import create_hindsight_tools

async def main():
    client = Hindsight(base_url="http://localhost:8888")
    await client.acreate_bank(bank_id="user-123")

    model_client = OpenAIChatCompletionClient(model="gpt-4o")
    tools = create_hindsight_tools(client=client, bank_id="user-123")

    agent = AssistantAgent(
        name="assistant",
        model_client=model_client,
        tools=tools,
    )

    # Store a memory
    result = await agent.run(task="Remember that I prefer dark mode")
    print(result.messages[-1].content)

    # 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 agent.run(task="What are my UI preferences?")
    print(result.messages[-1].content)

    # Clean up
    await client.aclose()
    await model_client.close()

asyncio.run(main())

The agent gets three tools:

  • hindsight_retain — Store information to long-term memory
  • hindsight_recall — Search long-term memory for relevant facts
  • hindsight_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_autogen 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
  • autogen-core >= 0.4.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_autogen-0.1.3.tar.gz (105.3 kB view details)

Uploaded Source

Built Distribution

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

hindsight_autogen-0.1.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file hindsight_autogen-0.1.3.tar.gz.

File metadata

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

File hashes

Hashes for hindsight_autogen-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d4b825ba53bb3c1ba8942d5eef4bbf012585b9264e14434f52cc83459df8c2d3
MD5 861b68c67d3a79abba13c3f0d263a470
BLAKE2b-256 7f149fdeda23b055147ee83a894bf173a3dda6633966aa66ae1881b457e36055

See more details on using hashes here.

Provenance

The following attestation bundles were made for hindsight_autogen-0.1.3.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_autogen-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for hindsight_autogen-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d89f1ebb20ede98f10d279ea1f760d95bba7f92ee2137f46cd8be1671411a8e8
MD5 05e1e685a2b8d07bd632e084d36272ad
BLAKE2b-256 b817b6c60728a429087669d14427e2877e248e6f538517feaa2260f9d9b63c07

See more details on using hashes here.

Provenance

The following attestation bundles were made for hindsight_autogen-0.1.3-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