agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
39 lines • 1.95 kB
JavaScript
/** Build-time cache diagnostic. Never evaluates a policy predicate, reads
* prompt text, or serializes a provider/options bag. The Agent calls once
* at construction; the returned policy source becomes fixed run metadata.
*/
import { isDevMode } from 'footprintjs';
export function cacheRequestedWithoutSupport(args) {
if (args.disabled || args.strategy.name !== 'none')
return undefined;
let requested = args.systemPrompt.length > 0 && args.systemPolicy !== 'never'
? args.systemExplicit
? 'explicit'
: 'default'
: undefined;
for (const injection of args.injections) {
if (!(injection.inject.systemPrompt?.length ||
injection.inject.messages?.length ||
injection.inject.tools?.length))
continue;
if (injection.metadata?.cache === undefined || injection.metadata.cache === 'never')
continue;
// Named factories record the source before applying their defaults. A
// custom Injection that authors metadata.cache itself is explicit.
const source = injection.metadata.cachePolicySource === 'default' ? 'default' : 'explicit';
if (source === 'explicit' || requested === undefined)
requested = source;
}
if (requested === undefined)
return undefined;
if (isDevMode() && (requested === 'explicit' || args.modelAwareUnavailable)) {
// eslint-disable-next-line no-console
console.warn((requested === 'explicit'
? `agentfootprint Agent: caching was requested, but provider '${args.providerName}' `
: `agentfootprint Agent: the default cache policy applies, but provider '${args.providerName}' `) +
"is configured with cache strategy 'none'. No cache markers will be sent. " +
'Choose a supported provider/model, or disable caching.');
}
return requested;
}
//# sourceMappingURL=cacheSupport.js.map