Commit graph

4 commits

Author SHA1 Message Date
Claude Code Bot
b6b8eed3bd fix(tests): skip memory tests when hnswlib not available
Add pytestmark skip conditions to memory test modules that depend on
hnswlib (core_operations, factory, easy). The subprocess probe for
hnswlib correctly detects unavailability on some platforms (like
Python 3.13 CI runners), but these tests were still trying to run
and failing with ImportError.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 16:09:53 -08:00
chopratejas
2320405348 Fix asyncio event loop error in Python 3.10+ tests
Use asyncio.run() instead of asyncio.get_event_loop().run_until_complete()
which raises RuntimeError in Python 3.10+ when no event loop exists.
2026-01-30 16:27:26 -08:00
chopratejas
52da662979 Fix mypy errors and add network timeout handler for flaky CI tests
Mypy fixes (no-any-return errors from external libraries):
- litellm_pricing.py: cast litellm.model_cost
- anthropic.py: cast litellm cost returns
- cohere.py: cast litellm info/cost returns
- compressor.py: explicit int() for PIL size calculations
- sqlite.py: explicit bytes() for numpy tobytes()
- universal.py: explicit str() for CCR store key
- direct_mem0.py: explicit list() for OpenAI embedding
- langchain/agents.py: explicit str() for result
- server.py: explicit str() for httpx response.text
- runner_v2/v3.py: add hasattr check for backend.close()

Test fixes (flaky network timeouts in CI):
- Add network_timeout_handler decorator to skip on httpx.ReadTimeout
- Applied to test_close_idempotent, test_save_with_entities, test_add_batch_basic

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 19:39:33 -08:00
chopratejas
da74341858 Add hierarchical memory system with graph + vector storage
Implement comprehensive memory system supporting:
- Local backend (SQLite + FTS5 + HNSW) for zero-dependency operation
- Mem0 backends (Neo4j + Qdrant) for production graph memory
- DirectMem0Adapter for optimized pre-extracted data (bypasses LLM)
- Memory extraction with facts, entities, and relationships
- Proxy integration with --memory flag for automatic memory injection

Key components:
- headroom/memory/backends/: LocalBackend, Mem0Backend, DirectMem0Adapter
- headroom/memory/system.py: MemorySystem with tool-based interface
- headroom/memory/extraction.py: Entity and relationship extraction
- headroom/proxy/memory_handler.py: Proxy integration layer
- headroom/prediction/feature_extractor.py: Content analysis features

Testing:
- 217 new memory system tests covering all backends
- LoCoMo evaluation framework for memory quality assessment
- Integration tests for proxy memory functionality

Also removes deprecated example files in favor of focused test coverage.
2026-01-26 21:58:47 -08:00