volt_get_savings
Compare actual compute spending against optimal routing to identify savings achieved and missed opportunities across AI inference providers.
Instructions
Compare actual spend against optimal routing. Shows savings achieved and savings missed.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| time_range | No | Time range for the report: today, 7d (7 days), or 30d (30 days) | 7d |
Implementation Reference
- The handleGetSavings function executes the logic for 'volt_get_savings', retrieving the savings report from the tracker and formatting it.
export function handleGetSavings(input: GetSavingsInput, tracker: SpendTracker) { const report = tracker.getSavingsReport(input.time_range); if (report.actualSpend === 0) { return { content: [ { type: 'text' as const, text: `No spend data for ${input.time_range}. Record inference calls to see savings opportunities.`, }, ], }; } return { content: [ { type: 'text' as const, text: formatSavingsReport(report), }, ], }; } - The getSavingsSchema defines the input validation for 'volt_get_savings', specifically the 'time_range' parameter.
export const getSavingsSchema = z.object({ time_range: z .enum(['today', '7d', '30d']) .default('7d') .describe('Time range for the report: today, 7d (7 days), or 30d (30 days)'), }); - The formatSavingsReport function is a helper used to construct the text-based savings report output.
function formatSavingsReport(r: SavingsReport): string { const lines: string[] = [ `Savings Report (${r.timeRange})`, '─'.repeat(60), `Actual spend: $${r.actualSpend.toFixed(2)}`, `Optimal spend: $${r.optimalSpend.toFixed(2)}`, `Potential savings: ${r.savingsPercent}%`, '', `Savings achieved (followed recommendations): $${r.savingsAchieved.toFixed(2)}`, `Savings missed (ignored recommendations): $${r.savingsMissed.toFixed(2)}`, ]; if (r.savingsMissed > 0) { lines.push( '', `You could save $${r.savingsMissed.toFixed(2)} by following Volt routing recommendations.`, ); } else if (r.savingsPercent === 0) { lines.push('', 'You are already using the most cost-effective providers.'); } return lines.join('\n'); }