pi-reduce
Reduce Pi session context by rebuilding the current branch with only the message types you keep.
Package details
Install pi-reduce from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-reduce- Package
pi-reduce- Version
0.1.0- Published
- Apr 16, 2026
- Downloads
- 141/mo · 8/wk
- Author
- toorusr
- License
- MIT
- Types
- extension
- Size
- 51.6 KB
- Dependencies
- 0 dependencies · 4 peers
Pi manifest JSON
{
"extensions": [
"./extensions/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-reduce
pi-reduce is a Pi package that rebuilds the current branch into a smaller session.
It keeps only the message types you want, drops the rest, and writes the result into a brand new Pi session that you continue from immediately.
No summaries are generated in v1. The reduction is deterministic: keep, drop, and truncate only.
Install
pi install npm:pi-reduce
Or from git:
pi install git:github.com/toorusr/pi-reduce
Commands
/reduce [chat|reasoning|tools|no-tools|advanced|last]/reduce-advanced
Presets
chat— keep user messages and final assistant output onlyreasoning— keep user messages, assistant thinking, assistant comments, and final outputtools— keep user messages plus tool calls and tool resultsno-tools— keep user messages plus assistant comments and final outputlast— rerun the last reduce configadvanced— open the full reducer UI
What gets reduced
/reduce always starts from the current active branch context. It does not rewrite your source session. Instead it:
- reads the current branch context
- filters messages by type
- optionally filters tools by name
- optionally truncates tool arguments and tool results
- creates a new session
- switches into the new session immediately
The current model and thinking level are copied to the new session.
Advanced options
/reduce-advanced lets you configure:
Message categories
- user messages
- assistant thinking
- assistant comments from tool-using turns
- assistant final messages
- assistant status / aborted / error messages
- tool calls
- tool results
- user bash executions (
!/!!) - custom / extension messages
- existing branch summaries
- existing compaction summaries
Tool filters
- keep all tools
- keep only selected tools
- exclude selected tools
Truncation
- tool call approx-token budget
- tool call char budget
- tool call line budget
- tool result approx-token budget
- tool result char budget
- tool result line budget
- head or tail truncation for tool results
Output
The final notification shows a compact before/after summary with:
- context reduction bar
- approximate context tokens before vs after
- kept vs removed messages
- key block reductions (thinking, tool calls, tool results)
- recorded source usage totals
The new reduced session also stores provenance in a reduce-source custom entry.
Notes
- Copied messages do not preserve historical assistant usage tags, so the new session starts with
0recorded usage until you continue chatting. - Approximate token counts use Pi's own conservative
chars / 4heuristic. - Tool-result
detailsare replaced with compact reduced metadata so the new session stays light.
Local development
npm install
npm run check
For a quick local test without installing the package:
pi -e /absolute/path/to/pi-reduce