* fix: misc fixes for observations and mental models * feat: improve graph retrieval for observations - Update LinkExpansionRetriever to traverse through source_memory_ids for observation entity connections (avoiding data duplication) - Remove entity link copy from world facts to observations in consolidator - Add tests for link expansion graph retrieval - Add directives_applied field to ReflectResult - Include user's other changes (CLI, docs, client updates) * fix: CI test failures - Add mental_model_id parameter to create_mental_model function - Fix ToolCallTrace not including reason field from ToolCall - Improve test_link_expansion_observation_graph_retrieval to wait for consolidation with retry * chore: reduce link expansion log verbosity * Revert "chore: reduce link expansion log verbosity" This reverts commit 3ce759391cead1012157785fa78fef16ef9bfe3b. * feat: add semantic/temporal/entity links as fallback in graph retrieval - Add fallback query for semantic, temporal, and entity links from memory_links - Check both directions (outgoing and incoming links) - Weight fallback results at 0.5x to prioritize entity links via unit_entities - Fixes graph retrieval returning 0 when data has cross-cluster temporal connections * fix: enable observations fixture for link expansion test - Add enable_observations fixture to ensure observations are created - Increase wait time from 10 to 30 seconds for CI reliability
161 lines
5.5 KiB
Text
161 lines
5.5 KiB
Text
---
|
|
sidebar_position: 6
|
|
---
|
|
|
|
# Memory Banks
|
|
|
|
Memory banks are isolated containers that store all memory-related data for a specific context or use case.
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
import CodeSnippet from '@site/src/components/CodeSnippet';
|
|
|
|
{/* Import raw source files */}
|
|
import memoryBanksPy from '!!raw-loader!@site/examples/api/memory-banks.py';
|
|
import memoryBanksMjs from '!!raw-loader!@site/examples/api/memory-banks.mjs';
|
|
import directivesPy from '!!raw-loader!@site/examples/api/directives.py';
|
|
import directivesMjs from '!!raw-loader!@site/examples/api/directives.mjs';
|
|
|
|
## What is a Memory Bank?
|
|
|
|
A memory bank is a complete, isolated storage unit containing:
|
|
|
|
- **Memories** — Facts and information retained from conversations
|
|
- **Documents** — Files and content indexed for retrieval
|
|
- **Entities** — People, places, concepts extracted from memories
|
|
- **Relationships** — Connections between entities in the knowledge graph
|
|
- **Directives** — Hard rules the agent must follow during reflect operations
|
|
|
|
Banks are completely isolated from each other — memories stored in one bank are not visible to another.
|
|
|
|
You don't need to pre-create a bank. Hindsight will automatically create it with default settings when you first use it.
|
|
|
|
:::tip Prerequisites
|
|
Make sure you've completed the [Quick Start](./quickstart) to install the client and start the server.
|
|
:::
|
|
|
|
## Creating a Memory Bank
|
|
|
|
<Tabs>
|
|
<TabItem value="python" label="Python">
|
|
<CodeSnippet code={memoryBanksPy} section="create-bank" language="python" />
|
|
</TabItem>
|
|
<TabItem value="node" label="Node.js">
|
|
<CodeSnippet code={memoryBanksMjs} section="create-bank" language="javascript" />
|
|
</TabItem>
|
|
<TabItem value="cli" label="CLI">
|
|
|
|
```bash
|
|
# Set mission
|
|
hindsight bank mission my-bank "I am a research assistant specializing in ML"
|
|
|
|
# Set disposition
|
|
hindsight bank disposition my-bank \
|
|
--skepticism 4 \
|
|
--literalism 3 \
|
|
--empathy 3
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
## Mission and Disposition
|
|
|
|
Mission and disposition are optional settings that influence how the bank reasons during [reflect](./reflect) operations.
|
|
|
|
:::info
|
|
Mission and disposition only affect the `reflect` operation. They do not impact `retain`, `recall`, or other memory operations.
|
|
:::
|
|
|
|
### Mission
|
|
|
|
The mission is a first-person narrative providing context for reasoning:
|
|
|
|
<Tabs>
|
|
<TabItem value="python" label="Python">
|
|
<CodeSnippet code={memoryBanksPy} section="bank-mission" language="python" />
|
|
</TabItem>
|
|
<TabItem value="node" label="Node.js">
|
|
<CodeSnippet code={memoryBanksMjs} section="bank-mission" language="javascript" />
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
### Disposition Traits
|
|
|
|
Disposition traits influence how reasoning is performed during reflection. Each trait is scored 1 to 5:
|
|
|
|
| Trait | Low (1) | High (5) |
|
|
|-------|---------|----------|
|
|
| **Skepticism** | Trusting, accepts information at face value | Skeptical, questions and doubts claims |
|
|
| **Literalism** | Flexible interpretation, reads between the lines | Literal interpretation, takes things exactly as stated |
|
|
| **Empathy** | Detached, focuses on facts and logic | Empathetic, considers emotional context |
|
|
|
|
## Directives
|
|
|
|
Directives are hard rules that the agent must follow during [reflect](./reflect) operations. Unlike disposition traits which influence *how* the agent reasons, directives are explicit instructions that are *always* enforced.
|
|
|
|
:::info
|
|
Directives only affect the `reflect` operation. They are injected into prompts and the agent is required to comply with them in all responses.
|
|
:::
|
|
|
|
### When to Use Directives
|
|
|
|
Use directives for rules that must never be violated:
|
|
|
|
- **Language/style constraints**: "Always respond in formal English"
|
|
- **Privacy rules**: "Never share personal data with third parties"
|
|
- **Domain constraints**: "Prefer conservative investment recommendations"
|
|
- **Behavioral guardrails**: "Always cite sources when making claims"
|
|
|
|
### Creating Directives
|
|
|
|
<Tabs>
|
|
<TabItem value="python" label="Python">
|
|
<CodeSnippet code={directivesPy} section="create-directive" language="python" />
|
|
</TabItem>
|
|
<TabItem value="node" label="Node.js">
|
|
<CodeSnippet code={directivesMjs} section="create-directive" language="javascript" />
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
### Listing Directives
|
|
|
|
<Tabs>
|
|
<TabItem value="python" label="Python">
|
|
<CodeSnippet code={directivesPy} section="list-directives" language="python" />
|
|
</TabItem>
|
|
<TabItem value="node" label="Node.js">
|
|
<CodeSnippet code={directivesMjs} section="list-directives" language="javascript" />
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
### Updating Directives
|
|
|
|
<Tabs>
|
|
<TabItem value="python" label="Python">
|
|
<CodeSnippet code={directivesPy} section="update-directive" language="python" />
|
|
</TabItem>
|
|
<TabItem value="node" label="Node.js">
|
|
<CodeSnippet code={directivesMjs} section="update-directive" language="javascript" />
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
### Deleting Directives
|
|
|
|
<Tabs>
|
|
<TabItem value="python" label="Python">
|
|
<CodeSnippet code={directivesPy} section="delete-directive" language="python" />
|
|
</TabItem>
|
|
<TabItem value="node" label="Node.js">
|
|
<CodeSnippet code={directivesMjs} section="delete-directive" language="javascript" />
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
### Directives vs Disposition
|
|
|
|
| Aspect | Directives | Disposition |
|
|
|--------|------------|-------------|
|
|
| **Nature** | Hard rules, must be followed | Soft influence on reasoning style |
|
|
| **Enforcement** | Strict — responses are rejected if violated | Flexible — shapes interpretation |
|
|
| **Use case** | Compliance, guardrails, constraints | Personality, character, tone |
|
|
| **Example** | "Never recommend specific stocks" | High skepticism: questions claims |
|