Repository navigation
fix: stop re-counting Claude usage on resume - #1175
Merged
sox8502 merged 4 commits intoNov 22, 2026
Merged
Conversation
Claude restores its running modelUsage totals when a session is resumed, so a new process's first turn must subtract the session's saved totals, not zero. A total below the saved one now counts from zero instead of being dropped, for Claude versions that don't restore. Fixes ORX-813
Contributor
Author
|
@greptileai review |
Contributor
[Medium impact] The reviewed changes appear safe to merge once the documented backend deployment is complete. SummaryThe PR stops resumed Claude processes from counting earlier usage again and adds a stable, hashed
Reviews (4) · Last reviewed commit: "fix: send no chat reference with telemet..." · Reviewed by Greptile |
A reset was only applied to the result event that saw it, so a later snapshot in the same attempt reloaded the old totals and under-counted.
Contributor
Author
|
@greptileai review |
A stable hash of the install and chat ids lets reports from one chat be told apart, so a turn that re-counts its chat's history shows up in one query. openresearch.sh must accept chatRef before this ships. Refs ORX-813
Contributor
Author
|
@greptileai review |
chat_ref ran before the suppressed check and minted an install id on an opted-out or source build that had none.
Contributor
Author
|
@greptileai review |
3 of 6 tasks
sox8502
deleted the
daniel/orx-813-claude-token-usage-re-counts-the-whole-chat
branch
November 22, 2026 21:01
1 task
small-angel
added a commit
that referenced
this pull request
Nov 23, 2026
main stopped persisting whether a Claude process had counted usage (#1175), so the keeper record drops its usage_started field. Forgetting a remote host now reports a saved session it could not remove. Fixes ORX-834 Assisted-by: claude-opus-5.5
small-angel
added a commit
that referenced
this pull request
Nov 23, 2026
main stopped persisting whether a Claude process had counted usage (#1175), so the keeper record drops its usage_started field. Forgetting a remote host now reports a saved session it could not remove. Fixes https://linear.app/alphaxiv/issue/ORX-834/keep-agents-and-terminals-alive-across-orx-up-restarts Assisted-by: claude-opus-5.5
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.
Fixes ORX-813.
Since 0.2.29, the first turn after orx starts a new Claude process for an existing chat reports the chat's entire history as that turn's tokens. Daily Claude Code usage in telemetry roughly doubled on Nov 21 (12.5B → 26.9B) while installs fell; Codex and the other harnesses did not move.
Why: Claude's
result.modelUsageis a running total for the session, and--resumerestores it (checked with Claude Code 2.1.330: a resumed process reports the old totals plus the new turn, exact to the token). #1031 made the first attempt of each new Claude process start from a zero baseline, on the assumption that the totals restart with the process. Processes restart routinely (15-minute idle reaper, orx restart or update, config change, retry), so long chats got re-counted again and again.Fix:
usage_started) is gone.Load-bearing choice: a total below the saved one is read as "started from zero". A fresh process whose first turn alone exceeds the session's old total would be under-counted by that old total; current Claude versions restore totals, so this only affects older ones.
Chat reference in usage reports: each
chat_model_usagereport now carrieschatRef, a hash of the install ID and the chat ID shaped as a UUID. It's the same for every turn of a chat and doesn't reveal the chat ID, so a chat whose reported usage jumps by its whole history can be found with one query. This is new data leaving the machine, recorded inarc/storage.md.chatRef) must deploy before this merges. Until then every usage report from this build would be rejected. The release workflow's contract gate (production_contract_is_accepted) now sendschatRefand would catch it.Telemetry already sent by 0.2.29 stays inflated; that's handled on the openresearch.sh side.
Test plan
a_resumed_claude_counts_only_its_new_usage: restored totals count only the new turn; totals that restart from zero count in full, including a later snapshot past the old totals (Greptile finding)cumulative_baselines_exclude_resume_history_and_replace_repeated_snapshotsa_chat_ref_is_stable_per_chat_and_hides_the_chat_idcargo fmt --all --check,cargo clippy --all-targets -- -D warnings,cargo build --locked,cargo test --locked. Fourorx-hostwrapper tests (tests/wrapper.rs) fail locally, and fail the same way on a cleanorigin/mainnode dev.ts restart, the resumed process reported a running total of 191,128 and the turn recorded 65,306. 0.2.29 would have recorded the full 191,128chatRefaccepted by production