You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cline-cli: rollup fallback double-counts a session whose per-message calls were all deduped #894
Follow-up from the adversarial review of #891 (which shipped). Not a blocker: it over-reports and needs an abnormal on-disk layout, but it is a real money-path edge case worth closing.
The bug
In src/providers/cline-cli.ts, the rollup fallback is gated on emitted > 0, but emitted is incremented only for calls that are actually yielded. The seenKeys dedup check runs before the increment:
So if a session has per-message metrics but every one of them is suppressed by the shared dedup, emitted stays 0 and the parser falls through to the metadata.usage rollup, emitting the session's cost a second time under cline-cli:<id>:rollup.
Repro
Two session directories whose internal session_id collides (e.g. a copied session dir), same message ids, the second carrying a metadata.usage rollup:
Gate the rollup on whether the session had any per-message metrics at all, set before the dedup check, not on the post-dedup emitted counter:
lethadMetrics=false...constmetrics=parseMetrics(message['metrics'])if(!metrics)continuehadMetrics=true...if(seenKeys.has(deduplicationKey))continue
...
// after the loopif(hadMetrics)return// instead of `if (emitted > 0) return`
A session whose messages were all deduped then correctly declines the rollup. Add a test with the duplicate-session_id layout above, mutation-checked against the current emitted-based gate.
Activity