agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
52 lines • 2.29 kB
TypeScript
/**
* loadSnapshot — read-side stage for Causal memory.
*
* Embeds the user's current question, searches the store for the most
* similar past run, projects the snapshot per `SnapshotProjection`,
* and writes the formatted result to `scope.formatted` so the
* downstream slot subflow injects it as a system message.
*
* Reads from scope: `identity`, `messages` (or `newMessages` fallback)
* Writes to scope: `formatted` — array of `LLMMessage` to inject
*
* Strict-threshold semantics:
* When `minScore` is set and no past snapshot meets it, returns an
* empty `formatted`. NO fallback — garbage past context is worse than
* no context.
*
* Empty-query handling:
* No user message → no embedding → no search → empty result.
*/
import type { TypedScope } from 'footprintjs';
import type { MemoryStore } from '../store/index.js';
import type { Embedder } from '../embedding/index.js';
import type { MemoryState } from '../stages/index.js';
import { type SnapshotProjection } from '../define.types.js';
export interface LoadSnapshotConfig {
/** Vector-capable store. Must implement `search()`. */
readonly store: MemoryStore;
/** Embedder used to vectorize the current query. */
readonly embedder: Embedder;
/** Stable id of the embedder — filters cross-model results out. */
readonly embedderId?: string;
/** Top-k snapshots to retrieve. Default 1 (most-relevant past run). */
readonly topK?: number;
/**
* Minimum cosine score [-1, 1]. Strict — entries below this are
* dropped. When no entry meets the threshold, the stage emits no
* messages (no fallback). Default 0.7.
*/
readonly minScore?: number;
/**
* Slice of the snapshot to project. Default `'decisions'` —
* decision evidence is the highest-signal field for "why" follow-ups.
*/
readonly projection?: SnapshotProjection;
/**
* Optional override for query extraction. Default: last user
* message in `scope.messages` (current turn's question).
*/
readonly queryFrom?: (scope: TypedScope<MemoryState>) => string;
}
export declare function loadSnapshot(config: LoadSnapshotConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
//# sourceMappingURL=loadSnapshot.d.ts.map