5cc5c58e01
The gateway's /reset cleanup path called shutdown_memory_provider without first draining the memory manager's serialized background write worker. shutdown_all only gives that worker a bounded (~5s) drain and abandons whatever is still queued past it, so a /reset could silently drop writes the session had already handed off -- the next session then loaded stale MEMORY.md. The CLI exit path already drains via MemoryManager.flush_pending before shutdown; this PR pins the same contract on the gateway cleanup path. Cleanup now calls agent._memory_manager.flush_pending(timeout=10) before the existing shutdown_memory_provider step. The flush is best-effort: a flush failure must never block teardown, so it is wrapped in try/except and the existing shutdown path remains the fallback. Closes #73297