Skip to main content

Main Methods

Hindsight provides three core operations: retain, recall, and reflect.

Prerequisites

Make sure you've installed Hindsight and completed the Quick Start.

Retain: Store Information

Store conversations, documents, and facts into a memory bank.

# Store a single fact
client.retain(
bank_id="my-bank",
content="Alice joined Google in March 2024 as a Senior ML Engineer"
)

# Store a conversation
conversation = """
User: What did you work on today?
Assistant: I reviewed the new ML pipeline architecture.
User: How did it look?
Assistant: Promising, but needs better error handling.
"""

client.retain(
bank_id="my-bank",
content=conversation,
context="Daily standup conversation"
)

# Batch retain multiple items
client.retain_batch(
bank_id="my-bank",
items=[
{"content": "Bob prefers Python for data science"},
{"content": "Alice recommends using pytest for testing"},
{"content": "The team uses GitHub for code reviews"}
]
)

What happens: Content is processed by an LLM to extract rich facts, identify entities, and build connections in a knowledge graph.

See: Retain Details for advanced options and parameters.


Recall: Search Memories

Search for relevant memories using multi-strategy retrieval.

# Basic search
results = client.recall(
bank_id="my-bank",
query="What does Alice do at Google?"
)

for result in results.results:
print(f"- {result.text}")

# Search with options
results = client.recall(
bank_id="my-bank",
query="What happened last spring?",
budget="high", # More thorough graph traversal
max_tokens=8192, # Return more context
types=["world"] # Only world facts
)

# Include source chunks for more context
results = client.recall(
bank_id="my-bank",
query="Tell me about Alice",
include_chunks=True,
max_chunk_tokens=500
)

# Check chunk details (chunks are on response level, keyed by memory ID)
for result in results.results:
print(f"Memory: {result.text}")
if results.chunks and result.id in results.chunks:
chunk = results.chunks[result.id]
print(f" Source: {chunk.text[:100]}...")

What happens: Four search strategies (semantic, keyword, graph, temporal) run in parallel, results are fused and reranked.

See: Recall Details for tuning quality vs latency.


Reflect: Reason with Disposition

Generate disposition-aware responses that form opinions based on evidence.

# Basic reflect
response = client.reflect(
bank_id="my-bank",
query="Should we adopt TypeScript for our backend?",
include_facts=True,
)

print(response.text)
print("\nBased on:", len(response.based_on.memories if response.based_on else []), "facts")

# Reflect with options
response = client.reflect(
bank_id="my-bank",
query="What are Alice's strengths for the team lead role?",
budget="high", # More thorough reasoning
include_facts=True,
)

# See which facts influenced the response
for fact in (response.based_on.memories if response.based_on else []):
print(f"- {fact.text}")

What happens: Memories are recalled, bank disposition is loaded, LLM reasons through evidence, new opinions are formed and stored.

See: Reflect Details for disposition configuration.


Comparison

FeatureRetainRecallReflect
PurposeStore informationFind informationReason about information
InputRaw text/documentsSearch queryQuestion/prompt
OutputMemory IDsRanked factsReasoned response + opinions
Uses LLMYes (extraction)NoYes (generation)
Forms opinionsNoNoYes
DispositionNoNoYes

Next Steps

  • Retain — Advanced options for storing memories
  • Recall — Tuning search quality and performance
  • Reflect — Configuring disposition and opinions
  • Memory Banks — Managing memory bank disposition