Repository navigation
fix(trace): separate Pi cache token accounting - #3719
Conversation
Recompute Pi v2 totals from native input and output counters, preserve cache categories, and verify them against cache-active raw session records. Assisted-by: Vibhav's Pi Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
PR validation — ✅ 3 passing
AI Session Checks — ⏭️ bypassed by labelAI Coding Session Check BypassedThis PR carries the Learn more about Chainloop Trace. Security Checks — ✅ 6 passing✅
|
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | secrets-detection |
- |
✅ sast-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | owasp-top10-2025 |
- |
| ✅ Passed | sast |
- |
| ✅ Passed | cwe-top25 |
- |
| ✅ Passed | cwe-top26-40-cusp |
- |
✅ iac-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | iac-misconfiguration |
- |
Scans not applied (2)
| Scan | Reason |
|---|---|
vulnerability-scan |
no manifest/lockfile changed |
github-actions-scan |
no workflow files changed |
Security context
✅ Nothing this change touches has a recorded security-fix history.
View in Chainloop ↗ · How this works ↗
Powered by Chainloop and Chainloop Trace
|
I see, so I was confused thinking that PI itself went to v2, when the change proposed a change in our session spec to v2. As @jiparis said, I'd not do it for now, let's just make the change in the calculation since there are no schema changes. Also, can you make sure |
Retain the existing Chainloop evidence version while normalizing Pi cache counters. Clarify that agent releases and evidence versions are distinct. Assisted-by: Vibhav's Pi Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
Compare Pi usage with the native session records regardless of the Chainloop evidence version; only Codex requires its v2 accounting guard. Assisted-by: Vibhav's Pi Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
The core provider and I’d suggest grouping the remaining Pi work into three phases:
This is a suggested way to organize the followups, not a list of things Pi needs before it’s useful. Happy to adjust the order around what would help people most. I would prioritze 3 then 2 and have 1 as good first issues. These would also probably require feature flags or config based on what the user would and wouldn't like to enable for the target harness for collection. |
uups, sorry that message was cut off and sounded rude. In fact what I wanted to say was "Last time I tried it, But that's not the case anymore |
Summary
schema_version: v1while recording native input, output, cache-read, and cache-write separatelytotal_tokensfrom base input plus output instead of trusting Pi's cache-inclusivetotalTokensThis implements the Pi-only #3720, a slice of the broader cross-provider #3706. The focused tracker was created after this PR opened to keep subsequent work issue-first. This PR does not close the broader all-provider tracker.
Trace provider checklist
Validation
go test -race -shuffle=on -count=1 ./internal/trace/pi ./internal/trace/e2ego build ./...go vet ./...golangci-lint run --new-from-rev upstream/mainCHAINLOOP_E2E_HARNESS=Pi CHAINLOOP_E2E_MODEL=openrouter/anthropic/claude-haiku-5.5 CHAINLOOP_E2E_FEATURE='Cache token accounting' make -C app/cli test-trace-e2eThe live run had nonzero cache reads and writes and passed with the matrix expecting
Yes.make -C app/cli teststill hits two existing local-environment failures that reproduce unchanged onupstream/main:cmd/TestLoadAuthTokenwhenCHAINLOOP_TOKENis inherited, and CodexTestCopySessionData*on the macOS storage-root path. The changed Pi and E2E packages pass under the race detector.AI assistance
Vibhav's Pi assisted with implementation, testing, and review. Both commits are signed, DCO-compliant, and carry
Assisted-by: Vibhav's Pi.The repository requires a
skip-ai-sessionlabel because the available Chainloop login cannot access thechainloopproject to upload the session. GitHub denied the label update with HTTP 403 (repository admin rights required), so a maintainer must apply it. This does not bypass code, test, DCO, or signature checks.