mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
Follows up on PR #19 which fixed RollingWindow but missed IntelligentContextManager, the default context manager used by the proxy. Changes: 1. intelligent_context.py: Extended `_get_protected_indices()` to handle Anthropic format: - Scan assistant.content for type="tool_use" blocks - Protect user messages containing type="tool_result" blocks with matching tool_use_id 2. test_intelligent_context.py: Added TestAnthropicFormatToolProtection class with 5 tests: - test_anthropic_tool_result_protected_when_tool_use_protected - test_anthropic_tool_units_dropped_atomically - test_anthropic_multiple_tools_same_message_atomic - test_anthropic_format_no_api_error_scenario (verifies bug fix) - test_mixed_openai_and_anthropic_formats 3. test_rolling_window.py: Added matching TestAnthropicFormatToolProtection class with 5 tests - Added skip decorator for CI/CD when OPENAI_API_KEY is not set This ensures both context managers (RollingWindow and IntelligentContextManager) correctly handle Anthropic's native tool_use/tool_result format, preventing the "unexpected tool_use_id found in tool_result blocks" API error. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_anchor_selector.py | ||
| test_cache_aligner.py | ||
| test_code_compressor.py | ||
| test_content_router.py | ||
| test_diff_compressor.py | ||
| test_html_extractor.py | ||
| test_intelligent_context.py | ||
| test_llmlingua_compressor.py | ||
| test_progressive_summarizer.py | ||
| test_rolling_window.py | ||
| test_scoring.py | ||
| test_smart_crusher.py | ||
| test_tool_crusher.py | ||