Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ updates:
- "/examples/deep_research"
- "/examples/nvidia_deep_agent"
- "/examples/text-to-sql-agent"
- "/examples/memory-backend-agent"
schedule:
interval: "monthly"
groups:
Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
| [deep_research](deep_research/) | Multi-step web research agent using Tavily for URL discovery, parallel sub-agents, and strategic reflection |
| [content-builder-agent](content-builder-agent/) | Content writing agent that demonstrates memory (`AGENTS.md`), skills, and subagents for blog posts, LinkedIn posts, and tweets with generated images |
| [text-to-sql-agent](text-to-sql-agent/) | Natural language to SQL agent with planning, skill-based workflows, and the Chinook demo database |
| [memory-backend-agent](memory-backend-agent/) | Minimal Deep Agent using MemoryBackend with path-keyed storage (PathMemoryStore); demo uses in-memory store, with notes for PowerMem |
| [ralph_mode](ralph_mode/) | Autonomous looping pattern that runs with fresh context each iteration, using the filesystem for persistence |
| [downloading_agents](downloading_agents/) | Shows how agents are just folders—download a zip, unzip, and run |

Expand Down
373 changes: 373 additions & 0 deletions examples/memory-backend-agent/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,373 @@
# =============================================================================
# Memory Backend Agent — unified config template
# =============================================================================
# Copy to .env and edit: cp .env.powermem.example .env
# Includes: Deep Agent model, PowerMem (DB / embedding / optional LLM) and options
# =============================================================================

# -----------------------------------------------------------------------------
# Deep Agent model (choose one; used by agent.py / agent_powermem.py)
# -----------------------------------------------------------------------------
# Option A: Qwen (OpenAI-compatible API, e.g. DashScope)
OPENAI_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1
OPENAI_API_KEY=your_dashscope_api_key_here
OPENAI_MODEL=qwen-plus

# Option B: Claude (use when OPENAI_API_BASE is commented out)
# ANTHROPIC_API_KEY=your_anthropic_api_key_here

# LangSmith tracing (optional)
# LANGCHAIN_TRACING_V2=true
# LANGSMITH_ENDPOINT=https://api.smith.langchain.com
# LANGCHAIN_API_KEY=your_langsmith_api_key_here
# LANGCHAIN_PROJECT=memory-backend-agent

# -----------------------------------------------------------------------------
# PowerMem (required for agent_powermem.py or persistent memory)
# -----------------------------------------------------------------------------
# For a complete list of timezones, see: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIMEZONE=Asia/Shanghai

# =============================================================================
# 1. Database Configuration (Required)
# =============================================================================
# Choose your database provider: sqlite, oceanbase, postgres
DATABASE_PROVIDER=sqlite

# -----------------------------------------------------------------------------
# SQLite Configuration (Default - Recommended for development)
# -----------------------------------------------------------------------------
SQLITE_PATH=./data/powermem_dev.db
SQLITE_ENABLE_WAL=true
SQLITE_TIMEOUT=30
SQLITE_COLLECTION=memories

# -----------------------------------------------------------------------------
# OceanBase Configuration
# -----------------------------------------------------------------------------
OCEANBASE_HOST=127.0.0.1
OCEANBASE_PORT=2881
OCEANBASE_USER=root@sys
OCEANBASE_PASSWORD=your_password
OCEANBASE_DATABASE=powermem
OCEANBASE_COLLECTION=memories

## Keep the default settings, as modifications are generally not needed.
OCEANBASE_INDEX_TYPE=IVF_FLAT
OCEANBASE_VECTOR_METRIC_TYPE=cosine
OCEANBASE_TEXT_FIELD=document
OCEANBASE_VECTOR_FIELD=embedding
OCEANBASE_EMBEDDING_MODEL_DIMS=1536
OCEANBASE_PRIMARY_FIELD=id
OCEANBASE_METADATA_FIELD=metadata
OCEANBASE_VIDX_NAME=memories_vidx

# -----------------------------------------------------------------------------
# PostgreSQL Configuration
# -----------------------------------------------------------------------------
POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password
POSTGRES_DATABASE=powermem
POSTGRES_COLLECTION=memories

## Keep the default settings, as modifications are generally not needed.
POSTGRES_EMBEDDING_MODEL_DIMS=1536
POSTGRES_DISKANN=true
POSTGRES_HNSW=true
# DATABASE_SSLMODE=prefer
# DATABASE_POOL_SIZE=10
# DATABASE_MAX_OVERFLOW=20


# =============================================================================
# 2. LLM Configuration (Required)
# =============================================================================
# Choose your LLM provider: qwen, openai, siliconflow, ollama, vllm, anthropic, deepseek
LLM_PROVIDER=qwen

LLM_API_KEY=your_api_key_here
# Adjust the model according to your provider, gpt-4 advised to use when provider is openai
LLM_MODEL=qwen-plus

## Keep the default settings, as modifications are generally not needed.
LLM_TEMPERATURE=0.7
LLM_MAX_TOKENS=1000
LLM_TOP_P=0.8
LLM_TOP_K=50
# Only supported by qwen provider
LLM_ENABLE_SEARCH=false

# Default Base URLs for LLM providers, you can adjust if necessary
QWEN_LLM_BASE_URL=https://dashscope.aliyuncs.com/api/v1
OPENAI_LLM_BASE_URL=https://api.openai.com/v1
SILICONFLOW_LLM_BASE_URL=https://api.siliconflow.cn/v1
OLLAMA_LLM_BASE_URL=
VLLM_LLM_BASE_URL=
ANTHROPIC_LLM_BASE_URL=https://api.anthropic.com
DEEPSEEK_LLM_BASE_URL=https://api.deepseek.com

# =============================================================================
# 3. Embedding Configuration (Required)
# =============================================================================
# Choose your embedding provider: qwen, openai, siliconflow, huggingface, lmstudio, ollama
EMBEDDING_PROVIDER=qwen

EMBEDDING_API_KEY=your_api_key_here
# Adjust the model according to your provider, text-embedding-ada-002 advised to use when provider is openai
EMBEDDING_MODEL=text-embedding-v4
EMBEDDING_DIMS=1536

# Default Base URLs for embedding providers, you can adjust if necessary
QWEN_EMBEDDING_BASE_URL=https://dashscope.aliyuncs.com/api/v1
OPENAI_EMBEDDING_BASE_URL=https://api.openai.com/v1
SILICONFLOW_EMBEDDING_BASE_URL=https://api.siliconflow.cn/v1
HUGGINFACE_EMBEDDING_BASE_URL=
LMSTUDIO_EMBEDDING_BASE_URL=
OLLAMA_EMBEDDING_BASE_URL=

# =============================================================================
# 4. Rerank Configuration (Optional)
# =============================================================================
# Rerank configuration for reordering search results
RERANKER_ENABLED=false
RERANKER_PROVIDER=qwen
RERANKER_MODEL=qwen3-rerank
RERANKER_API_KEY=your_api_key_here
# RERANKER_API_BASE_URL=

# Provider-specific configurations
# For Qwen: Uses DASHSCOPE_API_KEY and DASHSCOPE_BASE_URL if RERANKER_* not set
# For Jina: Uses JINA_API_KEY and JINA_API_BASE_URL if RERANKER_* not set
# For Zhipu AI: Uses ZAI_API_KEY and ZAI_API_BASE_URL if RERANKER_* not set

# =============================================================================
# 5. Agent Configuration (Optional)
# =============================================================================
# Agent memory management settings
AGENT_ENABLED=true
AGENT_DEFAULT_SCOPE=AGENT
AGENT_DEFAULT_PRIVACY_LEVEL=PRIVATE
AGENT_DEFAULT_COLLABORATION_LEVEL=READ_ONLY
AGENT_DEFAULT_ACCESS_PERMISSION=OWNER_ONLY

# Agent Memory Mode (auto, multi_agent, multi_user, hybrid)
AGENT_MEMORY_MODE=auto


# =============================================================================
# 6. Intelligent Memory Configuration (Optional)
# =============================================================================
# Ebbinghaus forgetting curve settings
INTELLIGENT_MEMORY_ENABLED=true
INTELLIGENT_MEMORY_INITIAL_RETENTION=1.0
INTELLIGENT_MEMORY_DECAY_RATE=0.1
INTELLIGENT_MEMORY_REINFORCEMENT_FACTOR=0.3
INTELLIGENT_MEMORY_WORKING_THRESHOLD=0.3
INTELLIGENT_MEMORY_SHORT_TERM_THRESHOLD=0.6
INTELLIGENT_MEMORY_LONG_TERM_THRESHOLD=0.8

# Memory decay calculation settings
MEMORY_DECAY_ENABLED=true
MEMORY_DECAY_ALGORITHM=ebbinghaus
MEMORY_DECAY_BASE_RETENTION=1.0
MEMORY_DECAY_FORGETTING_RATE=0.1
MEMORY_DECAY_REINFORCEMENT_FACTOR=0.3

INTELLIGENT_MEMORY_FALLBACK_TO_SIMPLE_ADD=false


# =============================================================================
# 7. Performance Configuration (Optional)
# =============================================================================
# Memory management settings
MEMORY_BATCH_SIZE=100
MEMORY_CACHE_SIZE=1000
MEMORY_CACHE_TTL=3600
MEMORY_SEARCH_LIMIT=10
MEMORY_SEARCH_THRESHOLD=0.7

# Vector store settings
VECTOR_STORE_BATCH_SIZE=50
VECTOR_STORE_CACHE_SIZE=500
VECTOR_STORE_INDEX_REBUILD_INTERVAL=86400


# =============================================================================
# 8. Security Configuration (Optional)
# =============================================================================
# Encryption settings
ENCRYPTION_ENABLED=false
ENCRYPTION_KEY=
ENCRYPTION_ALGORITHM=AES-256-GCM

# Access control settings
ACCESS_CONTROL_ENABLED=true
ACCESS_CONTROL_DEFAULT_PERMISSION=READ_ONLY
ACCESS_CONTROL_ADMIN_USERS=admin,root


# =============================================================================
# 9. Telemetry Configuration (Optional)
# =============================================================================
# Usage analytics and monitoring
TELEMETRY_ENABLED=false
TELEMETRY_ENDPOINT=https://telemetry.powermem.ai
TELEMETRY_API_KEY=
TELEMETRY_BATCH_SIZE=100
TELEMETRY_FLUSH_INTERVAL=30
TELEMETRY_RETENTION_DAYS=30


# =============================================================================
# 10. Audit Configuration (Optional)
# =============================================================================
# Audit logging settings
AUDIT_ENABLED=true
AUDIT_LOG_FILE=./logs/audit.log
AUDIT_LOG_LEVEL=INFO
AUDIT_RETENTION_DAYS=90
AUDIT_COMPRESS_LOGS=true
AUDIT_LOG_ROTATION_SIZE=100MB


# =============================================================================
# 11. Logging Configuration (Optional)
# =============================================================================
# General logging settings
LOGGING_LEVEL=DEBUG
LOGGING_FORMAT=%(asctime)s - %(name)s - %(levelname)s - %(message)s
LOGGING_FILE=./logs/powermem.log
LOGGING_MAX_SIZE=100MB
LOGGING_BACKUP_COUNT=5
LOGGING_COMPRESS_BACKUPS=true

# Console logging
LOGGING_CONSOLE_ENABLED=true
LOGGING_CONSOLE_LEVEL=INFO
LOGGING_CONSOLE_FORMAT=%(levelname)s - %(message)s


# =============================================================================
# 12. Graph Store Configuration (Optional)
# =============================================================================
# Graph store for knowledge graph storage and retrieval
# Enable graph store functionality
GRAPH_STORE_ENABLED=false

# Graph store provider (currently supports: oceanbase)
GRAPH_STORE_PROVIDER=oceanbase

# OceanBase Graph Configuration
GRAPH_STORE_HOST=127.0.0.1
GRAPH_STORE_PORT=2881
GRAPH_STORE_USER=root@sys
GRAPH_STORE_PASSWORD=your_password
GRAPH_STORE_DB_NAME=powermem

# Optional: Graph traversal settings
GRAPH_STORE_MAX_HOPS=3

# Optional: Graph store vector and index settings
# GRAPH_STORE_VECTOR_METRIC_TYPE=l2
# GRAPH_STORE_INDEX_TYPE=HNSW

# Optional: Custom prompts for graph operations
# GRAPH_STORE_CUSTOM_PROMPT=
# GRAPH_STORE_CUSTOM_EXTRACT_RELATIONS_PROMPT=
# GRAPH_STORE_CUSTOM_UPDATE_GRAPH_PROMPT=
# GRAPH_STORE_CUSTOM_DELETE_RELATIONS_PROMPT=

# =============================================================================
# 13. Sparse Embedding Configuration (Optional)
# =============================================================================
# Choose your sparse embedding provider: qwen, openai
SPARSE_VECTOR_ENABLE=false
SPARSE_EMBEDDER_PROVIDER=qwen

SPARSE_EMBEDDER_API_KEY=your_api_key_here
SPARSE_EMBEDDER_MODEL=text-embedding-v4
SPARSE_EMBEDDING_BASE_URL=https://dashscope.aliyuncs.com/api/v1

# =============================================================================
# 14. Query Rewrite Configuration (Optional)
# =============================================================================
# Custom query rewritten prompt & he model used, keeping it from the same manufacturer as llm

QUERY_REWRITE_ENABLED=false
# QUERY_REWRITE_PROMPT=
# QUERY_REWRITE_MODEL_OVERRIDE=

# =============================================================================
# 15. PowerMem HTTP API Server Configuration
# =============================================================================
# Configuration for the PowerMem HTTP API Server
# =============================================================================

# -----------------------------------------------------------------------------
# Server Settings
# -----------------------------------------------------------------------------
# Server host address (0.0.0.0 to listen on all interfaces)
POWERMEM_SERVER_HOST=0.0.0.0

# Server port number
POWERMEM_SERVER_PORT=8000

# Number of worker processes (only used when reload=false)
POWERMEM_SERVER_WORKERS=4

# Enable auto-reload for development (true/false)
POWERMEM_SERVER_RELOAD=false

# -----------------------------------------------------------------------------
# Authentication Settings
# -----------------------------------------------------------------------------
# Enable API key authentication (true/false)
POWERMEM_SERVER_AUTH_ENABLED=false

# API keys (comma-separated list)
# Example: POWERMEM_SERVER_API_KEYS=key1,key2,key3
POWERMEM_SERVER_API_KEYS=

# -----------------------------------------------------------------------------
# Rate Limiting Settings
# -----------------------------------------------------------------------------
# Enable rate limiting (true/false)
POWERMEM_SERVER_RATE_LIMIT_ENABLED=true

# Rate limit per minute per IP address
POWERMEM_SERVER_RATE_LIMIT_PER_MINUTE=100

# -----------------------------------------------------------------------------
# Logging Settings
# -----------------------------------------------------------------------------
POWERMEM_SERVER_LOG_FILE=server.log

# Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
POWERMEM_SERVER_LOG_LEVEL=INFO

# Log format: json or text
POWERMEM_SERVER_LOG_FORMAT=text

# -----------------------------------------------------------------------------
# API Settings
# -----------------------------------------------------------------------------
# API title (shown in Swagger UI)
POWERMEM_SERVER_API_TITLE=PowerMem API

# API version
POWERMEM_SERVER_API_VERSION=v1

# API description (shown in Swagger UI)
POWERMEM_SERVER_API_DESCRIPTION=PowerMem HTTP API Server - Intelligent Memory System

# -----------------------------------------------------------------------------
# CORS Settings
# -----------------------------------------------------------------------------
# Enable CORS (true/false)
POWERMEM_SERVER_CORS_ENABLED=true

# CORS allowed origins (comma-separated, use * for all origins)
# Example: POWERMEM_SERVER_CORS_ORIGINS=http://localhost:3000,https://example.com
POWERMEM_SERVER_CORS_ORIGINS=*
Loading
Loading