Troubleshooting¶
Common Issues and Solutions
Quick fixes for common StrataRouter issues.
High Latency¶
Symptoms¶
- P99 latency > 50ms
- Slow response times
Diagnosis¶
# Enable profiling
result = executor.execute(query)
print(result.profile)
# Check metrics
GET /metrics
Solutions¶
-
Enable Caching
-
Reduce HNSW ef_search
-
Check Provider Latency
Low Cache Hit Rate¶
Symptoms¶
- Hit rate < 70%
- High LLM costs
Solutions¶
-
Lower Similarity Threshold
-
Increase Cache Size
-
Extend TTL
Routing Errors¶
Low Confidence Scores¶
Cause: Route descriptions too similar
Fix:
# Make routes more distinct
router.add_route(Route(
"billing_payments",
"Credit card payments, invoices, refunds, billing cycles"
))
router.add_route(Route(
"technical_support",
"Software bugs, crashes, errors, technical troubleshooting"
))
No Route Found¶
Cause: Threshold too high
Fix:
Memory Issues¶
High Memory Usage¶
Diagnosis:
Solutions:
-
Reduce HNSW M Parameter
-
Limit Cache Size
-
Use Redis for Cache
Connection Issues¶
Provider Timeouts¶
Symptoms: Frequent timeout errors
Fix:
Database Connection Pool Exhausted¶
Fix:
Performance Degradation¶
Gradual Slowdown¶
Diagnosis:
Common Causes: - Cache eviction thrashing - Memory pressure - Too many routes - Provider rate limits
Fix:
# Monitor and adjust
config = RuntimeConfig(
cache_max_size=20000, # Increase
rate_limit_per_second=5000 # Adjust
)
Integration Issues¶
LangChain Integration¶
Error: ImportError: No module named stratarouter.integrations
Fix:
Embedding Dimension Mismatch¶
Error: DimensionMismatchError
Fix:
# Match router dimension to embedding model
router = Router(dimension=384) # all-MiniLM-L6-v2
router = Router(dimension=768) # all-mpnet-base-v2
router = Router(dimension=1536) # OpenAI text-embedding-ada-002
Diagnostic Commands¶
Check Status¶
View Metrics¶
Check Logs¶
Test Route¶
from stratarouter.testing import test_route
result = test_route(
router=router,
query="I need help with payment",
expected_route="billing"
)
print(f"Matched: {result.matched}")
print(f"Confidence: {result.confidence}")
Debug Mode¶
Enable Verbose Logging¶
Common Error Codes¶
| Code | Meaning | Solution |
|---|---|---|
| 400 | Invalid request | Check query format |
| 401 | Unauthorized | Verify API key |
| 429 | Rate limited | Reduce request rate |
| 500 | Internal error | Check logs |
| 503 | Service unavailable | Check health endpoint |
Getting Help¶
Before Asking¶
- Check logs
- Review metrics
- Test in isolation
- Reproduce issue