agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
40 lines (39 loc) • 1.95 kB
TypeScript
import type { Embedder } from '../influence-core/index.js';
import type { ContextUnit } from './missingContext.js';
import type { AblationRunStats, OutcomeComparator } from './types.js';
/**
* Re-run the agent with `units` ADDED BACK into the context (`[]` = baseline,
* restore nothing). Returns the run's output. Mirror of `AblationRunner`.
*/
export type RestorationRunner = (units: readonly ContextUnit[], run: {
readonly seed: number;
}) => Promise<string>;
/** The rerun configuration that upgrades the dropped list to the causal tier. */
export interface RestorationRerun {
readonly runner: RestorationRunner;
/** The original (buggy) output the reruns are compared against. */
readonly originalOutput: string;
/** Seeded reruns per probe. Default 3. Never below 2 (no single-run verdicts). */
readonly samples?: number;
/** Outcome-flip comparator. Default: similarity < `flipThreshold`. */
readonly outcomeChanged?: OutcomeComparator;
/** Similarity floor for the DEFAULT comparator. Default 0.8. */
readonly flipThreshold?: number;
/**
* Restore only the first K dropped candidates. Default 5. COST: confirmation
* calls your model `samples × (K + 1)` times (the +1 is the baseline) — real,
* seeded re-runs. Keep `maxCandidates`/`samples` low, or pre-rank candidates,
* to bound spend. Candidates beyond K are listed without a verdict.
*/
readonly maxCandidates?: number;
}
export interface RestorationProbeConfig {
readonly rerun: RestorationRerun;
readonly embedder: Embedder;
}
/**
* Run ONE restoration probe: call the consumer's runner with `units` restored
* once per seed, measure each output's similarity to the original, count flips.
* `[]` units = the un-restored baseline. Mirror of `runAblationProbe`.
*/
export declare function runRestorationProbe(config: RestorationProbeConfig, units: readonly ContextUnit[]): Promise<AblationRunStats>;