Repository navigation
Conversation
Accept only the documented nullable Claude cache fields as unknown so native transcripts retain measured sibling counters and attribution. Keep other Claude and Codex counter validation strict, with regression coverage for partial totals and repeated responses.
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @sernote on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
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.
Description
A native Claude Code response containing a documented nullable cache field currently loses its entire token-usage observation, including known sibling counters and attribution. Preserve those measured values while leaving null cache values unmeasured and omitted.
The change accepts null only for
cache_creation,cache_read_input_tokens, andcache_creation_input_tokens. The shared counter parser takes an explicit nullable-path allowlist; Codex supplies an empty list. Invalid non-null values, negative counts, unsupported nulls, partition-sum validation, and response reconciliation retain their existing behavior.Found during a cache-telemetry audit using audit-prompt-caching. Independent validation then reproduced the input with unmodified Claude Code 2.1.17 and the failure with Warp's real extractor. Investigation and implementation were AI-assisted with Codex.
Related: #16240 restructures the same crate and preserves independent reporting after invalid data, but its current head still classifies these nullable fields as invalid. This focused fix targets current
masterand may need to be carried into that change.Linked Issue
Fixes #16645
ready-to-specorready-to-implement. — Newly reported reproducible bug; awaiting maintainer triage.Testing
cargo +1.92.0 test -p warp_harness_usage --locked— passed.cargo +1.92.0 clippy -p warp_harness_usage --locked --all-targets --tests -- -D warnings— passed.git diff --checkpassed.cargo-nextestwas unavailable, so Cargo's native runner was used. No substitute crate or alternate dependency versions were used.Manual producer-to-extractor check: an unmodified pinned
@anthropic-ai/claude-code@2.1.17generated four native JSONL captures against a local fake SSE endpoint. The real Warpextract_claudeAPI was then executed on their assistant records before and after the patch. External networking and access to real user credentials/history were denied during the producer run. Package hashes and the minimal native input are in the linked issue.cache_creation: nullcache_read_input_tokens: nullcache_creation_input_tokens: nullAll three fixed cases retain independent tool coverage and emit no extraction diagnostics. Null is never converted to a measured zero. Production prevalence, provider cache-hit rate, billing impact, and behavior of every Claude Code version were not measured.
./script/run. — Not performed; manual verification exercised the real producer and pure extraction API. No full application build, GUI run, cross-platform checks or full presubmit are claimed.Agent Mode
CHANGELOG-BUG-FIX: Preserve known Claude Code usage counters when optional cache fields are null.