Skip to content
PidocsCLI & tooling

Investigate usage-extension's session log parsing and time filtering

Session from pi-extensions-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk

3msession
0interventions
GOAL

Understand how the Pi usage-extension reads session data—whether usage is tracked per log or per message—and how it filters by time range.

  1. Prompt · +0
    Does usage-extension pull usage per log or per message? Could I see usage between messages 5-20 in a conversation?
  2. Agent did · +0m
    Searched the repo, found usage-extension, read its README and index.ts, and grepped for session directory logic, jsonl parsing, and message role filtering.
  3. Agent did · +1m
    Explained that the extension reads JSONL session logs from ~/.pi/agent/sessions, counting only assistant messages, so usage is tracked per assistant message not per log file; noted a 5-20 message slice isn't exposed by the UI without custom filtering.
  4. Prompt · +2m
    Ok but that would be possible presumably. How does the extension filter for time range? By message?
  5. Agent did · +3m
    Dumped lines 130-340 of index.ts to inspect the parseSessionFile function and time period logic.
  6. Outcome · +3m
    Confirmed time filtering happens per assistant message using msg.timestamp compared against start-of-day/week boundaries, with fallback to entry timestamp; no code changes made.
VERDICT

Next time I'd just ask directly 'does usage-extension track per message or per file, and how does it do time filtering' up front instead of two separate prompts—the agent needed the follow-up question to get to the actual timestamp logic. No corrections were needed here since it was pure code reading, but grepping for specific field names like 'timestamp' and 'split(' was what actually got to the answer.

I tried this · 0

Discussion · 0

How Builds work