MCPcopy Create free account
hub / github.com/openai/plugins / addBudgetFindings

Function addBudgetFindings

plugins/plugin-eval/src/core/analyze.js:25–83  ·  view source on GitHub ↗
(result, budgets, baselineEvidence)

Source from the content-addressed store, hash-verified

23}
24
25function addBudgetFindings(result, budgets, baselineEvidence) {
26 result.budgets = budgets;
27 const bucketNames = ["trigger_cost_tokens", "invoke_cost_tokens", "deferred_cost_tokens"];
28
29 for (const bucketName of bucketNames) {
30 const bucket = budgets[bucketName];
31 result.metrics.push(
32 createMetric({
33 id: bucketName,
34 category: "budget",
35 value: bucket.value,
36 unit: "tokens",
37 band: bucket.band,
38 }),
39 );
40
41 if (bucket.band === "heavy" || bucket.band === "excessive") {
42 result.checks.push(
43 createCheck({
44 id: `${bucketName}-budget-high`,
45 category: "budget",
46 severity: bucket.band === "excessive" ? "error" : "warning",
47 status: bucket.band === "excessive" ? "fail" : "warn",
48 message: `${bucketName} is ${bucket.band} relative to the current Codex baseline.`,
49 evidence: [
50 `Value: ${bucket.value} tokens`,
51 `Baseline samples: skills=${baselineEvidence.skillSamples}, plugins=${baselineEvidence.pluginSamples}`,
52 ],
53 remediation: ["Reduce repeated instruction text and move detail into deferred supporting files."],
54 }),
55 );
56 }
57 }
58
59 if (budgets.explicit_only_invoke_cost_tokens) {
60 result.metrics.push(
61 createMetric({
62 id: "explicit_only_invoke_cost_tokens",
63 category: "budget",
64 value: budgets.explicit_only_invoke_cost_tokens.value,
65 unit: "tokens",
66 band: budgets.explicit_only_invoke_cost_tokens.band,
67 }),
68 );
69 }
70
71 result.artifacts.push(
72 createArtifact({
73 id: "budget-breakdown",
74 type: "budget",
75 label: "Budget breakdown",
76 description: "Trigger, invoke, and deferred token budget analysis.",
77 data: {
78 budgets,
79 baselineEvidence,
80 },
81 }),
82 );

Callers 1

analyzePathFunction · 0.85

Calls 3

createMetricFunction · 0.90
createCheckFunction · 0.90
createArtifactFunction · 0.90

Tested by

no test coverage detected