Skip to content

Conversation

zhangfengcdt
Copy link
Owner

@zhangfengcdt zhangfengcdt commented Jul 27, 2025

This PR implements a comprehensive agent memory system for support LLM agents with different types of memory persistence backed by prolly tree data structures.

🚀 Key Features

Memory Types Implemented

  • Short-Term Memory: Session/conversation history with TTL expiration
  • Semantic Memory: Facts, relationships, and structured knowledge
  • Episodic Memory: Experience records and interaction history
  • Procedural Memory: Rules, procedures, and operational knowledge

Prolly Tree Integration

  • Storage Backend: ProllyTree<32, InMemoryNodeStorage<32>> for robust data storage
  • Thread Safety: Arc for concurrent async operations
  • Advanced Features: Tree statistics, range queries, commit tracking
  • Git-like Operations: Branch/checkout/merge simulation for future durability

Also, we converted the financial advisor application to use the Rig framework for LLM interactions while maintaining git-prolly as the storage layer for all objects.

Key Changes

  1. Dependencies (Cargo.toml)
  • Added rig-core = "0.2.1" dependency for LLM framework integration
  1. New Module (src/advisor/rig_agent.rs)
  • Created FinancialAnalysisAgent struct that uses Rig's OpenAI client
  • Implemented proper Rig agent builder pattern with system prompts
  • Added structured request/response types (AnalysisRequest, AnalysisResponse)
  • Provides automatic fallback to rule-based analysis when AI fails
  1. Refactored FinancialAdvisor (src/advisor/mod.rs)
  • Replaced direct HTTP client (reqwest::Client) with FinancialAnalysisAgent
  • Updated generate_ai_reasoning_with_debug to generate_rig_analysis_with_debug
  • Removed unused imports

The implementation has been completed successfully with prolly tree-based in-memory storage.
  Here's what's working:

  🧠 Core Memory Types Implemented:

  1. Short-term Memory: Conversation history, working memory, session context
  2. Semantic Memory: Facts, relationships, structured knowledge
  3. Episodic Memory: Experience records, interaction history
  4. Procedural Memory: Rules, procedures, operational knowledge

  🌳 Prolly Tree Integration:

  - Replaced HashMap with ProllyTree<32, InMemoryNodeStorage<32>>
  - Maintains same interface while providing proper tree-based storage
  - Thread-safe async operations with Arc<RwLock<>>
  - Advanced features: tree_stats(), range_query(), commit tracking
@zhangfengcdt zhangfengcdt changed the title Convert Financial Advisor to Rig Framework Implements a comprehensive agent memory system for support LLM agents Jul 27, 2025
@zhangfengcdt zhangfengcdt merged commit 052878f into main Jul 27, 2025
2 checks passed
@zhangfengcdt zhangfengcdt deleted the feature/finance.rig.integration branch July 29, 2025 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant