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
Add Grok Build CLI as a first-class usage source. This would add ccusage grok daily|monthly|session, include Grok in unified reports, and support Grok-specific path configuration.
Why?
Current Grok Build releases write per-model token usage for completed turns to ~/.grok/sessions/**/updates.jsonl, but ccusage does not read it. Grok users therefore see incomplete token and estimated-cost totals.
How? (optional)
Add a Rust adapter that reads turn_completed usage, splits cached input without double-counting reasoning tokens, and estimates cost through the existing LiteLLM pricing data. Wire it into the CLI, config schema, all-agent loader, tests, and user docs. I have a current-main implementation ready and will open the PR after contributor approval.
This issue was auto-closed. Issues from new contributors are auto-closed by default.
Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.
Keep the issue short, concrete, and written in your own voice.
If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.
@LeeShunEE did you really try it?
when i tried it last time it doesnt have a token usage. could you make some poc with tiny script using js/shell to extract the usage data?
@LeeShunEE did you really try it? when i tried it last time it doesnt have a token usage. could you make some poc with tiny script using js/shell to extract the usage data?
To answer your "did you really try it?" question from before — yes, and here is the proof from a real run. The POC is the adapter itself: ccusage grok daily on my machine (grok 0.2.112, Windows), reading real turn_completed usage from ~/.grok/sessions/**/updates.jsonl:
Date
Input
Output
Cache Read
Total Tokens
Cost
2026-07-28
246,278
42,824
8,955,776
9,267,987
$3.90
2026-07-30
1,336,630
155,522
25,235,840
26,810,987
$12.67
2026-07-31
488,189
46,833
8,104,064
8,665,920
$4.18
2026-08-01
174,640
597
185,088
360,597
$0.46
2026-08-04
5,268,481
821,340
92,840,448
99,464,505
$49.11
2026-08-05
5,886,240
948,862
120,786,432
128,237,288
$60.88
Total
13,400,458
2,015,978
256,107,648
272,807,284
$131.20
The PR (#1520) is synced to the latest main (147e05b), and the full suite passes: ccusage-adapter-grok 39 passed (+ real-home smoke), ccusage-cli-parser 75, ccusage-config 26, ccusage-adapter-all 36.
Both this issue and the PR were auto-closed by the contributor gate — a reopen / lgtm when you have a chance would be much appreciated.
Sorry for being pushy earlier. Hope you’re feeling better now :)
Btw, having an issue immediately closed by a bot and getting no reply is a little bit frustrating.
Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.
Audit result: resolved. A later merged change or the current main implementation covers this request. This item is kept for history and does not need to be reopened.
Activity
pullfrog commentedon Jul 28, 2026
github-actions commentedon Jul 28, 2026
This issue was auto-closed. Issues from new contributors are auto-closed by default.
Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.
Keep the issue short, concrete, and written in your own voice.
If a maintainer replies
lgtmi, your future issues will stay open. If a maintainer replieslgtm, your future issues and PRs will stay open.See CONTRIBUTING.md.
ryoppippi commentedon Jul 28, 2026
@LeeShunEE did you really try it?
when i tried it last time it doesnt have a token usage. could you make some poc with tiny script using js/shell to extract the usage data?
it it works mention me.
LeeShunEE commentedon Jul 28, 2026
@ryoppippi
I got the PR ready for review already
my env
Grok Token Usage — Temp Q&A
Q1. Where are tokens stored, and what are the TTL / retention rules?
A: Two on-disk locations under Grok home:
$GROK_HOME/sessions/**/updates.jsonlTurnCompleted+usage[storage] cleanup_ttl_days)$GROK_HOME/logs/unified.jsonlTTL source (one line each):
grok-build\crates\codegen\xai-grok-shell\src\session\persistence.rs:3047(DEFAULT_CLEANUP_TTL_DAYS = 30)grok-build\crates\codegen\xai-grok-telemetry\src\unified_log.rs:29(MAX_SIZE = 5 * 1024 * 1024)one line of session updates.jsonl example containing token usage
{ "timestamp": 1785237763, "method": "_x.ai/session/update", "params": { "sessionId": "", "update": { "sessionUpdate": "turn_completed", "prompt_id": "", "stop_reason": "cancelled", "usage": { "inputTokens": 153817, "outputTokens": 2702, "totalTokens": 156519, "cachedReadTokens": 129408, "reasoningTokens": 940, "modelCalls": 6, "apiDurationMs": 39491, "costUsdTicks": 1038524000, "modelUsage": { "grok-4.5-build": { "inputTokens": 153817, "outputTokens": 2702, "totalTokens": 156519, "cachedReadTokens": 129408, "reasoningTokens": 940, "modelCalls": 6, "apiDurationMs": 39491, "costUsdTicks": 1038524000 } }, "numTurns": 6 } }, "_meta": { "eventId": "", "agentTimestampMs": 1785237763526, "cancelTrigger": "esc" } } }Q2. Which location does ccusage use for token usage?
A: Only
sessions/**/updates.jsonl.ccusage discovery (feature branch):
ccusage/rust/adapters/grok/src/paths.rsL17–L28 (resolve_root:GROK_HOMEthen~/.grok)discover_session_filesundersessions/)logs/unified.jsonlnot used for usage stats (diagnostic only; see Q1 unified sources).Q3. How are tokens extracted?
A: Reader: ccusage Grok adapter (feature branch). Writer wire: grok-build (Q1).
Line filter —
ccusage/rust/adapters/grok/src/parser.rs"turn_completed"sessionUpdate == "turn_completed"usagemodelUsagerowsmodel_usage_rows; def L276+)split_tokens); apply L205–L206input_tokensuncached, cache read, output); L267 (extra_total_tokens= reasoning)cost_usd: None)Field meaning on the wire — grok-build
inputTokens(includes cache on ACP)notification.rsL171–L175cachedReadTokensoutputTokensreasoningTokenscostUsdTicksccusage maps: uncached
input − cache, cache → cache_read, full output, reasoning → extra_total only (not billed separately).Q4. How is
GROK_HOMEresolved?Grok CLI (grok-build)
xai-grok-config/src/paths.rsL28–L31 —default_grok_home()→~/ .grokgrok_home(): envGROK_HOMEif set, elsedefault_grok_home();create_dir_allccusage (feature branch)
ccusage/rust/adapters/grok/src/paths.rsL9 —GROK_HOME_ENV = "GROK_HOME"GROK_HOMEdir, else~/.grokif existsNo
CCUSAGE_GROK_PATH, no--grok-path, no configgrokPathon this branch.GROK_HOME="$HOME/.grok-alt" ccusage grok dailyPR ready
LeeShunEE commentedon Jul 28, 2026
quick start
cd rust cargo run -p ccusage --release --features fetch-litellm-pricing -- grok dailyLeeShunEE commentedon Aug 7, 2026
@ryoppippi
To answer your "did you really try it?" question from before — yes, and here is the proof from a real run. The POC is the adapter itself:
ccusage grok dailyon my machine (grok 0.2.112, Windows), reading realturn_completedusage from~/.grok/sessions/**/updates.jsonl:The PR (#1520) is synced to the latest
main(147e05b), and the full suite passes:ccusage-adapter-grok39 passed (+ real-home smoke),ccusage-cli-parser75,ccusage-config26,ccusage-adapter-all36.Both this issue and the PR were auto-closed by the contributor gate — a reopen /
lgtmwhen you have a chance would be much appreciated.ryoppippi commentedon Aug 7, 2026
i'm sorry please wait for a couple of days. i don't feel well this week... i'm kind a exhausted this week. i'm sorry
LeeShunEE commentedon Aug 10, 2026
Sorry for being pushy earlier. Hope you’re feeling better now :)
Btw, having an issue immediately closed by a bot and getting no reply is a little bit frustrating.
ryoppippi commentedon Aug 10, 2026
lgtmi
ryoppippi commentedon Aug 10, 2026
lgtm
github-actions commentedon Aug 10, 2026
@LeeShunEE approved for issues and PRs. Your future issues and PRs will not be auto-closed.
See CONTRIBUTING.md.
ryoppippi commentedon Aug 31, 2026
Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.
Audit result: resolved. A later merged change or the current
mainimplementation covers this request. This item is kept for history and does not need to be reopened.