Features: - Multi-platform bot (Slack, Telegram) - Memory system with SQLite FTS - Tool use capabilities (file ops, commands) - Scheduled tasks system - Dynamic model switching (/sonnet, /haiku) - Prompt caching for cost optimization Optimizations: - Default to Haiku 4.5 (12x cheaper) - Reduced context: 3 messages, 2 memory results - Optimized SOUL.md (48% smaller) - Automatic caching when using Sonnet (90% savings) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1.6 KiB
1.6 KiB
Quick Start
Setup (30 seconds)
pip install anthropic requests watchdog
export ANTHROPIC_API_KEY="sk-ant-..." # Your Claude API key
export GLM_API_KEY="..." # Optional: z.ai GLM key
Usage
Basic Agent
from agent import Agent
# Initialize with Claude
agent = Agent(provider="claude")
# Chat (auto-loads SOUL + user context + relevant memory)
response = agent.chat("What should I work on?", username="alice")
# Switch to GLM
agent.switch_model("glm")
response = agent.chat("Explain SQLite FTS5")
Memory Operations
# Update personality
agent.memory.update_soul("## New trait\n- Be concise", append=True)
# User preferences
agent.memory.update_user("alice", "## Preference\n- Likes Python")
# Write memory
agent.memory.write_memory("Completed task X", daily=True)
# Search
results = agent.memory.search("python")
Task Tracking
# Add task
task_id = agent.memory.add_task(
"Implement API endpoint",
"Details: REST API for user auth"
)
# Update
agent.memory.update_task(task_id, status="in_progress")
# Get tasks
pending = agent.memory.get_tasks(status="pending")
all_tasks = agent.memory.get_tasks()
Files Created
llm_interface.py- Claude/GLM integrationagent.py- Main agent classmemory_workspace/MEMORY.md- Instructions for future sessions- Task system added to memory_system.py
Context Retrieval
Agent automatically loads:
- SOUL.md (personality)
- users/{username}.md (user prefs)
- Search results (top 3 relevant chunks)
- Recent conversation (last 5 messages)
All indexed in SQLite for fast retrieval.