Skip to main content

Memory Usage

Problem: Backend processes consuming excessive RAM (>4GB).Solution:
  1. Monitor memory usage:
  2. Enable context summarization:
  3. Reduce memory injection:
  4. Limit concurrent subagents:
  5. Configure thread pool sizes:
  6. Use lightweight models for non-critical tasks:
Problem: Memory usage grows continuously over multiple conversations.Solution:
  1. Clear conversation history periodically:
  2. Enable aggressive summarization:
  3. Clean up old threads:
  4. Restart services periodically:
  5. Monitor and set memory limits (Docker):
Problem: OOMKilled or memory errors in sandbox containers.Solution:
  1. Increase Docker memory limit:
  2. Configure container resource limits:
  3. For Kubernetes provisioner mode:
  4. Clean up sandbox artifacts:
  5. Limit file sizes in sandbox:

Context Window Optimization

Problem: Context length exceeded or Maximum token limit errors.Solution:
  1. Enable summarization (most important):
  2. Use models with larger context windows:
  3. Reduce memory injection tokens:
  4. Limit skill injection:
  5. Optimize tool descriptions:
  6. Use subagents for isolated context:
Problem: Model takes >30 seconds to respond as conversation grows.Solution:
  1. Aggressive summarization:
  2. Start new thread for new topics:
  3. Offload data to files:
  4. Disable thinking mode for simple queries:

Sandbox Performance

Problem: Sandbox container takes >10 seconds to start.Solution:
  1. Pre-pull sandbox image (most important):
  2. Use Apple Container on macOS (faster than Docker):
  3. Keep existing sandbox instead of recreating:
  4. Optimize Docker storage driver:
  5. Use local sandbox for development:
Problem: Reading/writing files in sandbox is sluggish.Solution:
  1. Check mount type (macOS):
  2. Reduce file I/O:
  3. Use smaller files:
  4. For Kubernetes provisioner - use local paths:
  5. Optimize Docker Desktop settings (macOS):
Problem: Shell commands take longer than expected in sandbox.Solution:
  1. Increase container CPU allocation:
  2. Use local sandbox for CPU-intensive tasks:
  3. Optimize commands:
  4. Use bash agent for complex command sequences:

Scaling Considerations

Problem: Performance degrades with multiple simultaneous conversations.Solution:
  1. Use provisioner mode with Kubernetes:
  2. Configure resource limits per thread:
  3. Implement request queuing (advanced):
  4. Use multiple model providers:
  5. Horizontal scaling (advanced):
Problem: Slow memory updates or thread data access.Solution:
  1. Increase memory debounce time:
  2. Use SSD for thread storage:
  3. Clean up old threads regularly:
  4. Limit fact storage:
  5. Use external database (advanced):
Problem: Slow responses due to network issues.Solution:
  1. Use geographically closer endpoints:
  2. Increase timeout for slow connections:
  3. Use local models (Ollama, LM Studio):
  4. Implement caching (advanced):
  5. Monitor provider status:

Performance Monitoring

Solution:
  1. Enable detailed logging:
  2. Monitor resource usage:
  3. Track API response times:
  4. Profile Python code (advanced):
  5. Use LangSmith for LLM tracing (advanced):
  6. Benchmark specific operations:

Next Steps