Skip to content

fix(auth-cursor): stop reporting the run's usage total on replies - #1

Merged
eric-x-liu merged 1 commit into
mainfrom
fix/cursor-no-run-usage
Nov 14, 2026
Merged

eric-x-liu merged 1 commit into
mainfrom
fix/cursor-no-run-usage

Conversation

@eric-x-liu

Copy link
Copy Markdown
Owner

What was broken

Cursor reports token usage once per run, and one run spans every tool round of a client turn (the plugin parks the run on each client tool call and resumes it with the result). The plugin put that run total on the final reply as if it were this request's usage (convertUsage(result.usage) in buildCompletion / buildStreamChunk). So the last reply of a turn counted the turn's whole context again for every round.

A Hermes agent on cursor/grok-4.7 (500K window) logged this on the final reply of a 17-call turn whose real prompts were about 40–58K each:

API call #17: model=cursor/grok-4.7 provider=custom in=1746716 out=11236

Hermes sizes its context from prompt_tokens, so the next message always started with a compression (context compression started … tokens=~3,680,991) even though the real context was about 35K. In one session, 13 such replies made up 39.9M of the 66.4M input tokens logged.

Reproduced straight against CLIProxyAPI with three tool rounds and then a text answer on a ~1.3K prompt: the tool-call replies carried no usage, and the final reply carried prompt_tokens: 13490.

What changed

  • Replies (streaming and non-streaming) carry no usage, the same as tool-call replies already did. LiteLLM and other OpenAI-compatible callers estimate usage per request.
  • The run total still goes to the cursor request completed log line (request_log.go is unchanged).
  • chatCompletion.Usage is removed. Tests now assert that no reply has a usage field.
  • README: one line under "Other limits".

Testing

  • go vet ./..., gofmt -l . (clean), go test ./... pass.
  • After the release, the deploy check is to repeat the probe above: the final reply should carry LiteLLM's estimate, and Hermes should stop compressing on every turn.

Not covered

  • CLIProxyAPI's host usage statistics lose Cursor token counts. The log line keeps them.
  • I haven't checked whether Cursor's input_tokens already includes cache_read_tokens; convertUsage adds them for the log line.

🤖 Generated with Claude Code

Cursor reports token usage once per run, and one run spans every tool
round of a client turn. The plugin put that run total on the final reply
as if it were this request's usage, so it counted the turn's whole context
again for each round. Clients that size their context from usage read it as
overflow: Hermes logged in=1,746,716 for a ~58K request on a 500K-window
model and compressed its context at the start of every turn.

Replies now carry no usage, the same as tool-call replies already did.
LiteLLM and other OpenAI-compatible callers estimate it per request. The
run total stays on the `cursor request completed` log line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eric-x-liu
eric-x-liu merged commit 49de234 into main Nov 14, 2026
2 checks passed
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.

1 participant