MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / sanitizeScriptContext

Function sanitizeScriptContext

src/providers/scriptContext.ts:33–57  ·  view source on GitHub ↗
(
  providerLabel: string,
  context: CallApiContextParams | undefined,
)

Source from the content-addressed store, hash-verified

31 * @returns A sanitized clone, or `undefined` if `context` was `undefined`.
32 */
33export function sanitizeScriptContext(
34 providerLabel: string,
35 context: CallApiContextParams | undefined,
36): CallApiContextParams | undefined {
37 if (!context) {
38 return undefined;
39 }
40
41 const sanitizedContext = { ...context };
42 const stripped: string[] = [];
43 for (const key of NON_SERIALIZABLE_CONTEXT_KEYS) {
44 if (key in sanitizedContext) {
45 stripped.push(key);
46 delete sanitizedContext[key];
47 }
48 }
49
50 if (stripped.length > 0) {
51 logger.debug(
52 `${providerLabel} sanitized context: stripped non-serializable keys [${stripped.join(', ')}]`,
53 );
54 }
55
56 return sanitizedContext;
57}

Callers 3

executePythonScriptMethod · 0.90
executeRubyScriptMethod · 0.90

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…