billion-context-pi 0.1.58 → 0.1.59-pr.301.129

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/README.md CHANGED
@@ -103,6 +103,8 @@ billion-context-pi is built for the **Pi** coding agent (`@earendil-works/pi-cod
103
103
 
104
104
  Full details: [docs/omp.md](./docs/omp.md).
105
105
 
106
+ - **Coexisting with the [billion-context](https://github.com/ranxianglei/billion-context) wire proxy** — running both on the same session double-compresses every request (wasted tokens, nested summaries, two ref coordinate systems). This is prevented automatically: launcher paths (`bili pi`, …) export `BILLION_CONTEXT_PROXY`, and models whose `baseUrl` routes through the proxy (`…/bili/https://upstream…`) are detected at session start — in both cases billion-context-pi stands down with a warning and leaves the proxy as the sole compressor. One exception: transparent mode, where traffic reaches the proxy via `HTTPS_PROXY` so the URL carries no `/bili/` prefix — that is undetectable from the URL, so export `BILLION_CONTEXT_PROXY=1` before starting pi in that case.
107
+
106
108
  ## Model-facing tools
107
109
 
108
110
  | Tool | What it does |
@@ -222,10 +224,10 @@ The `.acp.json` sidecar is what holds your compressed blocks. Without it, the se
222
224
 
223
225
  ### Migrating a session (cross-machine copy / backup-restore)
224
226
 
225
- Pi's built-in export/import moves only the **transcript**, not the ACP state. Two things are lost:
227
+ Pi's built-in export/import moves only the **transcript**, not the ACP state. Two things are affected:
226
228
 
227
- 1. **The `.acp.json` sidecar is not carried.** An imported session therefore has *no* compressed blocks: every LLM call resends the entire raw history until the nudge re-compresses it — a one-time full re-cache cost plus context bloat back to original size. Very long sessions can approach or exceed the model window before re-compression kicks in (Pi's native compaction is disabled while this plugin is active, so ACP is the only context manager).
228
- 2. **Export drops the `parentSession` header.** Clone/fork child sessions rely on that header field to inherit their parent's compression state; once exported, the link is gone even if the parent's files still exist on the target machine.
229
+ 1. **The `.acp.json` sidecar is not carried.** As a fallback, ACP now **rebuilds the compression state by replaying the session log itself**: on the first context event after import, it re-applies every successful `compress` call recorded in the transcript (assistant tool-call arguments + tool results) through the kernel, restoring the block structure, summaries, message refs and cumulative stats, then persists the recreated sidecar (#299). Errored, no-op and unparseable calls are skipped; the replay runs only when no sidecar and no inheritable parent state exists. This removes the old behavior — resending the entire raw history until the nudge re-compresses, with a one-time full re-cache cost and context bloat back to original size. Caveat: the replay restores what the *log* records, so summaries come back exactly as stored in the transcript, and stats like per-message token snapshots are re-derived rather than bit-identical.
230
+ 2. **Export drops the `parentSession` header.** Clone/fork child sessions rely on that header field to inherit their parent's compression state; once exported, the link is gone even if the parent's files still exist on the target machine. (A host-side fix is proposed upstream in [pi#1](https://github.com/ranxianglei/pi/pull/1).)
229
231
 
230
232
  **To migrate a session with its compression state intact, copy both files together** (they share the same base name):
231
233
 
@@ -238,7 +240,7 @@ cp -r ~/.pi/agent/sessions <backup>/pi-sessions
238
240
 
239
241
  Restore them next to each other on the target machine. For clone/fork children, also bring the parent's pair so `parentSession` resolves.
240
242
 
241
- > A permanent fix — the host carrying the sidecar through import/export and preserving `parentSession` — belongs upstream in pi-coding-agent and is tracked in issue [#299](https://github.com/ranxianglei/billion-context-pi/issues/299). Until it lands, copy the pair manually.
243
+ > If you import only the `.jsonl`, ACP's log-replay fallback rebuilds the state automatically on the next session (see above). Copying the pair is still preferred — it is exact, while the replay re-derives token snapshots and can only restore what the transcript records.
242
244
 
243
245
  ## Built on acp-kernel
244
246
 
package/README.zh-CN.md CHANGED
@@ -102,6 +102,8 @@ billion-context-pi 面向 **Pi** 编码代理(`@earendil-works/pi-coding-agent`)
102
102
 
103
103
  完整说明:[docs/omp.zh-CN.md](./docs/omp.zh-CN.md)。
104
104
 
105
+ - **与 [billion-context](https://github.com/ranxianglei/billion-context) 线代理共存** —— 两者同时作用于同一会话会对每个请求双重压缩(token 浪费、嵌套摘要、两套 ref 坐标系)。这会被自动防止:launcher 路径(`bili pi` 等)导出 `BILLION_CONTEXT_PROXY`;模型 `baseUrl` 经代理路由(`…/bili/https://upstream…`)时在会话开始即被检测到 —— 两种情况下 billion-context-pi 都会带警告让位,由代理独占压缩。一个例外:透明模式(流量经 `HTTPS_PROXY` 到达代理、URL 无 `/bili/` 前缀)无法从 URL 识别 —— 此时请在启动 pi 前导出 `BILLION_CONTEXT_PROXY=1`。
106
+
105
107
  ## 模型工具
106
108
 
107
109
  | 工具 | 作用 |
package/dist/config.d.ts CHANGED
@@ -206,6 +206,12 @@ export interface AdapterConfig {
206
206
  * disables) or a ThrottleRetryConfig object. Default: enabled, 10 retries,
207
207
  * 60s exponential base capped at 300s per kick. */
208
208
  throttleRetry?: boolean | ThrottleRetryConfig;
209
+ /** Cap on the output-headroom reservation as a fraction of the context
210
+ * window: reserved = min(model.maxTokens, pct * window). Accepts a ratio
211
+ * (0.25) or percent string ("25%"). Default: 0.25. Set 0 to disable the
212
+ * reservation entirely; >= 1 restores the legacy full-capability
213
+ * reservation (issue #207). */
214
+ outputHeadroomMaxPct?: number | string;
209
215
  /** Generic tool-call repetition guard (see RepetitionGuardConfig). Accepts a
210
216
  * boolean shorthand (`false` disables) or an object. Default: enabled,
211
217
  * warn=3, abort=5. Stops greedy small models looping on byte-identical