CommandCodeAI / CommandCodeAI/command-code

Bug: Context window size in CLI differs from input tokens in usage logs

Đang mở
#445 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

@ahmadbilaldev đang làm issue này rồi.

Từ ngày 2/6/2026.

p1
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
4k
Fork
350
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Bug: Context window size in CLI differs from input tokens in usage logs

Summary

There is a significant discrepancy between the context window size displayed in the CLI (bottom right corner) and the input token counts shown in the web usage logs. After compacting, the displayed context size drops significantly, but still doesn't match the actual token usage shown online.

Environment
  • Command Code version: 0.30.1
  • OS: Windows
  • Shell: PowerShell
Steps to Reproduce
  1. Start a Command Code session and have a conversation
  2. Note the context window size shown in the CLI bottom right corner (e.g., ~500k tokens)
  3. Check the web usage dashboard at https://commandcode.ai/settings/usage
  4. Compare the "input tokens" shown in the usage logs with the CLI context display
  5. Run /compact to compact the context
  6. Note the new context window size (e.g., drops to ~300k)
  7. Compare again with web usage logs
Expected Behavior

The context window size displayed in the CLI should roughly correspond to the input token counts shown in the usage logs. The numbers should be consistent and accurate.

Actual Behavior

Example observations:

  • CLI bottom right corner shows ~500k tokens used
  • Web usage logs show much lower input token counts for the same requests
  • After /compact, context drops from ~500k to ~300k
  • Neither the pre-compact nor post-compact CLI numbers match the web usage logs

The context window display appears to be showing a different metric than what's actually being sent as input tokens to the API.

Analysis

This could be caused by:

  1. The context display counting tokens differently than the API (e.g., including system prompts, tool definitions, cached content)
  2. The context display showing the total context window capacity used rather than the actual input tokens for the current request
  3. A bug in how compacting updates the context size display
  4. The usage logs showing only new tokens (excluding cached tokens) while the CLI shows total context
Impact

This discrepancy makes it difficult to:

  • Accurately track token usage and costs
  • Understand when context is approaching limits
  • Plan when to start new sessions or compact
Related Issues
  • #348 — "Context Window Visual Reference" (requesting better context visibility)
  • #426 — "Add persistent context window indicator in cli"
  • #444 — "Usage data discrepancy between CLI /usage command and web dashboard" (different issue but similar theme of data inconsistency)

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.