Skip to content

Safe branch summary replaces the built-in branch summarizer ​

pi budgets the branch summary request at contextWindow - reserveTokens, measured in its own chars/4 estimate. Code-heavy branches tokenize up to about 1.85x denser than that estimate (observed: a 266420-token request against a 160000-token window, rejected with exceed_context_size_error), so a branch that fits the budget still overflows the window the server serves, the navigation dies, and no summary is written. The Safe branch summary extension therefore replaces the built-in summarizer on the before-tree event and budgets the request as (Effective window minus pi's own branchSummary.reserveTokens) divided by the Inflation factor, default 2.0, so the worst-case tokenization of code content still fits the window.

Considered options: a guard that takes over only when a pessimistic check says the built-in would overflow, leaving the built-in for fitting branches - rejected because the budget math is wrong for every branch, so the extension fixes the budget instead of racing the built-in on it; calling pi's exported generateBranchSummary with an adjusted reserve - rejected because an extension cannot obtain the session's resolved request auth, so OAuth-based providers would break; raising branchSummary.reserveTokens in settings - rejected because it is a static per-machine knob that burns branch content even when the branch fits. An upstream fix was declined for this version; the extension stands alone.

Consequences: every summarized navigation writes its summary through the extension, so its system prompt, branch prompt, preamble, file-op sections, and 4096 output cap are verbatim copies of pi 0.86.1 and drift silently if upstream changes them (cosmetic: the format stays model-readable). Content denser than 2 chars per token (for example CJK) is not covered by factor 2.0 and can still overflow; the Soft-skip then degrades the navigation to summary-less instead of failing it. The built-in runs again only while the extension is disabled.