Skip to content

Implement per-call cost tracking and usage logging #7

@Aureliolo

Description

@Aureliolo

Context

Track every LLM API call for cost management and observability per spec 10.2. This is essential for budget enforcement, usage analytics, and understanding agent economics.

Acceptance Criteria

  • Every LLM call is tracked with: agent_id, task_id, provider, model, input_tokens, output_tokens, cost_usd, timestamp
  • Cost calculated from pricing configuration (per-model token pricing)
  • Aggregation queries by agent, department, and time period
  • Async logging that does not block LLM call responses
  • In-memory storage for now (SQLite persistence planned for M5)
  • Unit tests for cost calculation accuracy
  • Unit tests for aggregation queries
  • Thread-safe logging for concurrent agent execution

Dependencies

Design Spec Reference

Section 10.2 — Cost Tracking and Budget Management

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:highImportant, should be prioritizedscope:medium1-3 days of workspec:budgetDESIGN_SPEC Section 10 - Cost & Budget Managementspec:providersDESIGN_SPEC Section 9 - Model Provider Layertype:featureNew feature implementation

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions