I found 2 bugs that cause the memory example not to work as expected in https://github.com/anthropics/anthropic-sdk-python/blob/main/examples/memory/basic.py
- Variable scope: The
assistant_content variable was declared outside the message processing loop, causing content accumulation across multiple messages
- Message ordering: Assistant messages were being stored after tool results, which violates the correct conversation flow where assistant messages should come before tool results
To fix these problems, I opened a PR at #1049.