#1425·voltagent

Buffered conversation messages can be lost after a memory write fails

Author: dafyy321-pixelCreated Sep 28, 2026Updated Sep 28, 2026

What happens

When several messages are waiting to be written for the same conversation, a storage failure can leave the conversation history incomplete. A later flush does not recover the messages that were in the failed batch. This is particularly easy to miss with the debounced persistence path: the write error is logged, but the buffer no longer considers those messages pending.

For example, suppose a buffer contains three new messages and the storage adapter fails while saving the first one. The first flush() rejects, which is useful, but the buffer has already cleared all three pending IDs. Once the adapter is available again, a second flush() finds nothing to write. The conversation continues in memory while its persisted history is missing those turns.

A failure on the second write has a similar outcome: the first message reaches storage, but neither the failed second message nor the unattempted third message is available for a later flush. The retry set should contain exactly those two messages. Keeping the successful first message out of that set also avoids sending it twice.

The same problem can be silent through MemoryManager.saveMessage(). That method catches and logs a failure from the underlying Memory call, then resolves. The persistence queue interprets the resolved promise as a successful write. This also means a temporary database outage cannot be distinguished from a successful save by callers of saveMessage().

How to reproduce

  1. Create a ConversationBuffer and ingest two or more UIMessage values with markAsSaved = false.
  2. Use a MemoryPersistQueue whose saveMessage rejects once, then succeeds.
  3. Call flush() and observe the rejection.
  4. Call flush() again after the simulated adapter recovers.
  5. The second call does not send the messages from the failed batch to storage.

For the manager path, use a Memory instance whose message write rejects. MemoryManager.saveMessage() currently resolves even though the message was not stored.

The affected code is in packages/core/src/agent/memory-persist-queue.ts, packages/core/src/agent/conversation-buffer.ts, and packages/core/src/memory/manager/memory-manager.ts. The queue receives a ConversationBuffer from the agent's persistence path and writes pending messages individually; the lost pending state happens before the first individual write starts.

Why it happens

MemoryPersistQueue.persist() calls ConversationBuffer.drainPendingMessages() before saving any message. drainPendingMessages() clears the whole pending set immediately. The queue writes each drained message one by one, so a failure leaves the failed message and every later message outside the buffer's retry set. Separately, MemoryManager.saveMessage() catches a storage error without rethrowing it, so the queue can acknowledge a write that never succeeded.

Expected behavior

  • A message stays pending until its storage write succeeds.
  • If a later message fails, earlier successful writes are acknowledged, while that message and the rest of the batch remain pending for a subsequent flush.
  • A message updated during an in-flight write remains pending so its newer content can be saved.
  • The persistence queue receives a rejection from MemoryManager.saveMessage() after a failed write, while callers that intentionally treat memory writes as best effort can keep their current behavior.

This matters for any application that relies on stored conversation history after a transient adapter failure: a retry should recover the missing turns without requiring the application to reconstruct the buffer.