Repository navigation
Fix Cursor input normalization and CLI cache token accounting - #37
Open
Wang Siyuan (Wangmerlyn) wants to merge 1 commit into
Open
Wang Siyuan (Wangmerlyn) wants to merge 1 commit into
Wang Siyuan (Wangmerlyn) wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cursor CLI results report
cacheReadTokens, and Codex turns can reportcache_write_input_tokens. Argus currently drops these fields, turning reported cache counts (including an explicit zero) into unknown ledger values.Preserve both fields through the existing alias parser. Cursor also reports uncached input separately from cache reads/writes, so normalize its terminal result to Argus's inclusive input count. For example, a recorded result with
inputTokens=7361,cacheReadTokens=23040, andcacheWriteTokens=0becomes total input30401with cached input23040. Adding only the cache alias would incorrectly discount fresh input when a model has a configured price.Cursor terminal usage covers the current CLI invocation, including its followups. Mark that source separately so resumed sessions retain each invocation's full usage instead of subtracting the prior invocation. Canonical input aliases retain their existing precedence, omitted cache fields remain unknown, and raw events remain unchanged.
Protocol evidence: Cursor's CLI token explanation and official token-usage contract. Inspection of the installed official CLI
2026.09.28-64d2043confirms thatturnEndedsubtracts both caches from provider input and that the terminal usage accumulator is local to the print invocation. The two positive Cursor payloads in the tests are sanitized recorded results. Positive cache writes and the known-model pricing selection are synthetic regression cases.Validation:
uv run --python 3.11 --frozen --with pytest --with ruff python -m ruff check argus_skill testsandgit diff --checkpassed.The price catalog, subscription billing, historical reconciliation, and Cursor trust/model-effort integration require separate changes. This PR fixes the demonstrated token-accounting path.