Skip to content

Alert when a run's token use is far above the baseline for its repository and model #3439

Closed

Description

@integry

Problem

The only cost alert is a per-execution threshold that writes to a Redis list nothing reads. A run that burns several times the usual tokens goes unnoticed until the bill or the limit.

Goal

Detect outlier runs against ProPR's own history and tell the operator.

Acceptance criteria

  • After an execution is recorded, its total tokens are compared with the baseline for the same repository, model and execution type: the median of the last N successful executions (default 20, minimum 8 before any alert).
  • An alert fires when tokens exceed a multiple of the baseline (instance setting, default 4x) and an absolute floor, so small runs never alert.
  • The alert is an Inbox notification with severity warning, deduplicated per task, linking to the task, stating observed versus baseline. It reuses an existing notification kind.
  • An optional instance setting pauses scheduled automations for that repository after M alerts within a window (default off).
  • The settings follow the standard instance-setting pattern (loader, validation, settings catalog, MCP update_execution_settings, CLI).
  • The baseline query is indexed or cached so recording an execution does not slow down.
  • The existing unread high-cost Redis list is either wired to the same notification or removed.
  • Tests cover baseline computation, the threshold, the minimum-history guard, deduplication and the setting.

Implementation

Key files: packages/core/src/utils/llmMetrics.ts (recordLLMMetrics, checkCostThreshold), packages/core/src/services/notificationService.ts, src/jobs/runCostCap.ts (notifySpendCap precedent), settings pattern in packages/core/src/config/, packages/api/routes/configSettings.ts, packages/api/routes/configHelpers.ts (SPECIALIZED_SETTING_NAMES), packages/api/mcp/settingsCatalog.ts, packages/cli/src/api/settings.ts, packages/core/src/services/agents/agentRunCostGate.ts (automation pause precedent). Verify with the standard commands.

Activity

  1. propr-dev commented on Nov 12, 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: 3439/claude-opus-5-5-alert-when-a-run-s-token--20261112-1031-e9d
    • Base Branch: 3437-epic-cost-visibility-olu
    • Worktree: issue-3439-20261112-1031-claude-opus-5-5-e9d

    🔍 Track Task Execution

  2. added a commit that references this issue on Nov 12, 2026
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