autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Add Hindsight long-term memory extension (autogen_ext.tools.hindsight)

Open DK09876 opened this issue 7 months ago • 4 comments

Summary

Hindsight is an open-source (MIT) long-term memory engine for AI agents. It automatically extracts facts from conversations, builds entity graphs, and retrieves relevant context using four parallel strategies (semantic, BM25, graph traversal, temporal).

We've built an AutoGen extension (hindsight-autogen) that provides FunctionTool instances for retain, recall, and reflect operations. We'd like to propose including it as an official extension under autogen_ext.tools.hindsight.

What it does

Hindsight gives AutoGen agents persistent long-term memory across conversations:

  • Retain — store facts, preferences, or decisions extracted from conversations
  • Recall — search memories using multi-strategy retrieval (semantic, BM25, graph, temporal)
  • Reflect — synthesize coherent answers from stored memories using LLM-powered reasoning

Existing integration

The extension is already published and working:

Usage example

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

tools = create_hindsight_tools(bank_id="my-memory-bank")

agent = AssistantAgent(
    name="assistant",
    model_client=OpenAIChatCompletionClient(model="gpt-4o"),
    tools=tools,
    system_message="You are a helpful assistant with long-term memory.",
)

Hindsight deployment

Hindsight is fully self-hosted — runs locally via Docker, pip, or embedded in Python:

docker run --rm -it --pull always -p 8888:8888 \
  -e HINDSIGHT_API_LLM_API_KEY=$OPENAI_API_KEY \
  -v $HOME/.hindsight-docker:/home/hindsight/.pg0 \
  ghcr.io/vectorize-io/hindsight:latest

Proposal

We're happy to:

  1. Contribute the extension code to python/packages/autogen-ext/ under autogen_ext.tools.hindsight
  2. Add tests following the existing patterns in the repo
  3. Add documentation to the extensions user guide

Let us know if this is something the team would be interested in, and we'll put together a PR.

DK09876 avatar Apr 03 '26 15:04 DK09876

Interesting proposal.

As agent memory becomes persistent, the risk may not be memory loss — but systems confidently carrying forward stale assumptions across sessions.

Continuity is powerful.

But continuity without checkpoints can quietly turn drift into normal behavior.

humanal-labs avatar May 15 '26 00:05 humanal-labs

The pattern that usually hurts here is not the first failure. It's the quiet retry loop after the first failure, when the system still can't prove anything changed.

One simple rule has been surprisingly effective for us: before another attempt, show what changed.

If the answer is basically "nothing useful, but maybe this time", that's the loop you want to kill early.

Agents get a lot more usable once they have a finish line, not just another retry. We've been building MartinLoop around that exact problem and it's been a much better lever than adding more magic.

Keesan12 avatar Jun 06 '26 18:06 Keesan12

@humanal-labs your observation about continuity without checkpoints turning drift into normal behavior is the single most important sentence in this thread. That's the exact failure mode that makes long-term memory dangerous rather than just useful.

A long-term memory extension needs three foundational capabilities that most implementations skip:

First, typed memories with different retention strategies. Episodic memories (what happened in a specific session), semantic memories (extracted facts and patterns), and procedural memories (learned workflows and rules) need fundamentally different decay curves and consolidation strategies. An episodic memory of "user said X in session 12" should decay relatively quickly unless it's accessed frequently. A semantic fact extracted from that episode ("user prefers Y") should persist much longer. A procedural rule ("when user asks about Z, always check Y first") should persist indefinitely. Treating all memories with the same retention policy means either critical facts decay too fast or trivial episodes stick around forever.

Second, importance-weighted decay rather than uniform TTLs. Not all memories within the same type are equal. A memory stored at importance 0.9 with a half-life of 30 days will persist for months. A memory stored at importance 0.3 with the same half-life will effectively disappear within a week unless something accesses it. Access resets the decay clock but with diminishing returns — the 10th access to the same memory contributes less heat than the 1st. This prevents frequently-accessed-but-low-value memories from becoming artificially immortal.

Third — and this is the part that addresses @humanal-labs' concern about stale assumptions — the episodic-to-semantic consolidation pipeline. Raw session events should periodically consolidate into durable patterns through a "dream" processing phase. During consolidation, the system clusters related episodic memories, extracts common patterns, and promotes them to semantic memories at appropriate importance levels. Critically, the raw episodes are preserved (never rewritten), and the consolidated semantic memory links back to its source episodes. This means you can always audit why the system believes what it believes, and if a consolidated fact becomes stale, you can trace it back to the original evidence and see whether that evidence still holds. Without this pipeline, you either keep every raw event forever (expensive, noisy) or summarize and discard (lossy, unauditable).

@Keesan12 your "before another attempt, show what changed" rule maps perfectly to memory-based retry logic. Store each attempt as an episodic memory. Before the next attempt, recall the previous attempt memories and require the new attempt to demonstrate a delta. If the recalled episodes show the same approach was tried N times with no progress, the system should escalate rather than retry.

ferhimedamine avatar Jun 11 '26 21:06 ferhimedamine

The four parallel retrieval strategies (semantic, BM25, graph traversal, temporal) align closely with what we've found necessary. Pure semantic search misses when the query uses different terminology from the stored fact, BM25 catches those exact-match cases, and graph traversal surfaces related entities that neither search type finds on its own. Temporal retrieval is the one most systems underinvest in — understanding 'what happened before X' or 'the most recent decision about Y' requires time-aware scoring, not just recency sorting. We implemented temporal reasoning through decay-weighted importance where recent memories of the same importance score rank higher, combined with explicit timestamp-range filtering in queries. Our knowledge graph implementation with entity traversal: https://github.com/dakera-ai/dakera-py/blob/main/examples/knowledge_graph.py

ferhimedamine avatar Jun 15 '26 21:06 ferhimedamine