This commit fixes the memory cookbook to work with anthropic SDK 0.69.0
and improves documentation around context clearing behavior.
Changes:
- Update context_management parameter usage for SDK 0.69.0
- Pass as direct parameter instead of extra_body
- Update response handling to use getattr() for Pydantic objects
- Fix context clearing configuration in notebook
- Lower clear_at_least threshold from 3000 to 50 tokens
- Memory tool operations have small results (~50-150 tokens)
- Add documentation explaining why threshold is low
- Add explanatory notes about context clearing behavior
- Explain why token savings are small in the demo
- Provide guidance for production configurations
- Document that larger tool results would save more tokens
The notebook now works correctly with SDK 0.69.0 and provides clear
guidance for users configuring context management in their applications.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Links to the Effective Context Engineering blog post at the start of the introduction to provide readers with background on the engineering principles demonstrated in the cookbook.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add Any to imports in web_scraper_v1.py, api_client_v1.py, and cache_manager.py
- Replace lowercase 'any' with 'Any' in all type hints
- Fixes syntax error: 'any' is a built-in function, not a type
Addresses PR review comments from automated bot and samj.
- Update .env.example to use claude-sonnet-4-5 model
- Remove "Always check memory first" from system prompts
- Add warning to clear_all_memory() about demonstration purposes
- Add path validation assertion in _delete() for safety
- Add notebook cell warning about memory clearing
- Clarify "Pattern Stored" section to show what Claude learns
All changes verified against official memory tool documentation.
Reverted all instances of CLAUDE_API_KEY back to ANTHROPIC_API_KEY to maintain
compatibility with existing infrastructure and GitHub secrets. This affects:
- Environment variable examples (.env.example files)
- Python scripts and notebooks
- Documentation and README files
- Evaluation scripts and test files
Other naming changes (Claude API, Claude Console, Claude Docs, Claude Cookbook) remain intact.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
One of the examples was wrong. The calculator gave the wrong result, and then Claude hallucinated another result. I fixed the regex which fixed the example