Memory is not loaded automatically
I encountered an issue while using the Agent Python SDK. My project contains a MEMORY.md file. When using different session IDs within the same project, the MEMORY.md content fails to load automatically. It only loads after I explicitly instruct Claude to access it. Could you explain why this happens?
This is the expected default behavior,
The MEMORY.md is a dynamic section of the claude_code system-prompt preset, and is documented in the exclude_dynamic_sections docstring at types.py#L43. The SDK defaults system_prompt=None, which sends an empty prompt with no preset, you can see this here subprocess_cli.py#L227-L228. As a result, the section is never injected and the model only sees MEMORY.md when it Reads the file.
You can opt into the preset and keep project in setting sources:
options = ClaudeAgentOptions(
system_prompt={"type": "preset", "preset": "claude_code"},
setting_sources=["user", "project", "local"], # None also works; [] disables it
)