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

Function applyBudgetBands

plugins/plugin-eval/src/core/budget.js:271–315  ·  view source on GitHub ↗
(rawBudget, baseline)

Source from the content-addressed store, hash-verified

269}
270
271export function applyBudgetBands(rawBudget, baseline) {
272 const profile = baseline?.[rawBudget.kind] || baseline?.directory || baseline?.skill;
273 const trigger = buildBudgetBucket(
274 rawBudget.trigger_cost_tokens.value,
275 profile.trigger_cost_tokens,
276 rawBudget.trigger_cost_tokens.components,
277 );
278 const invoke = buildBudgetBucket(
279 rawBudget.invoke_cost_tokens.value,
280 profile.invoke_cost_tokens,
281 rawBudget.invoke_cost_tokens.components,
282 );
283 const deferred = buildBudgetBucket(
284 rawBudget.deferred_cost_tokens.value,
285 profile.deferred_cost_tokens,
286 rawBudget.deferred_cost_tokens.components,
287 );
288 const explicitOnly = rawBudget.explicit_only_invoke_cost_tokens
289 ? buildBudgetBucket(
290 rawBudget.explicit_only_invoke_cost_tokens.value,
291 profile.invoke_cost_tokens,
292 rawBudget.explicit_only_invoke_cost_tokens.components,
293 )
294 : null;
295 const total = trigger.value + invoke.value + deferred.value;
296 return {
297 method: rawBudget.method || "estimated-static",
298 ...(rawBudget.invocation_policy ? { invocation_policy: rawBudget.invocation_policy } : {}),
299 trigger_cost_tokens: trigger,
300 invoke_cost_tokens: invoke,
301 deferred_cost_tokens: deferred,
302 ...(explicitOnly ? { explicit_only_invoke_cost_tokens: explicitOnly } : {}),
303 total_tokens: {
304 value: total,
305 band:
306 [trigger.band, invoke.band, deferred.band].includes("excessive")
307 ? "excessive"
308 : [trigger.band, invoke.band, deferred.band].includes("heavy")
309 ? "heavy"
310 : [trigger.band, invoke.band, deferred.band].includes("moderate")
311 ? "moderate"
312 : "good",
313 },
314 };
315}

Callers 2

analyzePathFunction · 0.90
explainBudgetFunction · 0.90

Calls 1

buildBudgetBucketFunction · 0.85

Tested by

no test coverage detected