pi-collapse-failed-attempt
Collapse partial assistant responses that end with an error in Pi's interactive TUI.
Package details
Install pi-collapse-failed-attempt from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-collapse-failed-attempt- Package
pi-collapse-failed-attempt- Version
0.1.1- Published
- Aug 22, 2026
- Downloads
- 353/mo · 13/wk
- Author
- joshua-zyy
- License
- MIT
- Types
- extension
- Size
- 14.1 KB
- Dependencies
- 0 dependencies · 2 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-collapse-failed-attempt
A Pi extension that keeps interrupted assistant responses from overwhelming the interactive transcript.
When a streamed assistant response ends with an error, Pi may automatically retry the request. Without this extension, the partial response remains fully visible next to the replacement response. This extension collapses that failed attempt into a compact row while preserving its output for inspection.
Features
- Collapses partial assistant text and thinking content after an error.
- Preserves the original Pi retry and session behavior.
- Keeps failed output in the session as a TUI-only entry.
- Does not send the captured failed output back to the model.
- Uses Pi's existing output expansion control, normally
Ctrl+O. - Leaves errors with no partial text or thinking content unchanged.
Requirements
- Pi coding agent with extension and package support.
- A Pi version that provides
message_end,registerEntryRenderer, andappendEntry.
Installation
Install the package from npm:
pi install npm:pi-collapse-failed-attempt
You can also install the package directly from GitHub:
pi install git:github.com/joshua-zyy/pi-collapse-failed-attempt
Pi adds the package to the user-level settings by default. To install it for the current project instead, use the project-local option with either source:
pi install -l npm:pi-collapse-failed-attempt
# or
pi install -l git:github.com/joshua-zyy/pi-collapse-failed-attempt
Restart Pi, or run /reload in an existing session.
To remove the extension:
pi remove npm:pi-collapse-failed-attempt
If it was installed from GitHub instead:
pi remove git:github.com/joshua-zyy/pi-collapse-failed-attempt
Usage
No additional configuration is required. Once installed, the extension is active in interactive TUI sessions.
When a response produces partial content and then fails, the transcript shows a compact row similar to:
↻ Failed response (Ctrl+O to expand partial output)
Use the configured output expansion keybinding to inspect or hide the captured response. The exact key hint is generated by Pi, so it follows custom keybinding configuration.
How It Works
The extension listens for finalized assistant messages with:
stopReason === "error"
For messages that contain text or thinking content, it:
- Stores those parts in a custom session entry.
- Replaces the visible assistant content with an empty body.
- Renders the custom entry as a compact, expandable row.
The extension does not alter Pi's automatic retry policy, retry count, backoff, provider requests, or model context handling.
Limitations
Pi's public extension events do not currently expose whether a particular assistant error will be retried. As a result, this extension collapses every assistant error response that contains partial output, including errors that are not retryable and the final error after retries are exhausted.
The error row remains visible, and the captured output can be expanded. Errors that occur before any text or thinking content is produced are not replaced.
The extension is intended for Pi's interactive TUI. It does not provide a custom renderer for print or JSON output modes.
Development
Clone the repository and load the extension through Pi's normal extension environment. The extension has no runtime dependencies of its own; Pi supplies its core packages.
To validate the extension from a checkout:
pi --offline -e ./extensions/index.ts --list-models
The repository includes development-only declarations under types/ so editors can type-check the extension without installing Pi's bundled packages into the repository.
Contributing
Bug reports and pull requests are welcome. When reporting a problem, include:
- Pi version;
- provider and model;
- whether the response was retried;
- the relevant session behavior;
- terminal and operating system details when the issue is UI-specific.
License
MIT