Skip to main content

Module context

Module context 

Source
Expand description

Context management module for agent memory and knowledge systems

This module provides the core infrastructure for managing agent contexts, including hierarchical memory systems, knowledge bases, and persistent context storage with session continuity.

§Architecture

The context system is built around several key components:

  • AgentContext: The main container for an agent’s memory and knowledge
  • HierarchicalMemory: Multi-layered memory system (short-term, long-term, working, episodic, semantic)
  • KnowledgeBase: Structured storage for facts, procedures, and learned patterns
  • ContextManager: Trait and implementation for context operations

§Usage

use symbi_runtime::context::{StandardContextManager, ContextManagerConfig};
use symbi_runtime::types::AgentId;

let config = ContextManagerConfig::default();
let context_manager = StandardContextManager::new(config, "my-agent").await?;
context_manager.initialize().await?;

let agent_id = AgentId::new();
let session_id = context_manager.create_session(agent_id).await?;

§Features

  • Hierarchical Memory: Multiple memory types with different retention policies
  • Knowledge Management: Structured storage and retrieval of facts, procedures, and patterns
  • Semantic Search: Vector-based similarity search across memory and knowledge
  • Session Management: Persistent context across agent sessions
  • Knowledge Sharing: Secure sharing of knowledge between agents
  • Retention Policies: Automatic archiving and cleanup of old context data
  • Access Control: Policy-driven access control for context operations

Re-exports§

pub use types::AccessLevel;
pub use types::AgentContext;
pub use types::ContextError;
pub use types::ContextId;
pub use types::ContextPersistence;
pub use types::ContextQuery;
pub use types::FilePersistenceConfig;
pub use types::HierarchicalMemory;
pub use types::Knowledge;
pub use types::KnowledgeBase;
pub use types::KnowledgeId;
pub use types::KnowledgeItem;
pub use types::KnowledgeSource;
pub use types::KnowledgeType;
pub use types::MemoryItem;
pub use types::MemoryType;
pub use types::QueryType;
pub use types::RetentionPolicy;
pub use types::SessionId;
pub use types::StorageStats;
pub use types::VectorBatchItem;
pub use types::VectorBatchOperation;
pub use types::VectorContentType;
pub use types::VectorId;
pub use types::VectorMetadata;
pub use types::VectorOperationType;
pub use types::VectorSearchResult;
pub use manager::ContextManager;
pub use manager::ContextManagerConfig;
pub use manager::FilePersistence;
pub use manager::StandardContextManager;
pub use markdown_memory::MarkdownMemoryStore;
pub use embedding::create_embedding_service;
pub use embedding::create_embedding_service_from_env;
pub use embedding::EmbeddingConfig;
pub use embedding::EmbeddingProvider;
pub use embedding::OllamaEmbeddingService;
pub use embedding::OpenAiEmbeddingService;
pub use vector_db::EmbeddingService;
pub use vector_db::MockEmbeddingService;
pub use vector_db::NoOpVectorDatabase;
pub use vector_db::QdrantConfig;
pub use vector_db::QdrantDistance;
pub use vector_db::TfIdfEmbeddingService;
pub use vector_db::VectorDatabase;
pub use vector_db::VectorDatabaseStats;
pub use compaction::CompactionConfig;
pub use compaction::CompactionResult;
pub use compaction::CompactionTier;
pub use token_counter::context_limit_for_model;
pub use token_counter::create_token_counter;
pub use token_counter::HeuristicTokenCounter;
pub use token_counter::TiktokenCounter;
pub use token_counter::TokenCounter;
pub use vector_db_factory::create_vector_backend;
pub use vector_db_factory::resolve_vector_config;
pub use vector_db_factory::VectorBackendConfig;
pub use vector_db_lance::LanceDbBackend;
pub use vector_db_lance::LanceDbConfig;
pub use vector_db_trait::DistanceMetric;
pub use vector_db_trait::VectorDb;

Modules§

compaction
Context compaction pipeline for reclaiming tokens.
embedding
Embedding service providers for generating vector embeddings
manager
Context Manager implementation for agent memory and knowledge management
markdown_memory
Markdown-backed agent memory persistence
token_counter
Multi-model token counting for context compaction.
types
Core data structures for the Context & Knowledge Systems
vector_db
Vector Database integration for Qdrant
vector_db_factory
Vector backend factory.
vector_db_lance
LanceDB embedded vector backend.
vector_db_trait
Backend-agnostic vector database trait.