You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: Add content preview mode to reduce search context usage (v0.7.0)
**Problem:**
- Search results returned full memory content, causing context overload
- 10 results with 2000 chars each = 20,000+ chars consumed immediately
- Inconsistent behavior between STM (full content) and LTM (truncated to 500)
**Solution:**
- Add `preview_length` parameter to search_memory and search_unified
- Default to 300 characters (90% reduction in context usage)
- Configurable via CORTEXGRAPH_SEARCH_PREVIEW_LENGTH env var
- Full content available by passing `preview_length=0`
**Changes:**
- config.py: Add `search_default_preview_length` config (default: 300)
- search.py: Add `preview_length` parameter and `_truncate_content()` helper
- search_unified.py: Add `preview_length` parameter with consistent truncation
- Both tools now apply preview consistently across STM and LTM results
**Benefits:**
- 90% reduction in context usage for typical searches
- Consistent truncation behavior across all search types
- User can opt-in to full content when needed
- Backward compatible (just changes default behavior)
**Testing:**
- Standalone tests verify truncation logic (6 test cases)
- Config validation ensures preview_length in valid range (0-5000)
- Type checking passes (mypy)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* test: Fix mocked config in embedding tests for preview_length
Three tests in test_tools_search.py were failing in CI because they mock
get_config() but didn't include the new search_default_preview_length
property added in the content preview feature.
Fixed tests:
- test_search_with_embeddings (line 310)
- test_search_embeddings_disabled (line 336)
- test_search_embedding_import_error (line 354)
Each now includes:
mock_config.return_value.search_default_preview_length = 300
This resolves all 9 CI failures (3 OSes × 3 Python versions).
---------
Co-authored-by: Prefrontal Systems <prefrontalsys@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments