Skip to content

Metrics and LLM-cost export (CSV, JSON, CLI, MCP) #3438

Closed

Description

@integry

Implements roadmap item #1675.

Problem

The only export is GET /api/stats/review-scores.csv. Teams that need a finance breakdown compute it by hand from the UI.

Goal

A cost export by day, repository, model, effort, execution type and outcome.

Acceptance criteria

  • GET /api/stats/cost (JSON) and GET /api/stats/cost.csv return rows grouped by a group_by list drawn from: day, repository, agent, model, reasoning_level, execution_type, outcome (success/failed). Each row has executions, tasks, input/output/cache tokens and cost in USD.
  • The standard analytics window parameters and repository filter apply; access control matches the existing stats routes.
  • CSV follows the conventions of the review-scores CSV (header row, stable column order, proper escaping).
  • propr stats cost [--period] [--repository] [--group-by] [--json|--csv] in the CLI.
  • An MCP read tool returns the same data, registered in the tool catalog and documented in docs/mcp.md and docs/mcp-coverage.md.
  • The OpenAPI description and the generated client types include the new routes.
  • docs/docs/operations/metrics.md documents the export; docs/ROADMAP.md is updated.
  • Tests cover grouping, filters, CSV escaping, CLI output and the MCP tool.

Implementation

Key files: packages/api/routes/reviewScoreStats.ts (getCsv, CSV_COLUMNS pattern), packages/api/routeRegistry.ts (stats routes), packages/api/routes/analyticsWindow.ts, packages/api/routes/analyticsModelUsage.ts (executionTokenSums), packages/cli/src/commands/statsCommands.ts, packages/cli/src/api/stats.ts, packages/api/mcp/tools.ts, packages/client/src/generated/apiTypes.ts. Data source: llm_executions joined to tasks for repository; llm_logs for execution type and agent alias where needed. Verify with the standard commands.

Activity

  1. propr-dev commented on Nov 11, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3438/claude-opus-5-5-metrics-and-llm-cost-expo-20261111-2357-0bs
    • Base Branch: 3437-epic-cost-visibility-olu
    • Worktree: issue-3438-20261111-2357-claude-opus-5-5-0bs

    🔍 Track Task Execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions