Skip to content

Trace: normalize Pi cache token totals #3720

Open

Description

@waveywaves

Problem

Pi v1 evidence used Pi's supplied totalTokens, which can include cache reads and writes. That inflates the reported total even when native input, output, and cache fields are separate.

Scope

Pi token normalization only. The implementation is already under review in PR #3719; this focused tracker makes that slice explicit under the broader cross-provider audit #3706.

Acceptance criteria

  • Pi evidence version distinguishes cache-exclusive totals from historical v1 totals.
  • Preserve native input, output, cache-read, cache-write, and provider-reported cost. Set total to input + output, excluding cache.
  • Handle malformed and overflowing usage deterministically and count only the selected branch, including resumed history.
  • Independently compare stored evidence with raw Pi counters in an actual cache-active run and update only the Pi compatibility cell.
  • Verify the signed Pi-scoped PR and document any remaining broader Trace: define cache accounting and prevent token overcounting across providers #3706 gaps without closing the parent issue.

Non-goals

  • Changing Codex, Claude, Cursor, or OpenCode accounting.
  • Repricing provider cost or changing the shared evidence schema.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions