pi-tool-duration

Make host-observed Pi tool-call timing visible to the model

Packages

Package details

extension

Install pi-tool-duration from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-tool-duration
Package
pi-tool-duration
Version
0.6.6
Published
Nov 2, 2026
Downloads
602/mo · 70/wk
Author
fitchmultz
License
MIT
Types
extension
Size
27.7 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./extensions/tool-duration"
  ]
}

Security note

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

README

pi-tool-duration

This Pi extension adds elapsed time to tool results that the model receives. Use it to give the model context about slow or failed tool calls.

Pi runs a tool. The extension saves elapsed time and adds a marker to the model's copy. The terminal keeps its native output.

Install

Use Pi and Node.js. The development guide lists version requirements. Tests cover official Pi and the maintained fitchmultz/pi fork.

pi install npm:pi-tool-duration
pi

Run /reload in an open Pi session to load the extension. Then try a tool call.

Try it

Ask Pi to run this tool call:

Use bash to run: sleep 1; echo hi

The model receives hi and a marker such as [host tool-call elapsed: 1.0s]. The marker reports elapsed time to tenths of a second.

Configure

The default threshold is 50 ms. Faster successful calls get no marker because their time would round to 0.0s.

Failed calls get a marker at any threshold when Pi records their start and end.

Set the threshold when you start Pi:

# Include all observed tool results.
PI_TOOL_DURATION_THRESHOLD_MS=0 pi

# Include successful calls of at least one second and failed calls.
PI_TOOL_DURATION_THRESHOLD_MS=1000 pi

# Set a 500 ms threshold through the CLI.
pi --tool-duration-threshold-ms 500

Use a non-negative number of milliseconds. A valid CLI value takes precedence over the environment variable.

Timing limits

The measurement includes preflight and result processing. Parallel calls can overlap. Do not add their durations to measure total task time.

A tool that starts a background job reports the duration of the launch call.

The extension leaves recorded tool output and terminal output unchanged.

The extension saves elapsed time in the session. Timings survive reload, resume, forks, branch navigation, and retained compaction history. A compaction summary can omit individual timings.

Direct ! / !! commands and RPC bash messages are outside the scope of this extension.

Details

Read the timing reference for measurement boundaries, history matching, compaction, and OpenAI Responses setup.

See development and maintenance for Git installation, local setup, compatibility checks, and releases.

Changelog · Report a problem

License

MIT · Mitch Fultz