Skip to main content

Class: MemoryObserver

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

Constructors​

Constructor​

new MemoryObserver(traits, config?): MemoryObserver

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

Parameters​

traits​

HexacoTraits

config?​

Partial<ObserverConfig>

Returns​

MemoryObserver

Methods​

clear()​

clear(): void

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

Reset the observer.

Returns​

void


compressIfNeeded()​

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

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

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/cognition/memory/pipeline/observation/MemoryObserver.ts:167

Force extraction of observation notes from buffered messages.

Parameters​

mood?​

PADState

Returns​

Promise<ObservationNote[]>


getAccumulatedCompressed()​

getAccumulatedCompressed(): readonly CompressedObservation[]

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

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

Returns​

readonly CompressedObservation[]


getAccumulatedCompressedCount()​

getAccumulatedCompressedCount(): number

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

Get the count of accumulated compressed observations awaiting reflection.

Returns​

number


getAccumulatedNoteCount()​

getAccumulatedNoteCount(): number

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

Get the count of accumulated raw notes awaiting compression.

Returns​

number


getBuffer()​

getBuffer(): ObservationBuffer

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

Get the underlying buffer for inspection.

Returns​

ObservationBuffer


observe()​

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

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

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/cognition/memory/pipeline/observation/MemoryObserver.ts:224

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/cognition/memory/pipeline/observation/MemoryObserver.ts:267

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

Parameters​

threshold​

number

Returns​

void


setReflectionThresholdTokens()​

setReflectionThresholdTokens(threshold): void

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

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

Parameters​

threshold​

number

Returns​

void


shouldActivate()​

shouldActivate(): boolean

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

Check if observation should be triggered.

Returns​

boolean