@jy02414216/pi-task-timer

A Pi task timer with on-demand timing profiles and tool failure breakdowns.

Packages

Package details

extension

Install @jy02414216/pi-task-timer from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@jy02414216/pi-task-timer
Package
@jy02414216/pi-task-timer
Version
1.1.3
Published
Oct 2, 2026
Downloads
206/mo · 156/wk
Author
jy02414216
License
MIT
Types
extension
Size
27.3 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-task-timer

English | 简体中文

A task timer extension for Pi. It shows the elapsed time of each agent task in the footer and provides an on-demand timing breakdown of the latest task through /time_profile.

Installation

pi install npm:@jy02414216/pi-task-timer

Try it temporarily without changing Pi settings:

pi -e npm:@jy02414216/pi-task-timer

Uninstall:

pi remove npm:@jy02414216/pi-task-timer

Local development

pi -e ./packages/pi-task-timer

After editing the loaded local extension, run /reload in Pi to reload it.

Features

  • Updates elapsed time every second while the agent is working.
  • Keeps the total task duration visible once the task has fully finished.
  • Uses the final model response status consistently in the footer and report: ✓ for normal completion, warning-colored ■ … · Aborted for an abort, and error-colored ✗ … · Model error for a model error. A successful retry restores the normal style.
  • Provides task timing, tool duration rankings, and failed-call durations through /time_profile.
  • Clears timers and timing records on exit, reload, session changes, or branch navigation.

Timing profile

After a task finishes, enter:

/time_profile

Reports and command hints are in English. Reports appear as read-only text in the chat area, without entering the model context or triggering a model request. TUI and UI-capable RPC clients are supported; the footer timer is TUI-only.

The report includes:

  • Total task duration, with LLM, active tool, and other/unclassified time and their percentages.
  • Tools ranked by cumulative duration, with call counts and total time. Average time appears only for tools called more than once.
  • Failed-call counts, durations, and per-tool failure details only when failures occurred.

A normal report looks like this:

Time Profile · 10.18s · 2 turns

LLM     8.04s  79.0%
Tools   2.08s  20.4%
Other    66ms   0.6%

Tools
fetch_content   1 call   2.08s

Normal reports omit Ended, zero-failure information, and measurement notes. Notices for aborts, model errors, overlapping LLM/tool activity, incomplete records, and memory limits appear only when relevant. Measurement details are explained below.

If a task is still running, the command shows the previous task with an explicit notice. If no task has finished, it shows an informational message instead. The command takes no arguments and does not provide session totals, token/cost analysis, repeated-operation detection, or waste analysis.

How time is measured

  • Task: Usually starts at before_agent_start, including startup preparation. Runs that bypass that event, such as extension-triggered model calls, start at agent_start as a fallback. All tasks finish at agent_settled. Automatic retries and continuations neither reset the task nor create duplicate footer timers.
  • LLM phase: From turn_start to the assistant's message_end. This includes request preparation, waiting, and generation, not just model inference. Model calls made inside tools are not broken out separately.
  • Active tool time: The union of tool execution intervals. Parallel and nested intervals count only once. Waiting for user interaction inside a tool is included.
  • Other (unclassified): Total duration minus the union of recorded LLM and tool intervals. This may include event callbacks, phase transitions, or retry delays between turns; these sources are not broken down further. Overlapping LLM/tool activity is reported separately, so percentages cannot simply be added when overlap occurs.
  • Cumulative tool duration: The sum of all calls to a tool, including overlap between parallel calls and parent/child calls. It can exceed total task duration. Averages use only calls with both a start and an end.
  • Call identity: Uses toolCallId, tool name, and parent call ID together, with records stored by actual turn. Normal reuse of an identity across turns counts as separate calls; duplicate start/end events within the same receiving turn are deduplicated. A uniquely identified pending call can receive its end event in a later turn.
  • Failures: Based on Pi's tool_execution_end.isError. Tool output is not parsed, and command failure is not inferred independently. Cumulative failure durations may also overlap.
  • Incomplete records: Missing starts or ends do not produce guessed durations. The report flags incomplete data. An end event without a start in a new turn is retained separately, including its explicit failure status, rather than discarded as a historical duplicate. Unclassified time is not forced into the LLM category.
  • Ambiguous pairing: Different tool names or parent calls can distinguish reused IDs. If multiple unfinished calls share the same complete identity across turns, their start records are retained and that identity is isolated for the rest of the task. End order is not guessed, and uncertain durations or failures are not attributed to those calls. Other identities and subsequent tasks are unaffected. Durations and failure counts in incomplete reports therefore represent only what can be determined reliably. Events do not identify their originating turn, so not every abnormal event sequence can be reconstructed.

Performance and privacy

  • Listens only to task, turn, and tool start/end events, recording a small set of fields with a monotonic clock. It does not listen to per-token or tool streaming updates.
  • Loads the analysis module and performs aggregation, interval merging, sorting, and report formatting only when /time_profile is invoked.
  • Does not retain prompts, tool arguments, or outputs, or read session history. It makes no network requests or disk writes and adds no extra timers.
  • Keeps only the current task and the latest finished task in memory. Each task is limited to 10,000 combined turn/tool records; reaching the limit produces an explicit partial-results notice.
  • Does not persist or restore old tasks. After reload, restart, session changes, or branch navigation, a new task must finish before a report is available.

Lightweight event recording still has some overhead; this is not a zero-overhead claim. The existing once-per-second footer update is unchanged.

License

MIT