docs: clarify 'DCP summary blocks' not message blocks, note message counting reset

This commit is contained in:
wassname
2026-04-16 13:29:09 +08:00
parent ad9c550b41
commit 3cc0e9b612
3 changed files with 14 additions and 7 deletions
+8 -1
View File
@@ -11,6 +11,7 @@ Automatically reduces token usage in Pi coding agent sessions by managing conver
- **Manual mode** — disable autonomous compression nudges; trigger compression only via `/dcp compress` or explicit user request
- **Session persistence** — compression blocks and pruning state survive session restarts
- **`/dcp` commands** — inspect context usage, view stats, sweep tool outputs, and manage compression blocks interactively
- **Auto-compaction** — triggers pi's built-in compaction when DCP summary blocks exceed a configurable fraction of context, preventing indefinite block accumulation
## Installation
@@ -81,7 +82,13 @@ DCP uses a layered configuration system (later layers override earlier ones):
// Glob patterns — matching file paths are never pruned
"protectedFilePatterns": [],
// "off" | "minimal" | "detailed"
"pruneNotification": "detailed"
"pruneNotification": "detailed",
// Auto-compaction: trigger pi's built-in compaction when DCP summary blocks
// occupy >= this fraction of context tokens (0 = disabled).
// Compaction deactivates all DCP blocks and resets message counting.
// "compact": {
// "autoCompactThreshold": 0.5
// }
}
```
+3 -3
View File
@@ -24,7 +24,7 @@ export interface DcpConfig {
protectUserMessages: boolean
}
compact: {
autoCompactThreshold: number // 0-1, fraction of context that DCP blocks must occupy before triggering compaction (0 = disabled)
autoCompactThreshold: number // 0-1, fraction of context that DCP summary blocks must occupy before triggering compaction (0 = disabled). Compaction deactivates all DCP blocks and resets message counting.
}
strategies: {
deduplication: {
@@ -62,7 +62,7 @@ const DEFAULT_CONFIG: DcpConfig = {
protectUserMessages: false,
},
compact: {
autoCompactThreshold: 0.5, // trigger compaction when DCP blocks occupy >= 50% of context tokens
autoCompactThreshold: 0.5, // trigger compaction when DCP summary blocks occupy >= 50% of context tokens. Resets message counting.
},
strategies: {
deduplication: {
@@ -109,7 +109,7 @@ const DEFAULT_CONFIG_FILE_CONTENT = `{
// "protectedFilePatterns": [],
// "pruneNotification": "detailed",
// "compact": {
// "autoCompactThreshold": 0.5 // trigger pi compaction when DCP blocks >= 50% of context (0 = disabled)
// "autoCompactThreshold": 0.5 // trigger pi compaction when DCP summary blocks >= 50% of context (0 = disabled). Resets message counting.
// }
}
`
+3 -3
View File
@@ -202,7 +202,7 @@ export default function (pi: ExtensionAPI) {
// automaticStrategies is on) but skip autonomous nudge injection.
const usage = ctx.getContextUsage()
if (usage && usage.tokens !== null) {
// ── Auto-compaction: if DCP blocks exceed threshold, trigger pi compaction ──
// ── Auto-compaction: if DCP summary blocks exceed threshold, trigger pi compaction ──
if (!state.manualMode && config.compact.autoCompactThreshold > 0) {
const activeBlocks = state.compressionBlocks.filter((b) => b.active)
const dcpBlockTokens = activeBlocks.reduce((sum, b) => sum + b.summaryTokenEstimate, 0)
@@ -263,10 +263,10 @@ export default function (pi: ExtensionAPI) {
return { messages: prunedMessages }
})
// ── 11. session_compact: deactivate all DCP blocks ───────────────────────
// ── 11. session_compact: deactivate all DCP summary blocks and reset message counting ───────────────────────
// When pi's built-in compaction runs, it folds all prior context (including
// DCP summary blocks) into a single compaction summary. All active DCP
// blocks are now redundant — deactivate them.
// blocks are now redundant — deactivate them and reset message counting.
pi.on("session_compact", async (_event, _ctx) => {
const activeBlocks = state.compressionBlocks.filter((b) => b.active)
if (activeBlocks.length > 0) {