Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Cortex Memory RIG Integration
This crate provides integration between the cortex-mem memory system and the RIG AI agent framework. It offers tools that AI agents can use to store, search, and retrieve memories.
Overview
The cortex-mem-rig crate has been refactored to provide a consistent interface with cortex-mem-mcp. It now offers four distinct tools that mirror the MCP protocol tools:
store_memory- Store a new memoryquery_memory- Search memories using semantic similaritylist_memories- List memories with optional filteringget_memory- Retrieve a specific memory by ID
This design ensures that AI agents have a consistent experience whether they're using MCP or RIG to interface with the cortex-mem system.
Features
- Tool-based Interface: Four distinct tools with specific purposes
- Consistent with MCP: Same function signatures and parameters as cortex-mem-mcp
- Semantic Search: Advanced memory searching using vector embeddings
- Type-safe: Fully type-safe Rust interface with structured parameters
- Error Handling: Comprehensive error handling for all operations
- Backward Compatibility: Maintains compatibility with existing code through a wrapper
Quick Start
Add this to your Cargo.toml:
[]
= { = "0.1" }
= { = "0.1" }
= { = "0.1" }
= { = "0.1" }
= { = "1" }
= "0.1"
= "0.3"
Basic Usage
Set up the memory system
use Arc;
use Config;
use ;
use create_memory_tools;
async
Using the tools
use ;
// Store a memory
let store_args = StoreMemoryArgs ;
let result = memory_tools.store_memory.call.await?;
println!;
// Query memories
let query_args = QueryMemoryArgs ;
let result = memory_tools.query_memory.call.await?;
if let Some = result.data
// List memories
let list_args = ListMemoriesArgs ;
let result = memory_tools.list_memories.call.await?;
if let Some = result.data
// Get a specific memory
let get_args = GetMemoryArgs ;
let result = memory_tools.get_memory.call.await?;
if let Some = result.data
Configuration
You can customize the memory tools with a MemoryToolConfig:
use MemoryToolConfig;
let config = MemoryToolConfig ;
let memory_tools = create_memory_tools;
Integration with RIG Agent Framework
The tools are designed to work seamlessly with the RIG AI agent framework:
use Agent;
use openai;
// Create an agent with memory capabilities
let agent = builder
.model // Example model
.preamble
.tool
.tool
.tool
.tool
.build;
// The agent can now use these tools to interact with memories
API Reference
Store Memory
Stores a new memory in the system.
Parameters:
content(required, string): The content of the memoryuser_id(optional, string): User ID associated with the memoryagent_id(optional, string): Agent ID associated with the memorymemory_type(optional, string): Type of memory (conversational, procedural, factual, semantic, episodic, personal)topics(optional, array of strings): Topics to associate with the memory
Query Memory
Searches memories using semantic similarity.
Parameters:
query(required, string): Query string for semantic searchk(optional, integer): Maximum number of results to return (default: 10)memory_type(optional, string): Type of memory to filter bymin_salience(optional, number): Minimum salience/importance score threshold (0-1)topics(optional, array of strings): Topics to filter memories byuser_id(optional, string): User ID to filter memoriesagent_id(optional, string): Agent ID to filter memories
List Memories
Retrieves memories with optional filtering.
Parameters:
limit(optional, integer): Maximum number of memories to return (default: 100, max: 1000)memory_type(optional, string): Type of memory to filter byuser_id(optional, string): User ID to filter memoriesagent_id(optional, string): Agent ID to filter memories
Get Memory
Retrieves a specific memory by its exact ID.
Parameters:
memory_id(required, string): Exact ID of the memory to retrieve
Migration from Previous Versions
If you were using the old single-tool interface, you can still use the backward-compatible wrapper:
// Old way (deprecated)
use ;
let tool = create_memory_tool;
// New way (recommended)
use create_memory_tools;
let tools = create_memory_tools;
The old MemoryTool is still available but marked as deprecated. It now internally uses the new tool structure, so your existing code will continue to work, but you should migrate to the new interface for cleaner code and better type safety.
Examples
See the examples directory for complete working examples:
memory_tools_example.rs: Basic usage example with all tools
Architecture
The crate shares the core functionality with cortex-mem-mcp through the cortex-mem-tools crate:
cortex-mem-tools: Provides shared operations and tool definitionscortex-mem-rig: Implements RIG-specific tool interfacescortex-mem-mcp: Implements MCP-specific tool interfaces
Both rig and mcp use the same underlying operations, ensuring consistent behavior across different AI frameworks.
License
This project is licensed under the MIT License.