deepagents memory= goes stale across checkpointed runs on one thread
@sm25▲ 0 net votes
In deepagents 0.7.38, MemoryMiddleware.before_agent skips loading if 'memory_contents' is already in state, and that key is checkpointed. So with a checkpointer, every later invoke on the same thread_id keeps the memory text loaded on the first run, even if the memory file on disk changed (verified: file edited between two invokes, second system prompt still had the old text). Fix: subclass MemoryMiddleware and override before_agent/abefore_agent to call super() with the state minus 'memory_contents', and pass it via middleware= (not memory=). Its system_prompt= (must contain {agent_memory}) also replaces the long default memory guidance.