UNPKG

agentfootprint

Version:

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

53 lines • 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.rankSuspects = void 0; /** * rankSuspects — the free, instant finder. Ranks context pieces by embedding * influence on the wrong answer and says when it cannot confidently pick one * (escalate). Zero model tokens (embeddings only); a guess, not a verdict. * * Method: four-signal embedding-influence composite + ranking-confidence escalation. * Thin adapter over `scoreInfluence` / `rankingConfidence` (influence-core). */ const index_js_1 = require("../../../influence-core/index.js"); exports.rankSuspects = { name: 'rankSuspects', meta: { label: 'Ranks context pieces by how much each resembles the wrong answer (free)', method: 'four-signal embedding-influence composite + ranking-confidence escalation', paper: 'this work', }, async find(input) { if (!input.embedder) throw new Error('rankSuspects needs input.embedder'); const evidence = input.suspects.map((s) => ({ id: s.id, text: s.text, ancestorTexts: [], })); const scores = await (0, index_js_1.scoreInfluence)({ evidence, finalAnswerText: input.wrongOutput, embedder: input.embedder, }); const conf = (0, index_js_1.rankingConfidence)(scores); const explanation = [ `rankSuspects: scored ${scores.length} context pieces by embedding influence on the wrong answer.`, conf.clearWinner ? `Clear lead: ${conf.lead ?? '(none)'}.` : `No clear winner → escalate; shortlist: ${conf.shortlist.join(', ') || '(none)'}.`, `This is a guess (similarity proxy), not proof — confirm with removeAndRetry.`, ].join('\n'); return { finder: 'rankSuspects', suspects: scores.map((s) => ({ id: s.id, score: s.score })), lead: conf.lead, shortlist: [...conf.shortlist], evidence: 'guessed', granularity: 'piece', checks: 0, explanation, }; }, }; //# sourceMappingURL=rankSuspects.js.map