Skip to content

Add Filesystem Memory Tool And Chat Demo#10

Open
a1594834522-coder wants to merge 34 commits intopowerdrillai:mainfrom
a1594834522-coder:main
Open

Add Filesystem Memory Tool And Chat Demo#10
a1594834522-coder wants to merge 34 commits intopowerdrillai:mainfrom
a1594834522-coder:main

Conversation

@a1594834522-coder
Copy link
Collaborator

Introduce MemoryTool with filesystem-backed implementations and export it from the package entrypoint.
Add example/chat.py to demonstrate Anthropic chat integration plus local memory management commands.
Refresh README.md with setup guidance, usage examples, and configuration notes.
Validation steps: (1) install or activate dependencies, (2) run python example/chat.py, (3) exercise local memory commands and ensure tool callbacks succeed.

a1594834522-coder and others added 17 commits October 10, 2025 17:52
This commit includes the complete Claude Memory system with:

✅ Core Features:
- FastAPI-based server with memory capabilities
- Python SDK for easy integration
- Session management with intelligent context handling
- File-based memory storage with CRUD operations

✅ Architecture:
- Server: claude-memory-server/
- SDK: claude-memory-sdk/
- Examples and documentation

✅ Key Components:
- Memory management with automatic context retrieval
- Session tracking with timeout and cleanup
- Advanced search and backup capabilities
- RESTful API with comprehensive endpoints

✅ Development Setup:
- Virtual environment configuration
- Requirements and dependencies
- Interactive testing tools
- Comprehensive .gitignore

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Combined comprehensive Python gitignore with existing remote gitignore:
- Kept detailed Python-specific ignores (pycache, dist, eggs, etc.)
- Added Claude Memory Server specific ignores
- Maintained IDE and development file ignores
- Preserved coverage and testing file patterns

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 82.85078% with 77 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
memorylake/memorytool.py 81.92% 32 Missing ⚠️
memorylake/async_memorylake_memorytool.py 75.00% 31 Missing ⚠️
memorylake/memorylake_memorytool.py 87.03% 14 Missing ⚠️

📢 Thoughts on this report? Let us know!

cicd/test-all.sh Outdated
TEST_SCOPE="${1:-memorylake}"
python3 -m pytest -n logical --cov=. --cov-append --cov-report="" "${TEST_SCOPE}"

PYTEST_ARGS=()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为何需要增加 test-all.sh 里的这些改动?正常的开发环境 setup 之后这些包都是有的

MemoryToolOperationError,
MemoryToolPathError,
)
except ModuleNotFoundError as exc:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

什么时候会发生这种错误?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 测试需要:仓库里已有 test_memorytool_example.py::test_memorylake_init_missing_anthropic,就是为了验证当环境里缺少 anthropic 时,包仍能被导入且暴露出清晰的错误信息。如果删除
    try/except,该测试会失效。
    • 用户体验:哪怕 SDK 的主用例确实要求安装 anthropic,这个兜底逻辑能在“忘记安装”或“精简环境里先装 memorylake 再装 anthropic”的情形下提供友好的提示,而不是让整个 import memorylake
      直接崩掉。
    • 兼容性:一些用户可能只想安装 memorylake 看 API 或运行自定义的轻量操作(例如先处理路径、文件系统逻辑),延迟安装 anthropic。当前做法允许这种按需安装。

TEST_SCOPE="${1:-memorylake}"
python3 -m pytest -n logical --cov=. --cov-append --cov-report="" "${TEST_SCOPE}"

# Generate coverage.xml, and print to console too
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert 不必要的改动

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已恢复

a1594834522-coder and others added 9 commits October 20, 2025 21:50
Add HTTP-based memory tool clients that communicate with remote MemoryLake
server, supporting both synchronous and asynchronous operations.

New features:
- MemoryLakeMemoryTool: Sync HTTP client for remote memory operations
- AsyncMemoryLakeMemoryTool: Async HTTP client with context manager support
- Remote API endpoint: POST /public/v1/memory-tool
- Request structure: {memory_id, request, payload}
- Response structure: {content} or {error}
- Extended API: memory_exists(), list_memories(), stats()
- Client version header: x-memorylake-client-version

Example files:
- example/chat_remote.py: Interactive chat demo with remote server
- example/async_chat_remote.py: Async version of chat demo
- Both support verbose mode for debugging tool calls
- Fixed multi-tool handling to prevent 400 BadRequest errors

Test coverage:
- Full test suite for sync and async remote tools
- Mock server for testing without real backend
- Tests for all memory operations and error cases

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix integration test race condition by changing fixture scope to session
- Add type safety improvements using cast and helper functions
- Fix async generator return type annotation in test fixtures
- Update test files with proper type annotations
- Remove deprecated safe_cast implementation in favor of standard cast
- Fix flake8 and isort formatting issues
- All tests passing (28/28 unit tests, 0 errors in basedpyright)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace object | None with Optional[object] in test_memorylake_remote.py
- Ensures compatibility with Python 3.9 as per project requirements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Reorder isinstance check and cast to avoid Unknown type in len()
- Split compound condition for better type inference
- Achieves 0 errors, 0 warnings in basedpyright for Python 3.9

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants