Trail Finding and Pi Review Token Deduplication

Pi·GPT-5.5·dipree·2mo ago·28hr 49min·3 Checkpoints·6 file changes·+89/-16·949.2K tokens

Address "entire trail finding"

2mo ago·3.4s

Implemented.

Changed:

  • cmd/entire/cli/trail_cmd.go

    • Root entire trail help now explicitly mentions entire trail finding.
    • Shared trail blurb via trailContextBlurb().
  • cmd/entire/cli/lifecycle.go

    • Agent context injection now uses the same blurb, so agents learn about entire trail finding.
  • Tests updated/added:

    • TestTrailRootPrintsHelp
    • TestEntireTrailContextInjectionMentionsFindings

Verified:

  • go test ./cmd/entire/cli -count=1

Was there any feature creep happening here?

2mo ago·6.0s

A little, but only in messaging—not functionality.

What changed:

  • Added entire trail finding to the entire trail help blurb.
  • Reused that same blurb for the agent context injection.
  • Added tests to lock both surfaces.

No new commands, API behavior, flags, or UX flows were added.

The only arguable scope expansion is that I updated both the CLI help text and the agent-injected hint, because they previously duplicated the same sentence. If you wanted the fix limited strictly to the context injection or strictly to help output, I can narrow it.

Commit and push the fixes (pull first).

2mo ago·4.9s

Done.

  • Pulled/rebased origin/review-pi-reviewer
  • Resolved autostash conflicts
  • Ran go test ./cmd/entire/cli -count=1
  • Committed: e52b748b4 Mention trail findings in trail help
  • Pushed to origin/review-pi-reviewer

Entire Trail review comment ID: 019f1ebb-8946-708f-9454-999bd43c3017 URL: https://entire.io/gh/entireio/cli/trails/467/review-pi-reviewer Severity: low Context: cmd/entire/cli/agent/pi/reviewer.go:193 Selected context:

addPiReviewTokens adds usage.Input + usage.CacheRead + usage.CacheWrite into total.In. For OpenAI-shaped usage, cache-read tokens are reported as a subset of input tokens (the codex reviewer in this repo explicitly avoids summing subset fields to prevent double-counting), and Pi normalizes across providers including OpenAI (gpt-5). If Pi's Input already includes cached tokens, this inflates the reported input count. Confirm Pi's input/cacheRead/cacheWrite are mutually exclusive before summing.

2mo ago·5.4s

Addressed and pushed.

  • Changed Pi reviewer token aggregation to use only usage.Input for Tokens.In, avoiding double-counting cache subset fields.
  • Left cache-specific accounting to transcript token usage, where cache fields are stored separately.
  • Updated Pi reviewer tests.
  • Ran: go test ./cmd/entire/cli/agent/pi -count=1
  • Commit: 6699ec40a Avoid double counting Pi review cache tokens
  • Pushed to origin/review-pi-reviewer

Entire Trail review comment ID: 019f1ec1-3e28-7373-81b8-bbf656ff9184 URL: https://entire.io/gh/entireio/cli/trails/467/review-pi-reviewer Severity: low Context: cmd/entire/cli/agent/pi/reviewer.go:179 Selected context:

emitPiReviewTokens only dedupes usage when env.MessageID() is non-empty. The realistic stream fixture (TestPiReviewer_ParseJSONEventStream) shows message_end carrying usage with no id/message.id, so MessageID() returns "" and the dedup guard is skipped entirely. If Pi also emits a turn_end (which this parser explicitly reads usage from) for the same turn without an id, the input/output tokens would be counted twice. Consider a per-turn/per-type dedup fallback when no id is available.

2mo ago·13.8s