Skip to main content

Class: MemoryObserver

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:106

Constructors

Constructor

new MemoryObserver(traits, config?): MemoryObserver

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:120

Parameters

traits

HexacoTraits

config?

Partial<ObserverConfig>

Returns

MemoryObserver

Methods

clear()

clear(): void

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:276

Reset the observer.

Returns

void


compressIfNeeded()

compressIfNeeded(): Promise<CompressedObservation[] | null>

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:201

Run compression if accumulated notes exceed the compression threshold.

When the number of accumulated raw notes exceeds the configured threshold (default: 50), the ObservationCompressor is invoked to produce denser compressed observations. The raw notes are then cleared.

Returns

Promise<CompressedObservation[] | null>

Compressed observations if threshold was met, null otherwise.


extractNotes()

extractNotes(mood?): Promise<ObservationNote[]>

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:166

Force extraction of observation notes from buffered messages.

Parameters

mood?

PADState

Returns

Promise<ObservationNote[]>


getAccumulatedCompressed()

getAccumulatedCompressed(): readonly CompressedObservation[]

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:261

Get the accumulated compressed observations (read-only snapshot).

Returns

readonly CompressedObservation[]


getAccumulatedCompressedCount()

getAccumulatedCompressedCount(): number

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:256

Get the count of accumulated compressed observations awaiting reflection.

Returns

number


getAccumulatedNoteCount()

getAccumulatedNoteCount(): number

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:251

Get the count of accumulated raw notes awaiting compression.

Returns

number


getBuffer()

getBuffer(): ObservationBuffer

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:241

Get the underlying buffer for inspection.

Returns

ObservationBuffer


observe()

observe(role, content, mood?): Promise<ObservationNote[] | null>

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:150

Feed a message into the observation buffer. Returns observation notes if the buffer has reached activation threshold.

Parameters

role

"user" | "tool" | "system" | "assistant"

content

string

mood?

PADState

Returns

Promise<ObservationNote[] | null>


reflectIfNeeded()

reflectIfNeeded(): Promise<Reflection[] | null>

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:223

Run reflection if accumulated compressed observations exceed the token threshold.

When the total estimated tokens of accumulated compressed observations exceeds the configured threshold (default: 40,000 tokens), the ObservationReflector is invoked to extract higher-level patterns.

Returns

Promise<Reflection[] | null>

Reflections if threshold was met, null otherwise.


setCompressionThreshold()

setCompressionThreshold(threshold): void

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:266

Set the compression threshold (number of notes before compression triggers).

Parameters

threshold

number

Returns

void


setReflectionThresholdTokens()

setReflectionThresholdTokens(threshold): void

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:271

Set the reflection token threshold (estimated tokens before reflection triggers).

Parameters

threshold

number

Returns

void


shouldActivate()

shouldActivate(): boolean

Defined in: packages/agentos/src/memory/pipeline/observation/MemoryObserver.ts:246

Check if observation should be triggered.

Returns

boolean