@kingingwang/pi-linux-arm64 0.85.1 → 0.86.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/CHANGELOG.md +110 -0
- package/bin/README.md +3 -1
- package/bin/docs/compaction.md +39 -13
- package/bin/docs/custom-provider.md +22 -13
- package/bin/docs/development.md +4 -4
- package/bin/docs/docs.json +4 -0
- package/bin/docs/environment-variables.md +1 -0
- package/bin/docs/extensions.md +57 -43
- package/bin/docs/json.md +4 -4
- package/bin/docs/models.md +33 -2
- package/bin/docs/providers.md +10 -2
- package/bin/docs/sdk.md +4 -2
- package/bin/docs/security.md +1 -1
- package/bin/docs/session-format.md +82 -40
- package/bin/docs/sessions.md +27 -0
- package/bin/docs/settings.md +56 -1
- package/bin/docs/termux.md +0 -1
- package/bin/docs/tui.md +2 -2
- package/bin/docs/usage.md +1 -0
- package/bin/examples/extensions/README.md +0 -1
- package/bin/examples/extensions/custom-provider-anthropic/index.ts +18 -12
- package/bin/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/bin/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/bin/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/bin/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/bin/examples/extensions/gondolin/package-lock.json +2 -2
- package/bin/examples/extensions/gondolin/package.json +1 -1
- package/bin/examples/extensions/prompt-customizer.ts +19 -67
- package/bin/examples/extensions/sandbox/package-lock.json +2 -2
- package/bin/examples/extensions/sandbox/package.json +1 -1
- package/bin/examples/extensions/with-deps/package-lock.json +2 -2
- package/bin/examples/extensions/with-deps/package.json +1 -1
- package/bin/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
- package/bin/package.json +17 -23
- package/bin/pi +2 -2
- package/package.json +1 -1
- package/bin/examples/extensions/kimi-deferred-tools.ts +0 -61
- package/bin/node_modules/@mariozechner/clipboard/.yarnrc.yml +0 -1
- package/bin/node_modules/@mariozechner/clipboard/Cargo.toml +0 -45
- package/bin/node_modules/@mariozechner/clipboard/README.md +0 -60
- package/bin/node_modules/@mariozechner/clipboard/build.rs +0 -5
- package/bin/node_modules/@mariozechner/clipboard/clipboard.linux-arm64-gnu.node +0 -0
- package/bin/node_modules/@mariozechner/clipboard/exp.ts +0 -12
- package/bin/node_modules/@mariozechner/clipboard/index.d.ts +0 -37
- package/bin/node_modules/@mariozechner/clipboard/index.js +0 -606
- package/bin/node_modules/@mariozechner/clipboard/package.json +0 -56
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/common.rs +0 -307
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/mod.rs +0 -93
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/ios.rs +0 -313
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/macos.rs +0 -471
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/mod.rs +0 -252
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/wayland.rs +0 -431
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/win.rs +0 -712
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/x11.rs +0 -916
- package/bin/node_modules/@mariozechner/clipboard/src/lib.rs +0 -194
package/bin/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,114 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.86.1] - 2026-09-20
|
|
4
|
+
|
|
5
|
+
### New Features
|
|
6
|
+
|
|
7
|
+
- **Meta Muse provider** — Sign in with Meta using `/login meta` or use `META_API_KEY` to access Muse Spark models. See [Meta (Muse subscription)](docs/providers.md#meta-muse-subscription).
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Added Meta (Muse subscription) login via `/login meta` with automatic Model API key refresh, plus `META_API_KEY` support ([#9096](https://github.com/earendil-works/pi/pull/9096) by [@xl0](https://github.com/xl0)).
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Enabled Node's persistent compile cache before loading the bundled CLI runtime, reducing repeat launch time.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Fixed `/bug` descriptions dropping line breaks from pasted diagnostics.
|
|
20
|
+
- Fixed `/bug` hints appearing for user cancellations and retryable provider failures such as service unavailability.
|
|
21
|
+
- Fixed clipboard copy failing in containers and WSL without WSLg by restoring the OSC 52 fallback when no display is available, and added a verified Windows clipboard backend for WSL ([#9688](https://github.com/earendil-works/pi/issues/9688)).
|
|
22
|
+
- Fixed inherited z.ai `Prompt too long` errors not being recognized as context overflow ([#9805](https://github.com/earendil-works/pi/issues/9805)).
|
|
23
|
+
- Fixed inherited Cerebras models advertising unsupported strict tool schemas, which caused HTTP 400 errors when strict and non-strict tools were mixed ([#9804](https://github.com/earendil-works/pi/pull/9804) by [@EdenGottlieb](https://github.com/EdenGottlieb)).
|
|
24
|
+
|
|
25
|
+
## [0.86.0] - 2026-09-19
|
|
26
|
+
|
|
27
|
+
### New Features
|
|
28
|
+
|
|
29
|
+
- **Prompt cache warming** — Keep valuable prompt caches alive during long tool runs and optionally while idle using cost-aware refreshes. See [Cache Warming](docs/settings.md#cache-warming).
|
|
30
|
+
- **Bug reporting** — Report problems with `/bug` using redacted diagnostics, optional transcripts, or exported ZIP archives. See [Reporting Bugs](docs/sessions.md#reporting-bugs).
|
|
31
|
+
- **Transcript-aware prompt and tool updates** — Preserve instruction and tool changes across resume and branch navigation while retaining cached prefixes. See [`before_agent_start`](docs/extensions.md#before_agent_start).
|
|
32
|
+
- **Offline Radius model catalog** — Select Radius models immediately, with cached and live catalogs overlaid when available. See [Radius](docs/providers.md#radius).
|
|
33
|
+
- **Per-model compaction budgets** — Configure reserved and recent-token budgets by model. See [Per-model overrides](docs/compaction.md#per-model-overrides).
|
|
34
|
+
|
|
35
|
+
### Breaking Changes
|
|
36
|
+
|
|
37
|
+
- Changed inherited pi-ai provider stream inputs from `Context` to normalized `TranscriptContext` values. Custom providers must read system prompts and tool declarations from `context.messages` with `getCurrentSystemPrompt()` and `getCurrentTools()`. See [Custom Streaming API](docs/custom-provider.md#custom-streaming-api).
|
|
38
|
+
- Restricted inherited `ToolCall.arguments` and `ToolResultMessage.details` to JSON-compatible values, changed `ToolResultMessage` into a conditional type, and made `JsonValue` arrays readonly.
|
|
39
|
+
- `user_bash` now fails closed: errors or invalid defined results abort the command without invoking later handlers or executing locally. Return `undefined` to continue propagation; otherwise return `{ operations }` or `{ result }` ([#9068](https://github.com/earendil-works/pi/issues/9068)).
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- Added transcript-backed mid-conversation system prompt and tool changes so instruction and tool updates survive resume and branch navigation while preserving cached prefixes on supported models. See [`before_agent_start`](docs/extensions.md#before_agent_start) and [Entry Types](docs/session-format.md#entry-types) ([#9548](https://github.com/earendil-works/pi/pull/9548)).
|
|
44
|
+
- Added inherited native deferred tool loading for Fireworks Messages models. Use `ToolSearch` or `tool_search` as the loader name for prompt-prefix deferral ([#9323](https://github.com/earendil-works/pi/issues/9323)).
|
|
45
|
+
- Added click toggling for branch summaries, compaction summaries, and skill invocation entries.
|
|
46
|
+
- Added the public Radius model catalog for immediate and offline model selection, with cached and live gateway catalogs overlaid when available.
|
|
47
|
+
- Added `ctx.modelRegistry.stream()` and `streamSimple()` for extension model calls through configured providers with resolved authentication ([#8964](https://github.com/earendil-works/pi/issues/8964)).
|
|
48
|
+
- Added per-model `reserveTokens` and `keepRecentTokens` settings through `compaction.modelOverrides`, with ordinary compaction settings as fallback ([#8133](https://github.com/earendil-works/pi-mono/issues/8133)).
|
|
49
|
+
- Added `compat.allowedFallbackModels` configuration for overriding or disabling Anthropic server-side fallback models ([#9294](https://github.com/earendil-works/pi/issues/9294)).
|
|
50
|
+
- Added an unsubscribe function from `pi.on()` so extensions can drop event handlers. Handlers added or removed during a dispatch apply to later dispatches, not the current one ([#8967](https://github.com/earendil-works/pi/issues/8967)).
|
|
51
|
+
- Exported extension hook event and result types that were previously omitted from the package entry points ([#9642](https://github.com/earendil-works/pi/pull/9642)).
|
|
52
|
+
- Added `/bug [description]` to report a bug to the Pi developers. The report bundles environment, model, provider, extension, and settings metadata (secrets redacted), assistant message diagnostics from the session, optionally the session transcript, or a model-written summary of what went wrong instead. It is uploaded to Radius (no login required; attributed when logged in) or exported as a zip archive, and the report id is recorded in the session as a `pi.bug-report` entry. Crashes are recorded in `~/.pi/agent/crashes.json`, announced once on the next start, and attached to the next report; unexplained errors and exhausted retries point at `/bug` once per session.
|
|
53
|
+
- Added cost-aware prompt-cache warming during long tool runs and optionally while idle, with configurable modes, model cache-lifetime metadata, `/session` diagnostics, transcript notices, and the `cache_warming_decision` extension event. See [Cache Warming](docs/settings.md#cache-warming) ([#9668](https://github.com/earendil-works/pi/pull/9668)).
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- Enabled Node's persistent compile cache before loading the bundled CLI runtime, reducing repeat launch time.
|
|
58
|
+
- Made `--resume` session results appear progressively, using file modification times to prioritize all-folder loading and cancelling outstanding transcript reads after selection.
|
|
59
|
+
- Reduced `--continue` startup time by checking candidate session headers in modification-time order and stopping after the newest matching session.
|
|
60
|
+
- Replaced the external native clipboard dependency with bundled asynchronous macOS, Windows, and X11 helpers while preserving platform command and OSC 52 fallbacks ([#9163](https://github.com/earendil-works/pi/pull/9163)).
|
|
61
|
+
- Reduced inherited fuzzy search latency for long texts by using native substring search instead of scanning each character in JavaScript ([#9267](https://github.com/earendil-works/pi/issues/9267)).
|
|
62
|
+
- Moved compaction, branch summarization, and retry spinners into the editor border alongside the working indicator. Custom editors use the same embedding opt-in for all status spinners.
|
|
63
|
+
- Enabled strict-prefer JSON-schema sampling by default for built-in `read`, `bash`, `powershell`, `edit`, and `write` tools, without requiring `PI_EXPERIMENTAL`. Extensions can re-register tool definitions with `constrainedSampling: false`.
|
|
64
|
+
- Formatted Bash and PowerShell tool durations of at least one minute as minutes and seconds, with hours when needed ([#9628](https://github.com/earendil-works/pi/issues/9628)).
|
|
65
|
+
- Deferred the extension compiler and bundled virtual modules until a filesystem extension is loaded, reducing the baseline SDK import cost ([#9540](https://github.com/earendil-works/pi/issues/9540)).
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
|
|
69
|
+
- Fixed GitHub Copilot GPT models, including GPT-6 Astra, using the Chat Completions adapter instead of the required Responses adapter ([#9253](https://github.com/earendil-works/pi/pull/9253) by [@petrroll](https://github.com/petrroll)).
|
|
70
|
+
- Fixed inherited DeepSeek V4.1 thinking levels on OpenRouter and OpenCode Go preserving provider effort metadata ([#9485](https://github.com/earendil-works/pi/issues/9485)).
|
|
71
|
+
- Fixed inherited bodyless HTTP 400/413 errors from non-Cerebras providers being misclassified as context overflow ([#9482](https://github.com/earendil-works/pi/issues/9482)).
|
|
72
|
+
- Fixed inherited Vercel AI Gateway replaying unsigned thinking as assistant text ([#9676](https://github.com/earendil-works/pi/issues/9676)).
|
|
73
|
+
- Fixed inherited Google Generative AI and Vertex AI using unsupported thinking levels when reasoning is omitted or when model capabilities differ within a Gemini family ([#9455](https://github.com/earendil-works/pi/issues/9455)).
|
|
74
|
+
- Fixed inherited Anthropic-compatible relays breaking signed thinking replay when they report a different response model, while preserving fallback pricing ([#9188](https://github.com/earendil-works/pi/issues/9188)).
|
|
75
|
+
- Fixed inherited Amazon Bedrock one-hour cache writes being priced at the five-minute rate ([#9457](https://github.com/earendil-works/pi/issues/9457)).
|
|
76
|
+
- Fixed inherited quadratic CPU usage when draining buffered `EventStream` events ([#9055](https://github.com/earendil-works/pi/issues/9055)).
|
|
77
|
+
- Fixed inherited Mistral Medium reasoning requests to use `reasoning_effort` for all reasoning-capable `mistral-medium-*` model IDs instead of the unsupported `prompt_mode` ([#8700](https://github.com/earendil-works/pi/issues/8700)).
|
|
78
|
+
- Fixed inherited OpenCode and OpenCode Go requests to send `x-opencode-session` from `sessionId` across all supported API adapters ([#9326](https://github.com/earendil-works/pi/issues/9326)).
|
|
79
|
+
- Fixed inherited OpenAI Codex requests to send the model's Off reasoning effort instead of omitting it, while respecting unsupported Off mappings ([#9191](https://github.com/earendil-works/pi/issues/9191)).
|
|
80
|
+
- Fixed inherited Fireworks unsigned thinking replay and reasoning effort selection using catalog metadata, with verified DeepSeek V4 and Qwen3.8 fallbacks and removal of redundant GLM 5.2 and Kimi K3 effort aliases ([#9323](https://github.com/earendil-works/pi/issues/9323)).
|
|
81
|
+
- Fixed inherited OpenRouter requests to send `x-session-id` from `sessionId` for Chat Completions and Anthropic Messages models when prompt caching is enabled ([#9102](https://github.com/earendil-works/pi/issues/9102)).
|
|
82
|
+
- Fixed the inherited DeepSeek catalog to advertise `deepseek-flash` for DeepSeek V4.1 Flash instead of retired Flash aliases, and refreshed DeepSeek pricing metadata ([#9423](https://github.com/earendil-works/pi/issues/9423)).
|
|
83
|
+
- Fixed inherited Mistral-hosted GLM-5.2 reasoning requests to use `reasoning_effort` instead of the ignored `prompt_mode` ([#9375](https://github.com/earendil-works/pi/issues/9375)).
|
|
84
|
+
- Fixed inherited OpenAI-compatible Responses errors to identify the actual provider instead of always labeling them as OpenAI errors ([#9298](https://github.com/earendil-works/pi/issues/9298)).
|
|
85
|
+
- Fixed inherited Baseten requests to send session-affinity headers from `sessionId` for automatic prompt-cache routing ([#9629](https://github.com/earendil-works/pi/issues/9629)).
|
|
86
|
+
- Fixed inherited retry classification for Cloudflare 520 responses ([#9627](https://github.com/earendil-works/pi/issues/9627)).
|
|
87
|
+
- Fixed inherited retry classification for transient Azure peak-load capacity errors ([#9669](https://github.com/earendil-works/pi/issues/9669)).
|
|
88
|
+
- Fixed session tree navigation racing with active compaction and replacing its progress UI ([#9179](https://github.com/earendil-works/pi/pull/9179) by [@acmerfight](https://github.com/acmerfight)).
|
|
89
|
+
- Fixed exact session ID lookup scanning complete transcript bodies instead of reading session headers ([#9601](https://github.com/earendil-works/pi/pull/9601) by [@metaist](https://github.com/metaist)).
|
|
90
|
+
- Fixed repeated Anthropic thinking-drop notices being shown for the same dropped blocks, and shortened notices while retaining details in the session ([#9391](https://github.com/earendil-works/pi/issues/9391)).
|
|
91
|
+
- Fixed mid-run threshold compaction silently skipping oversized trailing tool results ([#9740](https://github.com/earendil-works/pi/issues/9740)).
|
|
92
|
+
- Fixed signal-terminated local shell commands being reported as successful with partial output ([#9577](https://github.com/earendil-works/pi/issues/9577) by [@BrendanJMurphy](https://github.com/BrendanJMurphy)).
|
|
93
|
+
- Fixed local clipboard failures reporting success when the terminal ignored the fallback OSC 52 write, and added platform-specific setup guidance when no clipboard backend works ([#9618](https://github.com/earendil-works/pi/issues/9618)).
|
|
94
|
+
- Capped agent-level retry backoff at `retry.maxAgentDelayMs` (60s by default) so long retry runs stay responsive during prolonged transient outages ([#8826](https://github.com/earendil-works/pi/issues/8826)).
|
|
95
|
+
- Fixed direct RPC `steer` and `follow_up` commands bypassing extension `input` handlers ([#8718](https://github.com/earendil-works/pi/issues/8718)).
|
|
96
|
+
- Fixed premature missing-model errors after login by waiting for catalog discovery. Radius now defaults to `balanced`, falling back to the first available Radius model when needed.
|
|
97
|
+
- Fixed fullscreen mode reserving a blank row for custom footers that render zero rows ([#8919](https://github.com/earendil-works/pi/issues/8919)).
|
|
98
|
+
- Fixed extension tools without parameter schemas to be rejected during registration instead of breaking provider requests ([#9300](https://github.com/earendil-works/pi/issues/9300)).
|
|
99
|
+
- Fixed `before_agent_start` handlers returning `systemPrompt` (and `forceSystemPrompt`) on models with mid-conversation system messages: the forced prompt is now sent as the provider's leading system prompt instead of being appended as a section patch after the original prompt.
|
|
100
|
+
- Fixed loaded llama.cpp models with `enable_thinking` chat templates ignoring Pi's thinking level ([#9528](https://github.com/earendil-works/pi/issues/9528)).
|
|
101
|
+
- Fixed cancellation races that could start automatic compaction, leave stale retry state, or miss cancellation while waiting for summarization authentication ([#9340](https://github.com/earendil-works/pi/issues/9340), [#9777](https://github.com/earendil-works/pi/issues/9777)).
|
|
102
|
+
- Fixed asynchronous Kitty image conversion replacing newer partial tool output images ([#8743](https://github.com/earendil-works/pi/pull/8743) by [@wutongyuonce](https://github.com/wutongyuonce)).
|
|
103
|
+
- Fixed inherited skill slash-command autocomplete ranking the `skill:` prefix instead of the bare skill name ([#9120](https://github.com/earendil-works/pi/pull/9120) by [@yearth](https://github.com/yearth)).
|
|
104
|
+
- Fixed inherited file autocomplete boundaries and path quoting around CJK punctuation ([#9746](https://github.com/earendil-works/pi/pull/9746) by [@haoqixu](https://github.com/haoqixu)).
|
|
105
|
+
- Fixed inherited LaTeX legacy font switches falling back to raw source, centered `cases` layouts around surrounding equations, and vertically laid out unsupported and nested display scripts ([#8827](https://github.com/earendil-works/pi/issues/8827), [#9564](https://github.com/earendil-works/pi/issues/9564), [#7929](https://github.com/earendil-works/pi/issues/7929)).
|
|
106
|
+
- Fixed inherited fullscreen Kitty images being erased by later row clears in WezTerm ([#9169](https://github.com/earendil-works/pi/issues/9169)).
|
|
107
|
+
|
|
108
|
+
### Removed
|
|
109
|
+
|
|
110
|
+
- Removed unavailable inherited GPT-5.4 and GPT-5.4 mini models from OpenAI Codex selection ([#9394](https://github.com/earendil-works/pi/issues/9394)).
|
|
111
|
+
|
|
3
112
|
## [0.85.1] - 2026-09-05
|
|
4
113
|
|
|
5
114
|
### New Features
|
|
@@ -32,6 +141,7 @@
|
|
|
32
141
|
- Added inherited OpenAI-compatible `vllmPriority` and `supportsMaxOutputTokens` model settings for vLLM scheduler priority and OpenAI Responses output-token limits ([#9004](https://github.com/earendil-works/pi/pull/9004) by [@AppleDannyClegg](https://github.com/AppleDannyClegg), [#8941](https://github.com/earendil-works/pi/pull/8941) by [@scturtle](https://github.com/scturtle)).
|
|
33
142
|
- Added inherited LaTeX rendering for relational algebra join symbols ([#9050](https://github.com/earendil-works/pi/pull/9050) by [@haoqixu](https://github.com/haoqixu)).
|
|
34
143
|
- Added a clickable "Jump to latest message" label with the `tui.altScreen.bottom` shortcut to the fullscreen transcript while it is scrolled up ([#9080](https://github.com/earendil-works/pi/pull/9080) by [@rwachtler](https://github.com/rwachtler)).
|
|
144
|
+
- Added Meta (Muse subscription) login via `/login meta` with automatic Model API key refresh, plus `META_API_KEY` support.
|
|
35
145
|
|
|
36
146
|
### Changed
|
|
37
147
|
|
package/bin/README.md
CHANGED
|
@@ -130,6 +130,7 @@ For each built-in provider, pi maintains a list of tool-capable models. Configur
|
|
|
130
130
|
- Together AI
|
|
131
131
|
- Baseten
|
|
132
132
|
- Kimi For Coding
|
|
133
|
+
- Meta
|
|
133
134
|
- MiniMax
|
|
134
135
|
- Xiaomi MiMo
|
|
135
136
|
- Xiaomi MiMo Token Plan (China)
|
|
@@ -195,6 +196,7 @@ Type `/` in the editor to trigger commands. [Extensions](#extensions) can regist
|
|
|
195
196
|
| `/export [file]` | Export session to HTML or JSONL file |
|
|
196
197
|
| `/import <file>` | Import and resume a session from a JSONL file |
|
|
197
198
|
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
199
|
+
| `/bug [description]` | Report a bug to the Pi developers; see [Sessions](docs/sessions.md#reporting-bugs) |
|
|
198
200
|
| `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
|
|
199
201
|
| `/hotkeys` | Show all keyboard shortcuts |
|
|
200
202
|
| `/changelog` | Display version history |
|
|
@@ -255,7 +257,7 @@ Use `/session` in interactive mode to see the current session ID before reusing
|
|
|
255
257
|
|
|
256
258
|
### Branching
|
|
257
259
|
|
|
258
|
-
**`/tree`** - Navigate the session tree in-place. Select any previous point, continue from there, and switch between branches. All history preserved in a single file.
|
|
260
|
+
**`/tree`** - Navigate the session tree in-place. Select any previous point, continue from there, and switch between branches. All history preserved in a single file. Selecting a point while the model is responding cancels that response. Navigation cannot proceed while compaction or another tree navigation is still running; wait for it to finish and retry.
|
|
259
261
|
|
|
260
262
|
<p align="center"><img src="docs/images/tree-view.png" alt="Tree View" width="600"></p>
|
|
261
263
|
|
package/bin/docs/compaction.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
LLMs have limited context windows. When conversations grow too long, Pi uses compaction to summarize older content while preserving recent work. This page covers both auto-compaction and branch summarization.
|
|
4
4
|
|
|
5
|
-
**Source files** ([pi
|
|
6
|
-
- [`packages/coding-agent/src/core/compaction/compaction.ts`](https://github.com/earendil-works/pi
|
|
7
|
-
- [`packages/coding-agent/src/core/compaction/branch-summarization.ts`](https://github.com/earendil-works/pi
|
|
8
|
-
- [`packages/coding-agent/src/core/compaction/utils.ts`](https://github.com/earendil-works/pi
|
|
9
|
-
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/earendil-works/pi
|
|
10
|
-
- [`packages/coding-agent/src/core/extensions/types.ts`](https://github.com/earendil-works/pi
|
|
5
|
+
**Source files** ([pi](https://github.com/earendil-works/pi)):
|
|
6
|
+
- [`packages/coding-agent/src/core/compaction/compaction.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) - Auto-compaction logic
|
|
7
|
+
- [`packages/coding-agent/src/core/compaction/branch-summarization.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts) - Branch summarization
|
|
8
|
+
- [`packages/coding-agent/src/core/compaction/utils.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/utils.ts) - Shared utilities (file tracking, serialization)
|
|
9
|
+
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/session-manager.ts) - Entry types (`CompactionEntry`, `BranchSummaryEntry`)
|
|
10
|
+
- [`packages/coding-agent/src/core/extensions/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/extensions/types.ts) - Extension event types
|
|
11
11
|
|
|
12
12
|
For TypeScript definitions in your project, inspect `node_modules/@earendil-works/pi-coding-agent/dist/`.
|
|
13
13
|
|
|
@@ -120,7 +120,7 @@ Never cut at tool results (they must stay with their tool call).
|
|
|
120
120
|
|
|
121
121
|
### CompactionEntry Structure
|
|
122
122
|
|
|
123
|
-
Defined in [`session-manager.ts`](https://github.com/earendil-works/pi
|
|
123
|
+
Defined in [`session-manager.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/session-manager.ts):
|
|
124
124
|
|
|
125
125
|
```typescript
|
|
126
126
|
interface CompactionEntry<T = unknown> {
|
|
@@ -145,7 +145,7 @@ interface CompactionDetails {
|
|
|
145
145
|
|
|
146
146
|
Extensions can store any JSON-serializable data in `details`. The default compaction tracks file operations, but custom extension implementations can use their own structure. Generated and extension-provided summaries store their LLM `usage` when available so session totals include summarization work.
|
|
147
147
|
|
|
148
|
-
See [`prepareCompaction()`](https://github.com/earendil-works/pi
|
|
148
|
+
See [`prepareCompaction()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) and [`compact()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) for the implementation. For direct programmatic summarization, `generateSummary()` returns the summary text and `generateSummaryWithUsage()` returns `{ text, usage }`.
|
|
149
149
|
|
|
150
150
|
## Branch Summarization
|
|
151
151
|
|
|
@@ -188,7 +188,7 @@ This means file tracking accumulates across multiple compactions or nested branc
|
|
|
188
188
|
|
|
189
189
|
### BranchSummaryEntry Structure
|
|
190
190
|
|
|
191
|
-
Defined in [`session-manager.ts`](https://github.com/earendil-works/pi
|
|
191
|
+
Defined in [`session-manager.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/session-manager.ts):
|
|
192
192
|
|
|
193
193
|
```typescript
|
|
194
194
|
interface BranchSummaryEntry<T = unknown> {
|
|
@@ -212,7 +212,7 @@ interface BranchSummaryDetails {
|
|
|
212
212
|
|
|
213
213
|
Same as compaction, extensions can store custom data in `details`.
|
|
214
214
|
|
|
215
|
-
See [`collectEntriesForBranchSummary()`](https://github.com/earendil-works/pi
|
|
215
|
+
See [`collectEntriesForBranchSummary()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts), [`prepareBranchEntries()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts), and [`generateBranchSummary()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts) for the implementation.
|
|
216
216
|
|
|
217
217
|
## Summary Format
|
|
218
218
|
|
|
@@ -256,7 +256,7 @@ path/to/changed.ts
|
|
|
256
256
|
|
|
257
257
|
### Message Serialization
|
|
258
258
|
|
|
259
|
-
Before summarization, messages are serialized to text via [`serializeConversation()`](https://github.com/earendil-works/pi
|
|
259
|
+
Before summarization, messages are serialized to text via [`serializeConversation()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/utils.ts):
|
|
260
260
|
|
|
261
261
|
```
|
|
262
262
|
[User]: What they said
|
|
@@ -272,7 +272,7 @@ Tool results are truncated to 2000 characters during serialization. Content beyo
|
|
|
272
272
|
|
|
273
273
|
## Custom Summarization via Extensions
|
|
274
274
|
|
|
275
|
-
Extensions can intercept and customize both compaction and branch summarization. See [`extensions/types.ts`](https://github.com/earendil-works/pi
|
|
275
|
+
Extensions can intercept and customize both compaction and branch summarization. See [`extensions/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/extensions/types.ts) for event type definitions.
|
|
276
276
|
|
|
277
277
|
### session_before_compact
|
|
278
278
|
|
|
@@ -288,7 +288,7 @@ pi.on("session_before_compact", async (event, ctx) => {
|
|
|
288
288
|
// preparation.fileOps - extracted file operations
|
|
289
289
|
// preparation.tokensBefore - context tokens before compaction
|
|
290
290
|
// preparation.firstKeptEntryId - where kept messages start
|
|
291
|
-
// preparation.settings -
|
|
291
|
+
// preparation.settings - effective settings after applying model overrides
|
|
292
292
|
|
|
293
293
|
// branchEntries - all entries on current branch (for custom state)
|
|
294
294
|
// reason - "manual" (/compact), "threshold", or "overflow"
|
|
@@ -416,3 +416,29 @@ Configure compaction in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settin
|
|
|
416
416
|
| `keepRecentTokens` | `20000` | Recent tokens to keep (not summarized) |
|
|
417
417
|
|
|
418
418
|
Disable auto-compaction with `"enabled": false`. You can still compact manually with `/compact`.
|
|
419
|
+
|
|
420
|
+
### Per-model overrides
|
|
421
|
+
|
|
422
|
+
Use `compaction.modelOverrides` to tune token budgets for different models:
|
|
423
|
+
|
|
424
|
+
```json
|
|
425
|
+
{
|
|
426
|
+
"compaction": {
|
|
427
|
+
"reserveTokens": 16384,
|
|
428
|
+
"keepRecentTokens": 20000,
|
|
429
|
+
"modelOverrides": {
|
|
430
|
+
"some-provider/big-model": {
|
|
431
|
+
"reserveTokens": 400000
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
For a model with a 1M context window, this override triggers compaction above 600K tokens and keeps the ordinary 20000 recent tokens. Other models retain the ordinary 16384-token reserve. `reserveTokens` also influences summarization output limits, capped by the model's maximum output tokens; it is not solely a trigger threshold.
|
|
439
|
+
|
|
440
|
+
Keys are exact, case-sensitive `provider/modelId` values, including any slashes within the model ID. Each `reserveTokens` and `keepRecentTokens` value falls back independently from the model override to the ordinary setting to the built-in default. Values must be non-negative safe integers. Invalid values in the matching model override produce an error when read; only omitted fields fall back to the ordinary setting. Model override entries must be objects. Invalid ordinary token settings produce an error when read, even if the active model has a valid override. Only omitted ordinary values use built-in defaults. `enabled` remains global, not model-specific.
|
|
441
|
+
|
|
442
|
+
These resolved values are used for manual compaction, all automatic threshold checks, overflow recovery, and extension-visible `preparation.settings`. Model switches affect subsequent checks and compactions without changing ordinary settings. Compaction already in progress uses the model and settings captured for that operation. Branch summarization settings are unaffected.
|
|
443
|
+
|
|
444
|
+
Overrides work in both global and project settings. The files merge recursively before lookup, so a global model-specific value beats a project-wide fallback; a project must override that model entry to change it. See [settings.md](settings.md#per-model-compaction-overrides) for details.
|
|
@@ -397,34 +397,40 @@ interface OAuthCredentials {
|
|
|
397
397
|
For providers with non-standard APIs, implement `streamSimple`. Study the existing API implementations before writing your own:
|
|
398
398
|
|
|
399
399
|
**Reference implementations:**
|
|
400
|
-
- [anthropic-messages.ts](https://github.com/earendil-works/pi
|
|
401
|
-
- [mistral-conversations.ts](https://github.com/earendil-works/pi
|
|
402
|
-
- [openai-completions.ts](https://github.com/earendil-works/pi
|
|
403
|
-
- [openai-responses.ts](https://github.com/earendil-works/pi
|
|
404
|
-
- [google-generative-ai.ts](https://github.com/earendil-works/pi
|
|
405
|
-
- [bedrock-converse-stream.ts](https://github.com/earendil-works/pi
|
|
400
|
+
- [anthropic-messages.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/anthropic-messages.ts) - Anthropic Messages API
|
|
401
|
+
- [mistral-conversations.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/mistral-conversations.ts) - Mistral Conversations API
|
|
402
|
+
- [openai-completions.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/openai-completions.ts) - OpenAI Chat Completions
|
|
403
|
+
- [openai-responses.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/openai-responses.ts) - OpenAI Responses API
|
|
404
|
+
- [google-generative-ai.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/google-generative-ai.ts) - Google Generative AI
|
|
405
|
+
- [bedrock-converse-stream.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/bedrock-converse-stream.ts) - AWS Bedrock
|
|
406
406
|
|
|
407
407
|
### Stream Pattern
|
|
408
408
|
|
|
409
|
-
All providers follow the same pattern:
|
|
409
|
+
All providers follow the same pattern. The context is a normalized transcript: the system prompt and tool declarations live in its system messages, so read them with `getCurrentSystemPrompt(context.messages)` and `getCurrentTools(context.messages)` rather than expecting `context.systemPrompt` or `context.tools`. Models that accept system messages mid-conversation can send them in place; otherwise call `collapseSystemMessages(context)` first to fold later system messages into the leading one.
|
|
410
410
|
|
|
411
411
|
```typescript
|
|
412
412
|
import {
|
|
413
413
|
type AssistantMessage,
|
|
414
414
|
type AssistantMessageEventStream,
|
|
415
|
-
type Context,
|
|
416
415
|
type Model,
|
|
417
416
|
type SimpleStreamOptions,
|
|
417
|
+
type TranscriptContext,
|
|
418
418
|
calculateCost,
|
|
419
|
+
collapseSystemMessages,
|
|
419
420
|
createAssistantMessageEventStream,
|
|
421
|
+
getCurrentSystemPrompt,
|
|
422
|
+
getCurrentTools,
|
|
420
423
|
} from "@earendil-works/pi-ai";
|
|
421
424
|
|
|
422
425
|
function streamMyProvider(
|
|
423
426
|
model: Model<any>,
|
|
424
|
-
context:
|
|
427
|
+
context: TranscriptContext,
|
|
425
428
|
options?: SimpleStreamOptions
|
|
426
429
|
): AssistantMessageEventStream {
|
|
427
430
|
const stream = createAssistantMessageEventStream();
|
|
431
|
+
const transcript = collapseSystemMessages(context);
|
|
432
|
+
const systemPrompt = getCurrentSystemPrompt(transcript.messages);
|
|
433
|
+
const tools = getCurrentTools(transcript.messages);
|
|
428
434
|
|
|
429
435
|
(async () => {
|
|
430
436
|
// Initialize output message
|
|
@@ -571,7 +577,7 @@ When a request exceeds the model's context window, pi can recover automatically
|
|
|
571
577
|
Detection runs on the finalized assistant message:
|
|
572
578
|
|
|
573
579
|
- `stopReason === "error"`
|
|
574
|
-
- `errorMessage` matches one of pi's known overflow patterns (see [`packages/ai/src/utils/overflow.ts`](https://github.com/earendil-works/pi
|
|
580
|
+
- `errorMessage` matches one of pi's known overflow patterns (see [`packages/ai/src/utils/overflow.ts`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/utils/overflow.ts))
|
|
575
581
|
|
|
576
582
|
If your provider returns overflow errors with a message pi does not recognize, normalize the error from the same extension that registers the provider. Use a `message_end` handler to rewrite the assistant message so its `errorMessage` starts with a phrase pi recognizes. The generic fallback `context_length_exceeded` is the safest choice.
|
|
577
583
|
|
|
@@ -634,7 +640,7 @@ pi.registerProvider("my-provider", {
|
|
|
634
640
|
|
|
635
641
|
## Testing Your Implementation
|
|
636
642
|
|
|
637
|
-
Test your provider against the same test suites used by built-in providers. Copy and adapt these test files from [packages/ai/test/](https://github.com/earendil-works/pi
|
|
643
|
+
Test your provider against the same test suites used by built-in providers. Copy and adapt these test files from [packages/ai/test/](https://github.com/earendil-works/pi/tree/main/packages/ai/test):
|
|
638
644
|
|
|
639
645
|
| Test | Purpose |
|
|
640
646
|
|------|---------|
|
|
@@ -668,10 +674,10 @@ interface ProviderConfig {
|
|
|
668
674
|
/** API type for streaming. Required at provider or model level when defining models. */
|
|
669
675
|
api?: Api;
|
|
670
676
|
|
|
671
|
-
/** Custom streaming implementation for non-standard APIs. */
|
|
677
|
+
/** Custom streaming implementation for non-standard APIs. Receives a normalized transcript. */
|
|
672
678
|
streamSimple?: (
|
|
673
679
|
model: Model<Api>,
|
|
674
|
-
context:
|
|
680
|
+
context: TranscriptContext,
|
|
675
681
|
options?: SimpleStreamOptions
|
|
676
682
|
) => AssistantMessageEventStream;
|
|
677
683
|
|
|
@@ -727,6 +733,9 @@ interface ProviderModelConfig {
|
|
|
727
733
|
cacheWrite: number;
|
|
728
734
|
};
|
|
729
735
|
|
|
736
|
+
/** Best-effort prompt cache lifetime in seconds per retention tier. Unset disables cache warming. */
|
|
737
|
+
promptCache?: { short?: number; long?: number };
|
|
738
|
+
|
|
730
739
|
/** Maximum context window size in tokens. */
|
|
731
740
|
contextWindow: number;
|
|
732
741
|
|
package/bin/docs/development.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Development
|
|
2
2
|
|
|
3
|
-
See [AGENTS.md](https://github.com/earendil-works/pi
|
|
3
|
+
See [AGENTS.md](https://github.com/earendil-works/pi/blob/main/AGENTS.md) for additional guidelines.
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
git clone https://github.com/earendil-works/pi
|
|
9
|
-
cd pi
|
|
8
|
+
git clone https://github.com/earendil-works/pi
|
|
9
|
+
cd pi
|
|
10
10
|
npm install
|
|
11
11
|
npm run build
|
|
12
12
|
```
|
|
@@ -14,7 +14,7 @@ npm run build
|
|
|
14
14
|
Run from source:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
/path/to/pi
|
|
17
|
+
/path/to/pi/pi-test.sh
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
The script can be run from any directory. Pi keeps the caller's current working directory.
|
package/bin/docs/docs.json
CHANGED
|
@@ -86,6 +86,7 @@ These variables are read by Pi itself:
|
|
|
86
86
|
| `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
|
|
87
87
|
| `PI_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
|
|
88
88
|
| `PI_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
|
|
89
|
+
| `PI_RADIUS_GATEWAY` | Override the Radius gateway origin used by `/bug` uploads and Radius relay connections |
|
|
89
90
|
| `PI_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
|
|
90
91
|
| `PI_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
|
|
91
92
|
| `PI_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
|
package/bin/docs/extensions.md
CHANGED
|
@@ -538,10 +538,13 @@ pi.on("before_agent_start", async (event, ctx) => {
|
|
|
538
538
|
// event.systemPrompt - current chained system prompt for this handler
|
|
539
539
|
// (includes changes from earlier before_agent_start handlers)
|
|
540
540
|
// event.systemPromptOptions - structured options used to build the system prompt
|
|
541
|
-
// .customPrompt -
|
|
541
|
+
// .customPrompt - exact prompt prefix from --system-prompt, SYSTEM.md, or custom templates
|
|
542
|
+
// .forceSystemPrompt - optional exact replacement for the complete prompt
|
|
542
543
|
// .selectedTools - tools currently active in the prompt
|
|
543
544
|
// .toolSnippets - one-line descriptions for each tool
|
|
544
|
-
// .
|
|
545
|
+
// .toolGuidelines - guideline bullets keyed by tool name
|
|
546
|
+
// .promptGuidelines - additional custom guideline bullets
|
|
547
|
+
// .sections - custom XML-wrapped sections keyed by tag name
|
|
545
548
|
// .appendSystemPrompt - text from --append-system-prompt flags
|
|
546
549
|
// .cwd - working directory
|
|
547
550
|
// .contextFiles - AGENTS.md files and other loaded context files
|
|
@@ -560,7 +563,7 @@ pi.on("before_agent_start", async (event, ctx) => {
|
|
|
560
563
|
});
|
|
561
564
|
```
|
|
562
565
|
|
|
563
|
-
The `systemPromptOptions` field gives extensions access to the same structured data Pi uses to build the system prompt.
|
|
566
|
+
The `systemPromptOptions` field gives extensions access to the same structured data Pi uses to build the system prompt. Collections are mutable. Prefer changing `sections`, `selectedTools`, or `promptGuidelines`: Pi diffs the resulting prompt sections against what the model already has and appends one system message patching only the changed sections. Returning `systemPrompt`, or setting `forceSystemPrompt`, replaces the whole prompt for the run: every provider receives the forced text as its leading system prompt (a cache miss when it changes), and the session transcript keeps recording the structured sections. Tool selection changes update both the prompt contributions and executable provider tools; calling `pi.setActiveTools()` inside the handler has the same effect as editing `selectedTools`. Models that accept system messages mid-conversation receive the patch in place and keep their cached prefix; other models get the replayed prompt as their system prompt, which is a cache miss once per change.
|
|
564
567
|
|
|
565
568
|
Inside `before_agent_start`, `event.systemPrompt` and `ctx.getSystemPrompt()` both reflect the chained system prompt as of the current handler. Later `before_agent_start` handlers can still modify it again.
|
|
566
569
|
|
|
@@ -735,6 +738,25 @@ pi.on("after_provider_response", (event, ctx) => {
|
|
|
735
738
|
|
|
736
739
|
Header availability depends on provider and transport. Providers that abstract HTTP responses may not expose headers.
|
|
737
740
|
|
|
741
|
+
#### cache_warming_decision
|
|
742
|
+
|
|
743
|
+
Fired before each prompt-cache refresh with pi's decision filled in. The event carries only pi's cost estimates; use `ctx.model`, `ctx.isIdle()`, and `ctx.getContextUsage()` for everything else.
|
|
744
|
+
|
|
745
|
+
```typescript
|
|
746
|
+
pi.on("cache_warming_decision", (event, ctx) => {
|
|
747
|
+
// event.warmCost: price of this refresh
|
|
748
|
+
// event.missCost: extra price of the next request if the entry is lost
|
|
749
|
+
// event.continuationProbability: pi's estimate that a request arrives in time
|
|
750
|
+
// event.action: "warm" | "stop", pi's decision
|
|
751
|
+
|
|
752
|
+
if (ctx.model?.provider === "my-provider") {
|
|
753
|
+
return { action: "stop" };
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
Return `{ action: "warm" }` or `{ action: "stop" }` to override; the last handler that returns an action wins. `"stop"` ends warming until the next real request.
|
|
759
|
+
|
|
738
760
|
### Model Events
|
|
739
761
|
|
|
740
762
|
#### model_select
|
|
@@ -906,6 +928,8 @@ pi.on("user_bash", (event, ctx) => {
|
|
|
906
928
|
});
|
|
907
929
|
```
|
|
908
930
|
|
|
931
|
+
Returning `undefined` continues to the next handler, then local execution if none handles the event. A valid result stops propagation: `operations` executes the command through the supplied backend, while `result` records the completed command without executing it.
|
|
932
|
+
|
|
909
933
|
### Input Events
|
|
910
934
|
|
|
911
935
|
#### input
|
|
@@ -1016,6 +1040,12 @@ Access to models, providers, and resolved authentication. `ctx.modelRegistry.get
|
|
|
1016
1040
|
|
|
1017
1041
|
`ctx.scopedModels` is the read-only list of models scoped to the current session — the same set the `/scoped-models` command shows. It is resolved at session start from the `--models` CLI flag and the `enabledModels` setting (matched against the available catalogue with minimatch on `provider/modelId` or a bare `modelId`). It is empty when no scoping is configured, meaning every available model is usable. Each entry is `{ model, thinkingLevel? }`, where `thinkingLevel` is set only when a pattern pinned it (e.g. `anthropic/*:high`). Use it to populate a model picker that mirrors the built-in one instead of enumerating the whole catalogue via `ctx.modelRegistry.getAvailable()`.
|
|
1018
1042
|
|
|
1043
|
+
#### Streaming model calls
|
|
1044
|
+
|
|
1045
|
+
Use `ctx.modelRegistry.streamSimple(model, context, options)` for provider-neutral options such as `reasoning`, or `stream()` for API-specific options. Both use configured providers and resolve authentication, including for providers registered with `pi.registerProvider()`. Use these instead of `pi-ai/compat` streaming functions, which cannot see extension provider registrations.
|
|
1046
|
+
|
|
1047
|
+
Both return an `AssistantMessageEventStream`. Iterate it for response events and await `.result()` for the final message. Setup failures produce error events and error results.
|
|
1048
|
+
|
|
1019
1049
|
### ctx.signal
|
|
1020
1050
|
|
|
1021
1051
|
The current agent abort signal, or `undefined` when no agent turn is active.
|
|
@@ -1119,7 +1149,7 @@ const options = ctx.getSystemPromptOptions();
|
|
|
1119
1149
|
const contextPaths = options.contextFiles?.map((file) => file.path) ?? [];
|
|
1120
1150
|
```
|
|
1121
1151
|
|
|
1122
|
-
This has the same shape and mutability as `before_agent_start` `event.systemPromptOptions`: custom prompt, active tools, tool snippets,
|
|
1152
|
+
This has the same shape and mutability as `before_agent_start` `event.systemPromptOptions`: custom or forced prompt, active tools, tool snippets, per-tool and custom rules, custom sections, appended prompt text, cwd, loaded context files, and loaded skills. It may include full context file contents, so treat it as sensitive extension-local data and avoid exposing it through command lists, logs, or autocomplete metadata.
|
|
1123
1153
|
|
|
1124
1154
|
This reports the current base prompt inputs. It does not include per-turn `before_agent_start` chained system-prompt changes, later `context` event message mutations, or `before_provider_request` payload rewrites.
|
|
1125
1155
|
|
|
@@ -1197,7 +1227,7 @@ Options:
|
|
|
1197
1227
|
|
|
1198
1228
|
### ctx.navigateTree(targetId, options?)
|
|
1199
1229
|
|
|
1200
|
-
Navigate to a different point in the session tree:
|
|
1230
|
+
Navigate to a different point in the session tree. Rejects while an agent response, manual or automatic compaction, or another tree navigation is active, even with `summarize: false`. These conflicts leave the active branch unchanged and reject the promise rather than returning `{ cancelled: true }`. Wait for the active operation to finish (for example, with `await ctx.waitForIdle()` in a command handler) and retry:
|
|
1201
1231
|
|
|
1202
1232
|
```typescript
|
|
1203
1233
|
const result = await ctx.navigateTree("entry-id-456", {
|
|
@@ -1360,7 +1390,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
1360
1390
|
|
|
1361
1391
|
### pi.on(event, handler)
|
|
1362
1392
|
|
|
1363
|
-
Subscribe to events. See [Events](#events) for event types and return values.
|
|
1393
|
+
Subscribe to events. Returns an unsubscribe function that removes only that registration. See [Events](#events) for event types and return values.
|
|
1394
|
+
|
|
1395
|
+
```typescript
|
|
1396
|
+
const unsubscribe = pi.on("agent_end", async (event) => {
|
|
1397
|
+
unsubscribe();
|
|
1398
|
+
await updateIntegration(event.messages);
|
|
1399
|
+
});
|
|
1400
|
+
```
|
|
1401
|
+
|
|
1402
|
+
Handlers run in extension load order, then registration order within each extension. Adding or removing a handler does not affect a dispatch already in progress.
|
|
1364
1403
|
|
|
1365
1404
|
### pi.registerTool(definition)
|
|
1366
1405
|
|
|
@@ -2101,14 +2140,14 @@ See [examples/extensions/tool-override.ts](../examples/extensions/tool-override.
|
|
|
2101
2140
|
**Your implementation must match the exact result shape**, including the `details` type. The UI and session logic depend on these shapes for rendering and state tracking.
|
|
2102
2141
|
|
|
2103
2142
|
Built-in tool implementations:
|
|
2104
|
-
- [read.ts](https://github.com/earendil-works/pi
|
|
2105
|
-
- [bash.ts](https://github.com/earendil-works/pi
|
|
2106
|
-
- [powershell.ts](https://github.com/earendil-works/pi
|
|
2107
|
-
- [edit.ts](https://github.com/earendil-works/pi
|
|
2108
|
-
- [write.ts](https://github.com/earendil-works/pi
|
|
2109
|
-
- [grep.ts](https://github.com/earendil-works/pi
|
|
2110
|
-
- [find.ts](https://github.com/earendil-works/pi
|
|
2111
|
-
- [ls.ts](https://github.com/earendil-works/pi
|
|
2143
|
+
- [read.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/tools/read.ts) - `ReadToolDetails`
|
|
2144
|
+
- [bash.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/tools/bash.ts) - `BashToolDetails`
|
|
2145
|
+
- [powershell.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/tools/powershell.ts) - `PowerShellToolDetails`
|
|
2146
|
+
- [edit.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/tools/edit.ts)
|
|
2147
|
+
- [write.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/tools/write.ts)
|
|
2148
|
+
- [grep.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/tools/grep.ts) - `GrepToolDetails`
|
|
2149
|
+
- [find.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/tools/find.ts) - `FindToolDetails`
|
|
2150
|
+
- [ls.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/tools/ls.ts) - `LsToolDetails`
|
|
2112
2151
|
|
|
2113
2152
|
### Remote Execution
|
|
2114
2153
|
|
|
@@ -2239,7 +2278,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2239
2278
|
|
|
2240
2279
|
### Custom Rendering
|
|
2241
2280
|
|
|
2242
|
-
Tools can provide `renderCall` and `renderResult` for custom TUI display. See [tui.md](tui.md) for the full component API and [tool-execution.ts](https://github.com/earendil-works/pi
|
|
2281
|
+
Tools can provide `renderCall` and `renderResult` for custom TUI display. See [tui.md](tui.md) for the full component API and [tool-execution.ts](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/modes/interactive/components/tool-execution.ts) for how tool rows are composed.
|
|
2243
2282
|
|
|
2244
2283
|
By default, tool output is wrapped in a `Box` that handles padding and background. A defined `renderCall` or `renderResult` must return a `Component`. If a slot renderer is not defined, `tool-execution.ts` uses fallback rendering for that slot.
|
|
2245
2284
|
|
|
@@ -2364,38 +2403,13 @@ If a slot renderer is not defined or throws:
|
|
|
2364
2403
|
|
|
2365
2404
|
### Dynamic Tool Loading
|
|
2366
2405
|
|
|
2367
|
-
Extensions can register many tools while keeping only a small initial set active. A tool can then
|
|
2368
|
-
|
|
2369
|
-
This works with every model. Models with native deferred-loading support preserve the stable prompt prefix and load the new definitions at the tool-result position. Other models use the fallback described below.
|
|
2406
|
+
Extensions can register many tools while keeping only a small initial set active. A tool can then change the active set with `pi.setActiveTools()` during execution. Pi stores the initial prompt and tool loadout in the transcript's first system message, then appends tool and prompt deltas before the next model request. Providers that cannot represent a transition receive a complete transcript checkpoint, which may invalidate the cached prefix.
|
|
2370
2407
|
|
|
2371
2408
|
The lifecycle is:
|
|
2372
2409
|
|
|
2373
2410
|
1. Register every tool with `pi.registerTool()` so it appears in `pi.getAllTools()`.
|
|
2374
2411
|
2. Keep loader tools, such as `search_tools`, active and leave searchable tools inactive.
|
|
2375
|
-
3. During loader execution, call `pi.setActiveTools(
|
|
2376
|
-
4. Pi records which tools were added on the loader's tool result.
|
|
2377
|
-
5. Before the next model response, Pi exposes the added definitions using native deferred loading when supported, or the normal active tool list otherwise.
|
|
2378
|
-
|
|
2379
|
-
You do not need to return provider-specific tool references or mark the loader as a special search tool. The active-tool change is the signal. Names passed to `pi.setActiveTools()` must already be registered; unknown names are ignored.
|
|
2380
|
-
|
|
2381
|
-
#### Models with native deferred loading
|
|
2382
|
-
|
|
2383
|
-
- **Anthropic**
|
|
2384
|
-
- **Models:** Sonnet, Opus, Fable version 4.5 or newer (without Haiku)
|
|
2385
|
-
- **Native representation:** Deferred definitions use `defer_loading`; the load point uses `tool_reference` content.
|
|
2386
|
-
- **OpenAI**
|
|
2387
|
-
- **Models:** `gpt-5.4` and newer family
|
|
2388
|
-
- **Native representation:** Pi adds completed client `tool_search_call` and `tool_search_output` items at the load point.
|
|
2389
|
-
|
|
2390
|
-
For a verified custom model or proxy, native handling can be enabled with `compat.supportsToolReferences: true` for `anthropic-messages`, or `compat.supportsToolSearch: true` for `openai-responses` and `openai-codex-responses`. Leave these disabled unless the endpoint and model accept the corresponding native protocol.
|
|
2391
|
-
|
|
2392
|
-
#### Fallback behavior
|
|
2393
|
-
|
|
2394
|
-
For all other models and providers, dynamic activation still works: Pi sends the complete current active tool list normally on the next request. The model can call the newly activated tools, but adding their definitions may invalidate the provider's cached prompt prefix.
|
|
2395
|
-
|
|
2396
|
-
Pi also uses this safe fallback when the active set is not purely additive, such as replacing one group of tools with another. Tool removals therefore work, but they do not use deferred loading.
|
|
2397
|
-
|
|
2398
|
-
For the best cache behavior, keep the loader tool active for the whole session and add tools instead of replacing the active set. Also note that activating a tool with `promptSnippet` or `promptGuidelines` rebuilds the system prompt; that system-prompt change can invalidate the prefix even when the provider supports deferred schemas. Lazily loaded tools should usually rely on their tool `description` and omit active-only prompt metadata.
|
|
2412
|
+
3. During loader execution, call `pi.setActiveTools()` with the desired active tool names. Names must already be registered; unknown names are ignored.
|
|
2399
2413
|
|
|
2400
2414
|
#### Search tool example
|
|
2401
2415
|
|
|
@@ -2497,7 +2511,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2497
2511
|
}
|
|
2498
2512
|
```
|
|
2499
2513
|
|
|
2500
|
-
When `search_tools` adds a match, the model receives
|
|
2514
|
+
When `search_tools` adds a match, the model receives the complete updated tool list on the immediately following request.
|
|
2501
2515
|
|
|
2502
2516
|
## Custom UI
|
|
2503
2517
|
|