RCLL — self-hosted shared memory for a team of AI agents. Canonical repository; pushed out to github.com/Holetron-lab/fleet-memory. Fork of vectorize-io/hindsight (MIT). https://rcll.ai
Find a file
DK09876 1d4879a206
feat(litellm): async retain, reflect support, and API cleanup (#167)
* feat(litellm): async retain with sync option, fix client session cleanup

- Add sync parameter to retain() for blocking vs background operation
- Default to async retain (sync=False) for better performance
- Add get_pending_retain_errors() to check async failures
- Fix "Unclosed client session" warnings by properly closing clients
- Fix "Timeout context manager" asyncio errors by creating fresh clients
- Each API call now creates and closes its own client (aiohttp limitation)
- Add _get_client() and _close_client() helpers for consistent handling
- Update recall(), reflect(), _retain_sync() and _inject_memories()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(litellm): add reflect support and require explicit hindsight_query

- Make hindsight_query required when inject_memories=True to enforce
  intentional memory queries (no automatic last-user-message fallback)
- Add reflect_context parameter for shaping LLM reasoning in reflect
- Add reflect_response_schema for structured JSON output from reflect
- Add _reflect_sync() and _reflect_async() methods in callbacks
- Update wrappers.py to support response_schema in reflect/areflect

This improves the developer experience by making memory injection
explicit and adds full reflect API support through the integration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(litellm): rename recall_budget to budget, add per-call reflect context

- Rename `recall_budget` parameter to `budget` for consistency with API
- Add `hindsight_reflect_context` kwarg for per-call reflect context override
- Fix reflect() to not pass None values for optional parameters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs(litellm): update README for new API structure and features

- Document configure() vs set_defaults() separation
- Add hindsight_query requirement when inject_memories=True
- Document async retain (sync=False default) and get_pending_retain_errors()
- Add hindsight_reflect_context per-call override documentation
- Document budget parameter (renamed from recall_budget)
- Add reflect_context and reflect_response_schema options
- Update all code examples to use new API structure
- Add new functions to API Reference table

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(litellm): update tests for new configure/set_defaults API

- Update tests to use separate configure() and set_defaults() calls
- Fix test assertions to check config vs defaults appropriately
- Add tests for legacy parameter backwards compatibility
- Add new TestSetDefaults test class
- Fix _format_memories test call signature (settings, config order)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add set_bank_mission(), deprecate set_bank_background()

- Add mission parameter to hindsight_client.create_bank()
- Add set_bank_mission() function to hindsight_litellm
- Deprecate set_bank_background() with DeprecationWarning
- Update _create_or_update_bank() to support mission parameter
- Update README and docstrings to document the new API

The 'background' field has been deprecated in the Hindsight API in favor
of 'mission' which is used for mental model generation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove deprecated background parameter and legacy configure() parameters

- Remove set_bank_background() in favor of set_bank_mission()
- Remove background parameter from _create_or_update_bank()
- Remove background parameter from hindsight_client.create_bank()
- Remove legacy parameters from configure() (bank_id, document_id, budget, etc.)
- These have been replaced by the set_defaults() API
- Remove legacy test cases for deprecated parameters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: update tests and docs to use mission instead of background

The create_bank() parameter was renamed from background to mission.
Update all tests and doc examples to use the new parameter name.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Nicolò Boschi <boschi1997@gmail.com>
2026-01-26 10:07:32 +01:00
.githooks feat: support for gemini-3-pro and gpt-5.2 (#30) 2025-12-16 11:00:27 +01:00
.github feat(cli): accept more file types on retain-files (#163) 2026-01-15 18:34:44 +01:00
cookbook prepare for release 2025-12-03 11:52:25 +01:00
docker/standalone chore: add flag to not include ml libs in docker image (#130) 2026-01-08 18:22:42 +01:00
helm/hindsight feat: new 'worker' service (#176) 2026-01-20 10:17:56 +01:00
hindsight Release v0.3.0 2026-01-13 18:43:33 +01:00
hindsight-api fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
hindsight-cli fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
hindsight-clients feat(litellm): async retain, reflect support, and API cleanup (#167) 2026-01-26 10:07:32 +01:00
hindsight-control-plane fix: improve mental model consolidation (#197) 2026-01-26 09:54:25 +01:00
hindsight-dev feat: revisit mental models, directives and reflections (#179) 2026-01-22 17:13:16 +01:00
hindsight-docs feat(litellm): async retain, reflect support, and API cleanup (#167) 2026-01-26 10:07:32 +01:00
hindsight-embed Fix skill installer test examples to use meaningful content (#160) 2026-01-14 18:41:04 +01:00
hindsight-integration-tests feat: introduce mental models (#132) 2026-01-16 11:16:41 +01:00
hindsight-integrations feat(litellm): async retain, reflect support, and API cleanup (#167) 2026-01-26 10:07:32 +01:00
monitoring/grafana/dashboards feat: add tenant to metrics labels (#151) 2026-01-13 15:31:58 +01:00
scripts feat: new 'worker' service (#176) 2026-01-20 10:17:56 +01:00
skills fix skill names 2026-01-23 11:03:12 +01:00
.dockerignore .dockerignore 2025-12-03 21:11:27 +01:00
.env.example feat: Add Anthropic Claude and LM Studio provider support (#36) 2026-01-01 16:34:11 +01:00
.gitignore feat: improve mental model refresh and add directives (#166) 2026-01-19 11:38:35 +01:00
.python-version initial commit 2025-10-30 12:53:12 +01:00
.sesskey papers and fixes 2025-11-14 14:07:41 +01:00
AGENTS.md chore: unify agents.md and claude.md (#173) 2026-01-19 14:18:33 +01:00
CLAUDE.md feat: improve mental model refresh and add directives (#166) 2026-01-19 11:38:35 +01:00
CODE_OF_CONDUCT.md add repo files 2025-12-04 10:20:26 +01:00
CONTRIBUTING.md chore: add pre-commit setup instructions 2026-01-05 10:03:15 +01:00
hindsight-favicon.png brandind and misc fixes 2025-12-11 12:46:48 +01:00
LICENSE Add license (#12) 2025-12-03 23:06:15 +01:00
package-lock.json feat: improve mental model refresh and add directives (#166) 2026-01-19 11:38:35 +01:00
package.json fix(security): fix qs - CVE-2025-15284 (#113) 2026-01-07 15:33:07 +01:00
pyproject.toml feat: add hindsight-embed and native agentic skill (#64) 2025-12-22 16:42:11 +01:00
README.md doc: update expired Slack invite link (#157) 2026-01-13 16:57:23 -05:00
SECURITY.md add repo files 2025-12-04 10:20:26 +01:00
uv.lock fix(sec): upgrade vulnerable deps (#174) 2026-01-19 14:27:31 +01:00


What is Hindsight?

Hindsight™ is an agent memory system built to create smarter agents that learn over time. It eliminates the shortcomings of alternative techniques such as RAG and knowledge graph and delivers state-of-the-art performance on long term memory tasks.

Hindsight addresses common challenges that have frustrated AI engineers building agents to automate tasks and assist users with conversational interfaces. Many of these challenges stem directly from a lack of memory.

  • Inconsistency: Agents complete tasks successfully one time, then fail when asked to complete the same task again. Memory gives the agent a mechanism to remember what worked and what didn't and to use that information to reduce errors and improve consistency.
  • Hallucinations: Long term memory can be seeded with external knowledge to ground agent behavior in reliable sources to augment training data.
  • Cognitive Overload: As workflows get complex, retrievals, tool calls, user messages and agent responses can grow to fill the context window leading to context rot. Short term memory optimization allows agents to reduce tokens and focus context by removing irrelevant details.

How is Hindsight Different From Other Memory Systems?

Overview

Most agent memory implementation rely on basic vector search or sometimes use a knowledge graph. Hindsight uses biomimetic data structures to organize agent memories in a way that is more like how human memory works:

  • World: Facts about the world ("The stove gets hot")
  • Experiences: Agent's own experiences ("I touched the stove and it really hurt")
  • Opinion: Beliefs with confidence scores ("I shouldn't touch the stove again" - .99 confidence)
  • Observation: Complex mental models derived by reflecting on facts and experiences ("Curling irons, ovens, and fire are also hot. I shouldn't touch those either.")

Memories in Hindsight are stored in banks (i.e. memory banks). When memories are added to Hindsight, they are pushed into either the world facts or experiences memory pathway. They are then represented as a combination of entities, relationships, and time series with sparse/dense vector representations to aid in later recall.

Hindsight provides three simple methods to interact with the system:

  • Retain: Provide information to Hindsight that you want it to remember
  • Recall: Retrieve memories from Hindsight
  • Reflect: Reflect on memories and experiences to generate new observations and insights from existing memories.

Agent Memory That Learns

A key goal of Hindsight is to build agent memory that enables agents to learn and improve over time. This is the role of the reflect operation which provides the agent to form broader opinions and observations over time.

For example, imagine a product support agent that is helping a user troubleshoot a problem. It uses a search-documentation tool it found on an MCP server. Later in the conversation, the agent discovers that the documentation returned from the tool wasn't for the product the user was asking about. The agent now has an experience in its memory bank. And just like humans, we want that agent to learn from its experience.

As the agent gains more experiences, reflect allows the agent to form observations about what worked, what didn't, and what to do differently the next time it encounters a similar task.


Memory Performance & Accuracy

Hindsight has achieved state-of-the-art performance on the LongMemEval benchmark, widely used to assess memory system performance across a variety of conversational AI scenarios. The current reported performance of Hindsight and other agent memory solutions as of December 2025 is shown here:

Overview

The benchmark performance data for Hindsight and GPT-4o (full context) have been reproduced by research collaborators at the Virginia Tech Sanghani Center for Artificial Intelligence and Data Analytics and The Washington Post. Other scores are self-reported by software vendors.

A thorough examination of the techniques implemented in Hindsight and detailed breakdowns of benchmark performance are available on arXiv. This research is currently being prepared for conference submission and the wider peer review process.

The benchmark results from this research can be inspected in our visual benchmark explorer. As additional improvements are made to Hindsight, new benchmark data will be available for review using this same tool.

Quick Start

export OPENAI_API_KEY=your-key

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

You can modify the LLM provider by setting HINDSIGHT_API_LLM_PROVIDER. Valid options are openai, anthropic, gemini, groq, ollama, and lmstudio. The documentation provides more details on supported models.

API: http://localhost:8888
UI: http://localhost:9999

Install client:

pip install hindsight-client -U
# or
npm install @vectorize-io/hindsight-client

Python example:

from hindsight_client import Hindsight

client = Hindsight(base_url="http://localhost:8888")

# Retain: Store information
client.retain(bank_id="my-bank", content="Alice works at Google as a software engineer")

# Recall: Search memories
client.recall(bank_id="my-bank", query="What does Alice do?")

# Reflect: Generate disposition-aware response
client.reflect(bank_id="my-bank", query="Tell me about Alice")

Python (embedded, no Docker)

pip install hindsight-all -U
import os
from hindsight import HindsightServer, HindsightClient

with HindsightServer(
    llm_provider="openai",
    llm_model="gpt-5-mini", 
    llm_api_key=os.environ["OPENAI_API_KEY"]
) as server:
    client = HindsightClient(base_url=server.url)
    client.retain(bank_id="my-bank", content="Alice works at Google")
    results = client.recall(bank_id="my-bank", query="Where does Alice work?")

Node.js / TypeScript

npm install @vectorize-io/hindsight-client
const { HindsightClient } = require('@vectorize-io/hindsight-client');

const client = new HindsightClient({ baseUrl: 'http://localhost:8888' });

await client.retain('my-bank', 'Alice loves hiking in Yosemite');
await client.recall('my-bank', 'What does Alice like?');

Architecture & Operations

Retain

The retain operation is used to push new memories into Hindsight. It tells Hindsight to retain the information you pass in as an input.

from hindsight_client import Hindsight

client = Hindsight(base_url="http://localhost:8888")

# Simple
client.retain(
    bank_id="my-bank",
    content="Alice works at Google as a software engineer"
)

# With context and timestamp
client.retain(
    bank_id="my-bank",
    content="Alice got promoted to senior engineer",
    context="career update",
    timestamp="2025-06-15T10:00:00Z"
)

Behind the scenes, the retain operation uses an LLM to extract key facts, temporal data, entities, and relationships. It passes these through a normalization process to transform extracted data into canonical entities, time series, and search indexes along with metadata. These representations create the pathways for accurate memory retrieval in the recall and reflect operations.

Retain Operation

Recall

The recall operation is used to retrieve memories. These memories can come from any of the memory types (world, experiences, etc.)

from hindsight_client import Hindsight

client = Hindsight(base_url="http://localhost:8888")

# Simple
client.recall(bank_id="my-bank", query="What does Alice do?")

# Temporal
client.recall(bank_id="my-bank", query="What happened in June?")

Recall performs 4 retrieval strategies in parallel:

  • Semantic: Vector similarity
  • Keyword: BM25 exact matching
  • Graph: Entity/temporal/causal links
  • Temporal: Time range filtering

Retain Operation

The individual results from the retrievals are merged, then ordered by relevance using reciprocal rank fusion and a cross-encoder reranking model.

The final output is trimmed as needed to fit within the token limit.

Reflect

The reflect operation is used to perform a more thorough analysis of existing memories. This allows the agent to form new connections between memories which are then persisted as opinions and/or observations. When building agents, the reflect operation is a key capability to enable the agent to learn from its experiences.

For example, the reflect operation can be used to support use cases such as:

  • An AI Project Manager reflecting on what risks need to be mitigated on a project.
  • A Sales Agent reflecting on why certain outreach messages have gotten responses while others haven't.
  • A Support Agent reflecting on opportunities where customers have questions not answered by current product documentation.

The reflect operation can also be used to handle on-demand question answering or analysis which require more deep thinking.

from hindsight_client import Hindsight

client = Hindsight(base_url="http://localhost:8888")

client.reflect(bank_id="my-bank", query="What should I know about Alice?")

Retain Operation


Resources

Documentation:

Clients:

Community:


Star History

Star History Chart

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE


Built by Vectorize.io