Skip to content

Commit 0565fa5

Browse files
committed
feat(memory): export REFLECTOR_PROMPT_HASH for content-addressed cache keys
Computed at module load time from the prompt rendered with neutral HEXACO traits. Consumers (bench cache-key fingerprinting, observability) use this to auto-invalidate caches on prompt changes — no manual fingerprint bump needed. Follow-up to the Step 11 prompt tuning.
1 parent 689c4da commit 0565fa5

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/memory/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ export { ObservationBuffer } from './pipeline/observation/ObservationBuffer.js';
231231
export type { BufferedMessage, ObservationBufferConfig } from './pipeline/observation/ObservationBuffer.js';
232232
export { MemoryObserver } from './pipeline/observation/MemoryObserver.js';
233233
export type { ObservationNote } from './pipeline/observation/MemoryObserver.js';
234-
export { MemoryReflector } from './pipeline/observation/MemoryReflector.js';
234+
export {
235+
MemoryReflector,
236+
REFLECTOR_PROMPT_HASH,
237+
} from './pipeline/observation/MemoryReflector.js';
235238
export type { MemoryReflectionResult } from './pipeline/observation/MemoryReflector.js';
236239

237240
// --- Observation Compression & Reflection ---

src/memory/pipeline/observation/MemoryReflector.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* @module agentos/memory/observation/MemoryReflector
1414
*/
1515

16+
import { createHash } from 'node:crypto';
1617
import type { MemoryTrace, MemoryType, MemoryScope } from '../../core/types.js';
1718
import type { HexacoTraits, PADState, ReflectorConfig } from '../../core/config.js';
1819
import type { ObservationNote } from './MemoryObserver.js';
@@ -145,6 +146,26 @@ After your <thinking> block, output JSON objects, one per line:
145146
Output your <thinking> block first, then ONLY valid JSON objects, one per line.`;
146147
}
147148

149+
/**
150+
* Content-addressed hash of the reflector system prompt, computed at
151+
* module load time from the prompt rendered with neutral HEXACO traits.
152+
* Exported so consumers (bench cache-key fingerprinting, observability)
153+
* can auto-invalidate caches whenever the prompt text changes — no
154+
* manual version bumping needed.
155+
*/
156+
const NEUTRAL_HEXACO_TRAITS: HexacoTraits = {
157+
honesty: 0.5,
158+
emotionality: 0.5,
159+
extraversion: 0.5,
160+
agreeableness: 0.5,
161+
conscientiousness: 0.5,
162+
openness: 0.5,
163+
} as HexacoTraits;
164+
165+
export const REFLECTOR_PROMPT_HASH: string = createHash('sha256')
166+
.update(buildReflectorSystemPrompt(NEUTRAL_HEXACO_TRAITS))
167+
.digest('hex');
168+
148169
// ---------------------------------------------------------------------------
149170
// MemoryReflector
150171
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)