Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agent Cost Optimizer

Real-time agent operation cost tracking and autonomous budget allocation with cost-ceiling enforcement.

Features

  • Real-time Cost Tracking: Track token usage across different LLM providers (OpenAI, Anthropic, Google).
  • Budget Management: Set daily, per-session, and monthly budget limits for multiple agents.
  • Ceiling Enforcement: Automatically check and block operations that exceed budget limits.
  • Cost Analysis: Generate usage summaries and export data to CSV or Markdown.
  • Alerting System: Get notified when agents reach specific budget thresholds (50%, 80%, 90%, 100%).

Installation

bun install

Usage

Record Token Usage

bun src/index.ts record -a agent-1 -s session-123 -m gpt-4o -p 500 -c 200

Check Budget Status

bun src/index.ts check -a agent-1 -s session-123

Set Agent Budgets

bun src/index.ts set-budget -a agent-1 -d 5.0 -s 0.5 -m 50.0

View Usage Summary

bun src/index.ts summary -a agent-1

List All Budgets

bun src/index.ts list-budgets

Architecture

  • CostTracker: Manages the persistence and aggregation of cost records.
  • BudgetManager: Handles agent-specific budget configurations.
  • CeilingEnforcer: Core logic for determining if an operation is allowed based on current usage and budget.
  • AlertManager: Monitors usage levels and triggers notifications at configurable thresholds.
  • DataExporter: Utility for exporting cost data to various formats.

Configuration

Pricing data is maintained in src/providers.ts and can be updated to reflect current API costs. Data is stored locally in the data/ directory.

License

MIT

About

Real-time agent operation cost tracking and autonomous budget allocation with cost-ceiling enforcement

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages