Configuration
Required Environment Variables
Vector Storage Configuration
Reflection memory uses the same vector storage backends as knowledge memory but requires a separate collection:Qdrant Configuration
Milvus Configuration
Development Configuration
Agent Configuration
For reflection memory to work optimally, you should configure an evaluation LLM in yourcipher.yml
file:
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
Input Parameters
Input Parameters
Output Structure
Output Structure
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
Input Parameters
Input Parameters
Output Structure
Output Structure
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
Input Parameters
Input Parameters
Output Structure
Output Structure
Storage Payload
Storage Payload
Reflection memories are stored with comprehensive metadata:
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
Input Parameters
Input Parameters
Output Structure
Output Structure
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
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
Basic Reasoning Extraction
Basic Reasoning Extraction
Quality Evaluation Example
Quality Evaluation Example
Pattern Search Example
Pattern Search Example
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
anddomain
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