Skip to content

Cursor provider inflates "Today" usage when Cursor stays running (agentKv timestamp drift) #460

Closed

Description

@TFOTG

Problem

Today usage for Cursor can become abnormally high (cost/calls), especially when Cursor keeps running for a long time.

Observed pattern:

  • Today shows inflated values.
  • Next day, previous day looks normal again.
  • But the new Today becomes inflated again.

This looks like historical records being repeatedly bucketed into the current date.

Likely cause

In src/providers/cursor.ts, bubbleId:% rows are mostly guarded by createdAt, but agentKv:blob:% rows do not have reliable per-row timestamps.

The agentKv path uses a shared runtime-derived timestamp (DB mtime / now fallback behavior), so older usage can drift into whatever day the command runs.

Suggested fix

  • Do not assign new Date() (or runtime-derived day) to rows without reliable timestamps.
  • Safest approach: skip agentKv rows for day-based stats until per-row timestamps are available.
  • If Cursor later provides a stable timestamp field in agentKv, only include rows with valid parsed timestamps.

Note

I used AI-assisted code tracing to locate and verify the affected parse paths quickly, sharing this as a reference for maintainers.

Activity

  1. tekumara commented on Jun 23, 2026

    @tekumara

    Dupe of #326

  2. hiSandog commented on Jun 29, 2026

    @hiSandog

    Agreed this overlaps #326, but the day-bucketing failure has an extra consequence worth calling out: the same agentKv:blob:% rows that drift into "Today" also corrupt lifetime rollups if they're summed without a reliable timestamp. The pragmatic fix is to exclude agentKv rows from any time-bounded aggregation until per-row timestamps exist (and only count them in a timestamp-agnostic total), rather than trying to bucket unbucketable rows. That at least stops the "Today" inflation without a schema migration. A per-row ts on those keys would be the real fix but is a bigger change.

  3. iamtoruk commented on Jul 20, 2026

    @iamtoruk
    Member

    Fixed: Cursor usage is attributed to the conversation/turn day instead of the drifting agentKv timestamp (#254, hardened in #575), so Today no longer inflates while Cursor stays running. Covered by a regression test.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions