UNPKG

agentfootprint

Version:

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

47 lines • 2.13 kB
"use strict"; /** * AutomaticCacheStrategy — for a provider that caches repeated prefixes on * its own (`promptCaching.mode: 'automatic'`; OpenAI, Azure OpenAI). * * Chosen by CAPABILITY (`cacheStrategyFor`), never by provider name. * * - **prepareRequest**: pass-through. The provider decides what to cache; * a marker would mean nothing on its wire. The `cache:` policies on * injections still matter — they travel with the agent and take effect * the moment it runs on a breakpoint provider — but here they have no * local effect, and `cache: 'never'` cannot stop the provider caching. * - **extractMetrics**: the port usage when the adapter declares it * reports cache tokens; `not applicable` when it declares it does not * (the OpenAI adapter does not lift `prompt_tokens_details.cached_tokens` * yet — named, rather than hidden behind a per-call `unknown` that would * suggest the measurement was attempted). */ Object.defineProperty(exports, "__esModule", { value: true }); exports.AutomaticCacheStrategy = void 0; const claim_js_1 = require("../../lib/claim/claim.js"); const portUsage_js_1 = require("../portUsage.js"); class AutomaticCacheStrategy { name = 'automatic'; reportsUsage; who; /** * @param declared the provider's `promptCaching` declaration * @param who names the adapter in the meter's evidence sentences */ constructor(declared, who = 'the provider') { this.reportsUsage = declared.reportsUsage; this.who = who; } async prepareRequest(req, _candidates, _ctx) { return { request: req, markersApplied: [] }; } extractMetrics(usage) { if (!this.reportsUsage) { return (0, claim_js_1.notApplicable)(`${this.who} caches automatically but declares that it does not report cache ` + 'token counts (promptCaching.reportsUsage: false)'); } return (0, portUsage_js_1.readPortCacheUsage)(usage, this.who); } } exports.AutomaticCacheStrategy = AutomaticCacheStrategy; //# sourceMappingURL=AutomaticCacheStrategy.js.map