UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

33 lines • 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadRecent = void 0; const DEFAULT_COUNT = 20; /** * Build a stage function that loads recent entries into `scope.loaded`. * * The returned stage is async and side-effect-free on failure: if the * store throws, the stage re-throws (fail-loud) — callers wrap with * `withRetry` / `withFallback` if they want degrade-to-empty behavior. */ function loadRecent(config) { const count = config.count ?? DEFAULT_COUNT; return async (scope) => { const identity = scope.identity; const entries = count === 0 ? [] : (await config.store.list(identity, { limit: count, ...(config.tiers && { tiers: config.tiers }), })).entries; // Store returns most-recently-updated first (see InMemoryStore.list). // Chat consumers want oldest-first for natural reading order, so // reverse before append. Allocates one array; acceptable for N ≤ a few // hundred (the only realistic scale for "recent messages"). const chronological = [...entries].reverse(); // Append rather than replace — lets multiple load stages compose. const existing = scope.loaded ?? []; scope.loaded = [...existing, ...chronological]; }; } exports.loadRecent = loadRecent; //# sourceMappingURL=loadRecent.js.map