Open Agent Loops
API Reference

withMemoryListeners

@open-agent-loops/core


function withMemoryListeners(memory, listener): Memory;

Defined in: compose.ts:160

Wrap a Memory so a MemoryListener is notified after each operation.

Parameters

ParameterTypeDescription
memoryMemoryThe memory backend to wrap.
listenerMemoryListenerCallbacks invoked after each successful operation.

Returns

Memory

A Memory that notifies listener after each op.

Remarks

This is the observer/listener seam for storage — the counterpart to withModelObserver for the model. Listeners only react (logging, metrics, cache warming); each callback runs after the underlying op succeeds and its return value is ignored, so the result the loop sees is never altered.

Attach more than one listener by wrapping more than once — wrappers stack.

Example

const logged = withMemoryListeners(store, {
  onAppend: (id, messages) => console.log(`+${messages.length} to ${id}`),
});

See

withModelObserver

On this page