feat(compaction): add dynamic context pruning as recovery stage

Implements DCP-style pruning strategies inspired by opencode-dynamic-context-pruning plugin:

- Deduplication: removes duplicate tool calls (same tool + args)
- Supersede writes: prunes write inputs when file subsequently read
- Purge errors: removes old error tool inputs after N turns

Integration:
- Added as Stage 2.5 in compaction pipeline (after truncation, before summarize)
- Configurable via experimental.dynamic_context_pruning
- Opt-in by default (experimental feature)
- Protected tools list prevents pruning critical tools

Configuration:
- Turn protection (default: 3 turns)
- Per-strategy enable/disable
- Aggressive/conservative modes for supersede writes
- Configurable error purge threshold (default: 5 turns)
- Toast notifications (off/minimal/detailed)

Testing:
- Added unit tests for deduplication signature creation
- Type check passes
- Schema regenerated

Closes #271
This commit is contained in:
sisyphus-dev-ai
2025-12-27 09:20:42 +00:00
parent 3ba7e6d46b
commit 1fc7fe7122
11 changed files with 1042 additions and 0 deletions

View File

@@ -1383,6 +1383,97 @@
"truncate_all_tool_outputs": {
"default": true,
"type": "boolean"
},
"dynamic_context_pruning": {
"type": "object",
"properties": {
"enabled": {
"default": false,
"type": "boolean"
},
"notification": {
"default": "detailed",
"type": "string",
"enum": [
"off",
"minimal",
"detailed"
]
},
"turn_protection": {
"type": "object",
"properties": {
"enabled": {
"default": true,
"type": "boolean"
},
"turns": {
"default": 3,
"type": "number",
"minimum": 1,
"maximum": 10
}
}
},
"protected_tools": {
"default": [
"task",
"todowrite",
"todoread",
"lsp_rename",
"lsp_code_action_resolve",
"session_read",
"session_write",
"session_search"
],
"type": "array",
"items": {
"type": "string"
}
},
"strategies": {
"type": "object",
"properties": {
"deduplication": {
"type": "object",
"properties": {
"enabled": {
"default": true,
"type": "boolean"
}
}
},
"supersede_writes": {
"type": "object",
"properties": {
"enabled": {
"default": true,
"type": "boolean"
},
"aggressive": {
"default": false,
"type": "boolean"
}
}
},
"purge_errors": {
"type": "object",
"properties": {
"enabled": {
"default": true,
"type": "boolean"
},
"turns": {
"default": 5,
"type": "number",
"minimum": 1,
"maximum": 20
}
}
}
}
}
}
}
}
},