agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
28 lines (27 loc) • 1.21 kB
TypeScript
import type { ChoiceAttribution, AttributionUnit, Embedder } from './types.js';
export interface AttributeChoiceArgs {
/**
* The chosen tool being explained. `text` is what gets embedded — pass
* name + description (the name matters: rules that NAME a tool, e.g.
* "call report_gap", are its strongest citation).
*/
readonly tool: {
readonly name: string;
readonly text: string;
};
/** The context units to attribute to — the system-prompt rules, the task, … */
readonly units: readonly AttributionUnit[];
/** Injected embedder. Wrap in an `EmbeddingCache` so rule texts embed once. */
readonly embedder: Embedder;
/** Abort signal threaded to the embedder (network backends). */
readonly signal?: AbortSignal;
}
/**
* Embed the tool text and every unit once (deduplicated batch), rank the
* units by cosine to the tool, and report the top unit plus the per-channel
* share of positive similarity mass.
*
* Fail-loud validation: empty units or duplicate unit ids throw — those are
* caller wiring bugs, not runtime conditions.
*/
export declare function attributeChoice(args: AttributeChoiceArgs): Promise<ChoiceAttribution>;