Commit Graph

3 Commits

Author SHA1 Message Date
JackChen 6de7bbd41f
feat: add rule-based compact context strategy (#111) (#119)
* feat: add rule-based compact context strategy (#111)

Add `contextStrategy: 'compact'` as a zero-LLM-cost alternative to `summarize`.
Instead of making an LLM call to compress everything into prose, it selectively
compresses old turns using structural rules:

- Preserve tool_use blocks (agent decisions) and error tool_results
- Replace long tool_result content with compact markers including tool name
- Truncate long assistant text blocks with head excerpts
- Keep recent turns (configurable via preserveRecentTurns) fully intact
- Detect already-compressed markers from compressToolResults to avoid double-processing

Closes #111

* fix: remove redundant length guard and fix compact type indentation
2026-04-16 23:34:50 +08:00
MrAvalonApple 629d9c8253 feat: implement synthetic framing for user messages and enhance context strategy handling 2026-04-12 00:18:36 +03:00
MrAvalonApple eb484d9bbf feat: add context management strategies (sliding-window, summarize, custom) to prevent unbounded conversation growth 2026-04-09 19:40:15 +03:00