Skip to content

fix: count every Cursor Agent assistant message instead of one turn per user message - #1513

Merged
iamtoruk merged 6 commits into
getagentseal:mainfrom
iliaal:fix/cursor-agent-full-turn-accounting
Sep 24, 2026
Merged

iamtoruk merged 6 commits into
getagentseal:mainfrom
iliaal:fix/cursor-agent-full-turn-accounting

Conversation

@iliaal

@iliaal iliaal commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #1512.

What changed

  • Every assistant message counts as a turn: each carries the last user message forward (JSONL and legacy text parsers).
  • tool_use inputs are serialized into the output text instead of counting as zero.
  • Input tokens use the full user text; the displayed message stays truncated at 500 chars.
  • cursor-agent parse version bumped (full-turn-accounting-v1) so cached sessions re-parse.

Verification

  • 4 new regression tests (carry-forward jsonl/txt, tool-input counting, truncation split); provider suite 21/21.
  • Full suite 4317 passed, tsc clean.
  • Live corpus, September: 240 turns → 5,004 calls, 2.66M in / 1.36M out tokens, $28.40 (est.).

Still estimates — no real token counts exist on disk — and everything prices as Sonnet 4.5 (conversation_summaries is empty in practice).

…er user message

Agentic loops emit dozens of assistant messages per user message and
the parser kept only the first (on one real corpus: 247 of 4,946
messages, ~4% of assistant text). Each message now carries the last
user message forward, tool_use inputs join the output text, and input
tokens use the full user text while the display stays truncated at
500 chars. Parse version bumped so cached sessions re-parse.
@iliaal
iliaal requested a review from iamtoruk as a code owner September 20, 2026 20:26
@iamtoruk

Copy link
Copy Markdown
Member

Merged, thanks @iliaal. Your diagnosis held up: on one real corpus main counted 669 of 5,050 Cursor Agent assistant messages. I added three small commits on top: the user's prompt is now billed once per user message rather than once per assistant message (a long pasted prompt was being re-billed on every reply of the loop), the daily cache version is bumped so settled days re-derive with the new counts, and transcripts that end before any assistant reply (usage-limit and error stubs) no longer print an unrecognized-format warning.

@ozymandiashh ozymandiashh added bug Something isn't working provider: cursor-agent Cursor Agent provider area: cli The codeburn CLI and its core parsing/reporting engine labels Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli The codeburn CLI and its core parsing/reporting engine bug Something isn't working provider: cursor-agent Cursor Agent provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor Agent usage severely undercounted: only first assistant message per user message parsed

3 participants