-
Notifications
You must be signed in to change notification settings - Fork 16
Agent Skill Troubleshooting Guide
This guide covers common issues and their solutions when using Agent Brain for document indexing and search.
Symptoms:
-
agent-brain-servecommand fails to start - Error messages about missing modules or imports
- Port already in use errors
Solutions:
Module Import Errors:
# Reinstall global CLI tools
pip install agent-brain-rag agent-brain-cli
# Or run locally
cd agent-brain-server && poetry run agent-brain-servePort Already in Use:
# Find what's using port 8000
lsof -i :8000
# Kill the process
kill -9 <PID>
# Or use different port
agent-brain-serve --port 8001Permission Errors:
# Check if you can write to the directory
ls -la agent-brain-server/
chmod 755 agent-brain-server/Symptoms:
- Hybrid/vector queries fail with authentication errors
- Error: "No API key found for OpenAI"
- BM25 works but hybrid/vector don't
Solutions:
Set API Key in .env file:
cd agent-brain-server
echo "OPENAI_API_KEY=sk-your-key-here" > .env
echo "ANTHROPIC_API_KEY=sk-ant-your-key-here" >> .envSet as Environment Variables:
export OPENAI_API_KEY="sk-your-key-here"
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
agent-brain-serveGet API Keys:
- OpenAI: https://platform.openai.com/account/api-keys
- Anthropic: https://console.anthropic.com/
Verify Key Format:
# Should start with sk-proj or sk-
echo $OPENAI_API_KEY | head -c 15Symptoms:
- Some summarization features fail
- Warnings about missing Anthropic key
- Core search still works
Solutions:
Add to .env file:
cd agent-brain-server
echo "ANTHROPIC_API_KEY=sk-ant-your-key-here" >> .envGet API Key:
- Anthropic: https://console.anthropic.com/
Note: Anthropic key is optional for basic search functionality.
Symptoms:
-
agent-brain statusshows 0 documents - All queries return empty results
- Indexing seems to complete but no data
Solutions:
Check if indexing ran:
agent-brain status
# Should show: Total Documents: > 0Run indexing:
agent-brain index /path/to/your/docs
# Wait for completion messageVerify document path:
ls -la /path/to/your/docs
# Should contain .md, .txt, .pdf filesCheck supported formats:
- ✅ Markdown (.md)
- ✅ Text (.txt)
- ✅ PDF (.pdf)
- ❌ Word docs, images (not supported)
Symptoms:
- BM25 queries fail with "BM25 index not initialized"
- Hybrid queries fail but vector works
- Status shows BM25 index missing
Solutions:
Wait for indexing to complete:
agent-brain status
# Wait until indexing shows "Idle"Re-index if needed:
agent-brain reset --yes
agent-brain index /path/to/docsCheck server logs:
# Look for BM25 indexing messages
tail -f server.logSymptoms:
- Queries return empty results array
- Server is running and documents are indexed
Solutions:
Lower threshold:
# Default is 0.7, try lower values
agent-brain query "your search" --threshold 0.3Check query spelling:
# Try variations of your query
agent-brain query "alternative wording"Use different search modes:
# Try BM25 for exact matches
agent-brain query "exact term" --mode bm25 --threshold 0.1
# Try vector for semantic search
agent-brain query "conceptual description" --mode vector --threshold 0.5Verify content exists:
# Search for common words
agent-brain query "the" --mode bm25 --threshold 0.01Symptoms:
- Queries take longer than expected
- Hybrid/vector queries are slow (>2 seconds)
Solutions:
Use BM25 for speed:
# Fastest option, no API calls
agent-brain query "exact terms" --mode bm25Optimize hybrid settings:
# Reduce top-k for faster results
agent-brain query "search" --top-k 3 --alpha 0.5Check network connectivity:
# Test OpenAI API connectivity
curl -H "Authorization: Bearer $OPENAI_API_KEY" https://api.openai.com/v1/modelsMonitor server resources:
# Check if server is overloaded
top -p $(pgrep -f "agent-brain")Symptoms:
-
agent-braincommands fail with connection errors - "Unable to connect to server" messages
Solutions:
Start the server (multi-instance mode):
agent-brain start --daemon # Uses auto-port allocation
agent-brain status # Shows the actual portCheck server status:
agent-brain status
# Should show server is healthy with port numberVerify port from runtime.json:
# Check what port was assigned
cat .claude/doc-serve/runtime.json | jq '.port'List all running instances:
agent-brain list
# Shows all projects with their portsUse correct URL:
# Override URL if needed
export DOC_SERVE_URL="http://localhost:54321"
agent-brain statusSymptoms:
-
runtime.jsonexists but server is not responding - "Server not responding" warnings
- Previous server crashed without cleanup
Solutions:
Let the CLI handle it:
# CLI automatically detects stale state and starts fresh
agent-brain start --daemonManual cleanup:
# Remove stale state files
rm .claude/doc-serve/runtime.json
rm .claude/doc-serve/lock.json
rm .claude/doc-serve/pid
# Start fresh
agent-brain start --daemonSymptoms:
- "Another instance is already running" error
- Lock acquisition failures
Solutions:
The lock file protocol prevents double-start automatically:
# First agent wins and starts the server
# Second agent should detect the running instance
agent-brain status
# If lock is stale (process died), cleanup happens automatically
agent-brain start --daemonIf locks persist incorrectly:
# Manual lock cleanup (only if process is truly dead)
ps aux | grep agent-brain # Verify no process running
rm .claude/doc-serve/lock.json
agent-brain start --daemonSymptoms:
- Authentication failed messages
- 401 Unauthorized responses
- Works with BM25 but fails with hybrid/vector
Solutions:
Check API key validity:
# Test OpenAI key
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json"Verify key format:
# Should be sk-proj-... or sk-...
echo $OPENAI_API_KEY | grep -E "^sk-(proj-)?[a-zA-Z0-9]"Check account credits:
- OpenAI: https://platform.openai.com/account/usage
- Ensure account has credits and API access
Regenerate key if needed:
- OpenAI: https://platform.openai.com/account/api-keys
- Delete old key, create new one
Symptoms:
- Server crashes with out of memory errors
- Queries fail with resource exhaustion
- System becomes unresponsive
Solutions:
Reduce batch sizes:
# Smaller embedding batches
export EMBEDDING_BATCH_SIZE=50Limit concurrent requests:
# Use single-threaded mode if needed
export WEB_CONCURRENCY=1Monitor resource usage:
# Check memory usage
ps aux | grep agent-brain
top -p $(pgrep -f "agent-brain")Restart with clean state:
agent-brain reset --yes
agent-brain index /path/to/docsSymptoms:
-
--jsonoutput is malformed - Parsing errors in scripts
- Unexpected response format
Solutions:
Check API response:
curl -s http://localhost:8000/health | python -m json.toolValidate JSON output:
agent-brain query "test" --json | jq .Update CLI version:
pip install agent-brain-rag agent-brain-cliSymptoms:
- Cannot read documents during indexing
- Cannot write index files
- Permission denied errors
Solutions:
Check file permissions:
ls -la /path/to/docs
chmod 644 /path/to/docs/*.mdCheck index directory permissions:
ls -la agent-brain-server/
chmod 755 agent-brain-server/
mkdir -p agent-brain-server/chroma_db
chmod 755 agent-brain-server/chroma_dbRun as appropriate user:
# Don't run as root unless necessary
whoami# Server health
agent-brain status
# Check API connectivity
curl http://localhost:8000/health
# Test basic query
agent-brain query "test" --mode bm25# API keys set
echo "OpenAI: ${OPENAI_API_KEY:+SET}"
echo "Anthropic: ${ANTHROPIC_API_KEY:+SET}"
# Python environment
which python
python --version
# Poetry environment
cd agent-brain-server && poetry env info# Server logs
tail -f server.log
# System logs
dmesg | tail -20
# Network connectivity
ping -c 3 api.openai.comIf these solutions don't resolve your issue:
- Check GitHub Issues: https://github.com/SpillwaveSolutions/agent-brain/issues
- Provide diagnostic info: Run the diagnostic commands above
- Include error messages: Copy full error output
- Describe your setup: OS, Python version, installation method
- Always run
task pr-qa-gatebefore committing changes - Keep API keys secure and don't commit them
- Use environment variables for sensitive configuration
- Regularly update dependencies with
poetry update - Monitor server logs for early warning signs
- Test with different search modes when queries fail
- Design-Architecture-Overview
- Design-Query-Architecture
- Design-Storage-Architecture
- Design-Class-Diagrams
- GraphRAG-Guide
- Agent-Skill-Hybrid-Search-Guide
- Agent-Skill-Graph-Search-Guide
- Agent-Skill-Vector-Search-Guide
- Agent-Skill-BM25-Search-Guide
Search
Server
Setup
- Pluggable-Providers-Spec
- GraphRAG-Integration-Spec
- Agent-Brain-Plugin-Spec
- Multi-Instance-Architecture-Spec