agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
38 lines (37 loc) • 1.77 kB
TypeScript
/**
* heuristicExtractor — zero-dep, zero-cost beat extractor.
*
* Produces one beat per non-system message with a simple
* `"{role} said: {text}"` summary. Importance defaults to 0.5 except
* for messages that trip obvious salience signals (questions from the
* user, assistant tool-use, etc.) where a higher score fires.
*
* Why ship this as a default?
* Users who enable `narrativePipeline()` without configuring an
* extractor still get sensible behavior — compressed per-turn beats
* with provenance — without paying for an LLM call. The beats are
* less semantic than an LLM extractor's but still useful for recall.
* Users who want higher-quality beats opt into `llmExtractor()`.
*
* Heuristic rules (intentionally simple — this is a baseline, not
* state-of-the-art):
* - User messages → importance 0.6 (users are generally salient)
* - User questions (ending in '?') → importance 0.75
* - Messages containing "my name is" / "i am" → importance 0.9
* (identity beats are high-value for recall)
* - Assistant tool-use → importance 0.5 (process step)
* - Assistant final answers → importance 0.5
* - Tool results → importance 0.3 (noise for recall most of the time)
*
* Category hints:
* - `"identity"` for name / role assertions
* - `"question"` for user questions
* - `"tool-result"` for tool outputs
* - undefined otherwise (category is optional)
*
* This is heuristic. It will miss nuances the LLM extractor catches.
* Swap for `llmExtractor({ provider })` when quality matters.
*/
import type { BeatExtractor } from './extractor.js';
/** Default heuristic. Takes no config; factory function for consistency. */
export declare function heuristicExtractor(): BeatExtractor;