One of the key lessons from this project was the value of merging two separate approaches:
correlation-rules-memfocused on proper plugin lifecycle integrationcorrelation-memoryimplemented rich matching logic
By combining these approaches, we achieved both robust integration with OpenClaw and sophisticated matching capabilities. This taught us that sometimes the best solution emerges from synthesizing multiple partial solutions rather than trying to build everything from scratch.
Implementing confidence scoring for correlation rules was more complex than initially anticipated. We learned that:
- Simple threshold-based approaches often fail in practice
- Context matters significantly in determining appropriate confidence levels
- User feedback is crucial for tuning confidence scores
- Different domains may require different confidence models
The three matching modes (auto, strict, lenient) revealed important trade-offs:
- Strict mode provides predictable results but may miss relevant correlations
- Lenient mode captures more connections but increases false positives
- Auto mode requires careful tuning to balance precision and recall
Attempting to build all features simultaneously led to integration challenges. Breaking down the development into smaller, testable components proved more effective:
- Basic rule parsing and validation
- Simple matching logic
- Confidence scoring implementation
- Advanced matching modes
- Performance optimization
Early testing with synthetic data didn't reveal the complexities that emerged with real-world usage. Key insights came from:
- Testing with actual OpenClaw session data
- Observing how users phrase their queries
- Identifying common correlation patterns in practice
- Understanding the diversity of contexts in real usage
Memory search performance became a critical concern as the correlation system grew more sophisticated. Lessons learned:
- Caching frequently accessed rules improved performance significantly
- Lazy evaluation of correlation rules reduced unnecessary computation
- Parallel processing of independent correlations was beneficial
- Monitoring memory usage was essential for maintaining responsiveness
During development, we experienced failures with subagents responsible for correlation rule processing. Key lessons:
- Resource contention between multiple concurrent correlation searches
- Inadequate error handling in rule processing pipelines
- Timeout issues with complex rule evaluations
- Memory leaks in recursive correlation resolution
- Implemented resource quotas for correlation processing
- Added comprehensive error boundaries and fallback mechanisms
- Introduced timeouts with graceful degradation
- Fixed memory leak patterns through better resource management
- Enhanced monitoring of subagent health
- Improved logging for correlation processing failures
- Added circuit breaker patterns for problematic rules
- Implemented progressive backoff for failing correlations
Users appreciated the enhanced search results but wanted more transparency about why certain correlations were made. This led to:
- Adding debug tools to explain correlation decisions
- Providing visibility into matched rules
- Allowing users to adjust correlation sensitivity
- Enabling rule-level feedback mechanisms
Initially, the system was too aggressive in suggesting correlations, leading to:
- Information overload
- Reduced trust in suggestions
- Performance impacts
- Confusion about relevance
We learned to be more conservative in correlation suggestions and provide better controls for users to tune the system.
Establishing effective feedback mechanisms was crucial:
- Users needed ways to indicate when correlations were helpful or misleading
- Rule authors required data on rule effectiveness
- System administrators needed monitoring of overall performance
- Developers needed insights for future improvements
The correlation plugin reinforced several important architectural principles:
- Separation of concerns between rule definition and execution
- Clear interfaces between components
- Extensibility for future enhancements
- Backward compatibility considerations
Managing correlation rules as external configuration files proved beneficial:
- Enabled non-developers to contribute rules
- Allowed A/B testing of rule sets
- Facilitated version control of rule changes
- Supported different environments (dev/staging/prod)
Robust error handling was essential for a system that operates on user data:
- Graceful degradation when rules are malformed
- Isolation of failing rules from affecting others
- Clear error messages for debugging
- Recovery mechanisms for transient failures
While the current rule-based approach works well, we've identified opportunities for ML enhancement:
- Automatic discovery of correlation patterns
- Adaptive confidence scoring based on user feedback
- Personalization of correlations per user/context
- Anomaly detection for unusual correlation patterns
Ongoing performance work could focus on:
- More sophisticated caching strategies
- Distributed correlation processing
- Query optimization for complex rule sets
- Resource allocation improvements
Future improvements could include:
- Visual rule editing tools
- Correlation analytics dashboards
- Interactive correlation tuning
- Collaborative rule development workflows
The correlation plugin development was a valuable learning experience that highlighted the importance of iterative development, real-world testing, and user feedback. The challenges encountered with subagent failures, performance optimization, and user experience tuning provided crucial insights that will benefit future OpenClaw plugin development efforts.
The key takeaway is that complex AI-enhanced systems require careful attention to reliability, transparency, and user control. Balancing automation with user agency remains a central challenge in building effective AI assistants.
During memory system troubleshooting, we discovered a critical issue:
- Problem: node-llama-cpp v3.x is ESM-only, but OpenClaw gateway uses CommonJS require()
- Error:
ERR_REQUIRE_ASYNC_MODULE - Impact: Memory search disabled, semantic embeddings unavailable
Lessons:
- Always check module system compatibility (ESM vs CJS) when integrating Node.js packages
- File bugs early when dependencies have breaking changes
- Maintain fallback mechanisms (FTS) for critical functionality
Troubleshooting revealed configuration complexity:
- Multiple ways to configure API keys (env, credentials dir, auth.json, config)
- Provider initialization depends on environment availability at gateway startup
- Gateway restart is required for config changes to take effect
Lessons:
- Document configuration options clearly
- Provide diagnostic tools to verify provider initialization
- Use wrapper scripts for persistent environment variables
We solved the embedding problem using local (Ollama) instead of remote (Voyage):
- Installed Ollama with
nomic-embed-textmodel - Configured
provider: "ollama"in memorySearch - Result: Fully local semantic search, no API costs
Lessons:
- Local embeddings can be more reliable than remote APIs
- Ollama provides a good alternative when ESM packages fail
- Hybrid mode (semantic + FTS) provides redundancy
Our extensive correlation rules (20+ rules) proved valuable:
- Rules automatically enrich memory searches with context
- Lifecycle states (proposal → testing → validated → promoted → retired) help manage rule quality
- Usage tracking helps identify effective vs unused rules
Lessons:
- Invest in rule governance from the start
- Track rule effectiveness through usage counts
- Regular review cycles keep rules relevant
Added: 2026-03-18