Skip to content

fix(cline-cli): decline the rollup when per-message calls were all deduped - #896

Merged
iamtoruk merged 1 commit into
mainfrom
fix/cline-cli-rollup-dedup
Aug 4, 2026
Merged

fix(cline-cli): decline the rollup when per-message calls were all deduped#896
iamtoruk merged 1 commit into
mainfrom
fix/cline-cli-rollup-dedup

Conversation

@iamtoruk

@iamtoruk iamtoruk commented Aug 3, 2026

Copy link
Copy Markdown
Member

Closes #894. Follow-up from the adversarial review of #891.

The bug

The rollup fallback in cline-cli was gated on emitted > 0, but emitted counted only calls that were actually yielded, and the seenKeys dedup check runs before the increment. So a session whose per-message calls were all suppressed by the shared dedup (a duplicated session directory reusing a session_id) kept emitted at 0 and fell through to the metadata.usage rollup, emitting the session's cost a second time under cline-cli:<id>:rollup. Over-reports; needs an abnormal on-disk layout.

The fix

Gate the rollup on whether the session carried any per-message metrics at all, tracked by a hadMetrics flag set before the dedup check rather than on the post-dedup emitted counter. A session whose messages were all deduped now correctly declines the rollup.

Verification

  • New test: two directories sharing an internal session_id and message ids, the second also carrying a metadata.usage rollup, collected through one shared seenKeys set. The copy is deduped and its rollup declined, so exactly one call survives and cost stays $0.01 rather than doubling to $0.02.
  • Mutation-checked: moving the hadMetrics assignment after the dedup check reproduces the original double-count (the test then sees 2 calls).
  • tsc clean; all 34 cline-cli tests pass; full suite green apart from the two standing parser.test.ts failures that reproduce on main.

…duped

The rollup fallback was gated on the post-dedup emitted counter, so a session
whose per-message calls were all suppressed by the shared dedup (a duplicated
session directory reusing a session_id) fell through to the metadata.usage
rollup and double-counted its cost. Gate on a hadMetrics flag set before the
dedup check instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cline-cli: rollup fallback double-counts a session whose per-message calls were all deduped

1 participant