Reflection memory is cipher’s advanced learning system that captures, evaluates, and stores reasoning patterns and decision-making processes. Unlike knowledge memory which stores factual information, reflection memory focuses on the “how” and “why” of reasoning, enabling continuous improvement of agent capabilities through pattern analysis and reuse.

Configuration

Required Environment Variables

# OpenAI API Key (Required for embeddings)
OPENAI_API_KEY=sk-proj-your-openai-key-here

# Vector Store Type (Required)
VECTOR_STORE_TYPE=qdrant  # qdrant, milvus, in-memory

# Reflection Memory Collection (Required for reflection memory)
REFLECTION_VECTOR_STORE_COLLECTION=reflection_memory

Vector Storage Configuration

Reflection memory uses the same vector storage backends as knowledge memory but requires a separate collection:

Qdrant Configuration

# Connection Options (choose one)
VECTOR_STORE_URL=http://localhost:6333           # Complete URL
# OR
VECTOR_STORE_HOST=localhost                      # Host + Port
VECTOR_STORE_PORT=6333

# Optional Settings
VECTOR_STORE_API_KEY=your-qdrant-api-key        # For Qdrant Cloud
VECTOR_STORE_DIMENSION=1536                     # Embedding dimensions
VECTOR_STORE_DISTANCE=Cosine                    # Distance metric
VECTOR_STORE_ON_DISK=false                      # Store vectors on disk

# Reflection Memory Specific
REFLECTION_VECTOR_STORE_COLLECTION=reflection_memory  # Separate collection
DISABLE_REFLECTION_MEMORY=false                        # Enable/disable reflection

Milvus Configuration

# Connection Options (choose one)
VECTOR_STORE_URL=http://localhost:19530          # Complete URL
# OR
VECTOR_STORE_HOST=localhost                      # Host + Port
VECTOR_STORE_PORT=19530

# Authentication (Zilliz Cloud)
VECTOR_STORE_USERNAME=your-username              # Optional
VECTOR_STORE_PASSWORD=your-password              # Optional
VECTOR_STORE_API_KEY=your-api-token             # Optional

# Collection Settings
VECTOR_STORE_DIMENSION=1536                     # Embedding dimensions
REFLECTION_VECTOR_STORE_COLLECTION=reflection_memory  # Separate collection

Development Configuration

# In-Memory (Development/Testing)
VECTOR_STORE_TYPE=in-memory
VECTOR_STORE_DIMENSION=1536
REFLECTION_VECTOR_STORE_COLLECTION=reflection_memory
VECTOR_STORE_MAX_VECTORS=10000                  # Memory limit

Agent Configuration

For reflection memory to work optimally, you should configure an evaluation LLM in your cipher.yml file:
# cipher.yml
llm:
  provider: anthropic
  model: claude-3-5-haiku-20241022
  apiKey: $ANTHROPIC_API_KEY

# Evaluation LLM for reasoning assessment (recommended)
evalLlm:
  provider: anthropic
  model: claude-3-5-sonnet-20241022
  apiKey: $ANTHROPIC_API_KEY
Note: If evalLlm is not specified, the evaluation tool will default to using the same model as llm. Using a separate evaluation model can provide more objective assessment of reasoning quality.

Reflection Memory Tools

Cipher provides four specialized tools for reflection memory management:

Extract Reasoning Steps Tool

cipher_extract_reasoning_steps This tool analyzes user input to identify and extract reasoning patterns, thought processes, and decision-making steps. It detects both explicit reasoning markup and implicit reasoning patterns from natural language. Important: This tool is only executed automatically when cipher detects reasoning content in user input. It does not run on every interaction - only when the system identifies that the input contains structured reasoning patterns or explicit reasoning markup. Key Features:
  • Automatic detection of reasoning content in conversations
  • Extraction of explicit markup (Thought:, Action:, Observation:)
  • Implicit reasoning pattern recognition from natural language
  • Task context extraction and categorization
  • Structured reasoning trace generation

Evaluate Reasoning Tool

cipher_evaluate_reasoning This tool assesses the quality, efficiency, and effectiveness of extracted reasoning traces. It provides quality scores, identifies issues, and determines whether the reasoning should be stored for future reference. Important: This tool is automatically triggered only after reasoning extraction when cipher has detected and extracted reasoning content. It does not evaluate non-reasoning interactions. Key Features:
  • Multi-dimensional quality assessment (quality, efficiency, clarity)
  • Issue identification and severity classification
  • Improvement suggestions generation
  • Storage recommendation decisions
  • Pattern analysis and completeness checking

Store Reasoning Memory Tool

cipher_store_reasoning_memory This tool stores high-quality reasoning traces with their evaluations in the reflection memory system. It operates in append-only mode and only stores reasoning that meets quality thresholds. Important: This tool is automatically executed only for high-quality reasoning that has been extracted and evaluated. It only runs when the evaluation determines the reasoning should be stored (when shouldStore: true). Key Features:
  • Append-only storage (no updates or deletions)
  • Quality threshold enforcement
  • Unified trace and evaluation storage
  • Rich metadata preservation
  • Automatic embedding generation for search

Search Reasoning Patterns Tool

cipher_search_reasoning_patterns This tool performs semantic search over stored reflection memory to find relevant reasoning patterns that can inform current decision-making processes. Key Features:
  • Semantic search over reasoning patterns
  • Context-aware filtering by task type and domain
  • Query deduplication to reduce redundant searches
  • Detailed similarity scoring and ranking
  • Pattern analysis and recommendations

Advanced Features

Intelligent Reasoning Detection

Reflection memory automatically detects reasoning content in conversations and only processes interactions that contain reasoning:
  • Explicit Markup: Recognizes structured reasoning with tags like “Thought:”, “Action:”, “Observation:”
  • Implicit Patterns: Identifies natural language reasoning patterns and decision-making processes
  • Context Extraction: Automatically infers task goals, complexity, and domain from conversation context
  • Quality Filtering: Only processes interactions that contain meaningful reasoning content
Key Behavior: When cipher receives outputs from reasoning models or human users that contain reasoning patterns, it automatically extracts and evaluates these reasoning traces for future usage. Non-reasoning and simple retrieval inputs are completely skipped - no reflection memory tools are executed for basic questions, factual queries, or simple requests that don’t involve step-by-step reasoning processes. This selective processing ensures that reflection memory focuses only on valuable reasoning patterns while avoiding noise from routine interactions.

Multi-Dimensional Quality Assessment

The evaluation system assesses reasoning across multiple dimensions:
  • Quality Score: Overall reasoning effectiveness and correctness
  • Efficiency: How streamlined and direct the reasoning process is
  • Clarity: How clear and understandable the reasoning steps are
  • Completeness: Whether the reasoning covers all necessary aspects

Automatic Storage Decisions

The system intelligently decides what reasoning to preserve:
  • Quality Thresholds: Only stores reasoning above configurable quality scores
  • Issue Analysis: Identifies common reasoning pitfalls and areas for improvement
  • Storage Recommendations: Uses evaluation results to determine storage worthiness
  • Append-Only: Never modifies stored reasoning, maintaining historical accuracy

Query Deduplication

Search functionality includes intelligent query optimization:
  • Similarity Detection: Identifies similar search queries within recent time windows
  • Result Caching: Avoids redundant searches for similar queries
  • Session Tracking: Maintains query history per session for better deduplication
  • Performance Optimization: Reduces unnecessary vector search operations

Examples

Best Practices

Configuration

  • Use separate collections - keep knowledge and reflection memory in different collections
  • Set quality thresholds - configure evaluation criteria based on your use case

Content Optimization

  • Use explicit reasoning markup - “Thought:”, “Action:”, “Observation:” for better extraction
  • Provide complete reasoning chains - include all steps from problem to solution
  • Include context information - specify task goals and problem domains clearly

Search Strategies

  • Query with specific context - “React async patterns” vs just “async patterns”
  • Use domain filters - specify taskType and domain for targeted results
  • Leverage pattern similarity - high-quality stored reasoning provides better search results

Memory Management

  • Monitor quality scores - reasoning below 0.6 may not provide value for reuse
  • Enable debug logging - set CIPHER_LOG_LEVEL=debug to see detailed reasoning analysis
  • Regular pattern analysis - review stored reasoning to identify improvement opportunities
Reflection memory transforms reasoning processes into a persistent, searchable knowledge base that enables continuous learning and reasoning improvement over time.